/* ═══════════════════════════════════════════════════
   analysis.css - Work Period Analysis Page Styles
   Requires: style.css (base variables, card, header, etc.)
   ═══════════════════════════════════════════════════ */

/* Navigation styles in style.css (shared) */

/* ─── 2. Date Range Row ─── */
.date-range-row {
  display: flex;
  gap: 16px;
  align-items: end;
}

.date-field {
  flex: 1;
}

.date-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.date-field input[type="date"] {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Cairo', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  direction: ltr;
  text-align: center;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.date-field input[type="date"]:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-glow);
}

/* Webkit date input icon color */
.date-field input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

/* ─── 3. Stats Grid ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 20px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-icon {
  font-size: 1.6rem;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.1;
  direction: ltr;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Stat card color variants */
.stat-avg {
  border-color: rgba(78, 205, 196, 0.15);
  background: rgba(78, 205, 196, 0.04);
}

.stat-avg:hover {
  border-color: rgba(78, 205, 196, 0.3);
}

.stat-avg .stat-value {
  color: var(--success);
}

.stat-avg .stat-icon {
  filter: drop-shadow(0 0 8px rgba(78, 205, 196, 0.3));
}

.stat-max {
  border-color: rgba(244, 196, 48, 0.15);
  background: rgba(244, 196, 48, 0.04);
}

.stat-max:hover {
  border-color: rgba(244, 196, 48, 0.3);
}

.stat-max .stat-value {
  color: var(--gold);
}

.stat-max .stat-icon {
  filter: drop-shadow(0 0 8px var(--gold-glow));
}

.stat-min {
  border-color: rgba(255, 140, 66, 0.15);
  background: rgba(255, 140, 66, 0.04);
}

.stat-min:hover {
  border-color: rgba(255, 140, 66, 0.3);
}

.stat-min .stat-value {
  color: var(--fajr);
}

.stat-min .stat-icon {
  filter: drop-shadow(0 0 8px var(--fajr-glow));
}

.stat-total {
  border-color: rgba(124, 106, 239, 0.15);
  background: rgba(124, 106, 239, 0.04);
}

.stat-total:hover {
  border-color: rgba(124, 106, 239, 0.3);
}

.stat-total .stat-value {
  color: var(--purple);
}

.stat-total .stat-icon {
  filter: drop-shadow(0 0 8px var(--purple-glow));
}

/* ─── 4. Daily Breakdown ─── */
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.card-header-row h2 {
  margin-bottom: 0;
}

.select-all-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}

.select-all-label input[type="checkbox"] {
  accent-color: var(--purple);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Day Group */
.day-group {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.day-group:last-child {
  border-bottom: none;
}

.day-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  cursor: pointer;
  border-right: 3px solid var(--success);
  transition: background 0.2s;
  user-select: none;
}

.day-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.dh-date {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  direction: ltr;
  font-variant-numeric: tabular-nums;
}

.dh-day {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.dh-total {
  margin-right: auto;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--success);
  background: rgba(78, 205, 196, 0.1);
  padding: 3px 12px;
  border-radius: 20px;
  white-space: nowrap;
  direction: ltr;
}

.dh-arrow {
  font-size: 0.72rem;
  color: var(--text-muted);
  transition: transform 0.25s;
  flex-shrink: 0;
}

.day-group.expanded .dh-arrow {
  transform: rotate(180deg);
}

/* Day Body (collapsed by default) */
.day-body {
  display: none;
  padding: 0 0 8px;
}

.day-group.expanded .day-body {
  display: block;
}

/* Day Work Item */
.day-work-item {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid rgba(78, 205, 196, 0.06);
  transition: opacity 0.25s, background 0.2s;
}

.day-work-item:last-child {
  border-bottom: none;
}

.dwi-bar {
  width: 4px;
  background: var(--success);
  flex-shrink: 0;
  border-radius: 2px 0 0 2px;
  transition: background 0.25s;
}

.dwi-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  flex: 1;
}

.dwi-check-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.dwi-check-label input[type="checkbox"] {
  display: none;
}

.dwi-check-custom {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(78, 205, 196, 0.4);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
}

.dwi-check-label input:checked + .dwi-check-custom {
  background: var(--success);
  border-color: var(--success);
}

.dwi-check-label input:checked + .dwi-check-custom::after {
  content: '\2713';
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1;
}

.dwi-info {
  display: flex;
  align-items: center;
  gap: 8px 12px;
  flex: 1;
  flex-wrap: wrap;
}

.dwi-time {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--cyan);
  unicode-bidi: plaintext;
  direction: rtl;
  white-space: nowrap;
}

.dwi-dur {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(78, 205, 196, 0.1);
  padding: 2px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.dwi-between {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  width: 100%;
}

/* Unchecked work item */
.day-work-item.dwi-unchecked {
  opacity: 0.4;
}

.day-work-item.dwi-unchecked .dwi-bar {
  background: var(--text-muted);
}

.day-work-item.dwi-unchecked .dwi-time {
  color: var(--text-muted);
  text-decoration: line-through;
}

.day-work-item.dwi-unchecked .dwi-dur {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}

/* Day with all periods unchecked */
.day-group.day-unchecked {
  opacity: 0.35;
}

.day-group.day-unchecked .day-header {
  border-right-color: var(--text-muted);
}

.day-group.day-unchecked .dh-total {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}

/* ─── 5. Best / Worst Day Highlight ─── */
.day-best .day-header {
  border-right-color: var(--gold);
  background: rgba(244, 196, 48, 0.04);
  box-shadow: inset 0 0 20px rgba(244, 196, 48, 0.03);
}

.day-best .day-header:hover {
  background: rgba(244, 196, 48, 0.07);
}

.day-best .dh-total {
  background: rgba(244, 196, 48, 0.12);
  color: var(--gold);
}

.day-worst .day-header {
  border-right-color: var(--danger);
  background: rgba(255, 107, 107, 0.03);
  box-shadow: inset 0 0 20px rgba(255, 107, 107, 0.02);
}

.day-worst .day-header:hover {
  background: rgba(255, 107, 107, 0.06);
}

.day-worst .dh-total {
  background: rgba(255, 107, 107, 0.1);
  color: var(--danger);
}

/* ─── 6. Responsive ─── */

/* Mobile */
@media (max-width: 600px) {
  .date-range-row {
    flex-direction: column;
    gap: 12px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .stat-card {
    flex-direction: row;
    text-align: start;
    padding: 14px 16px;
    gap: 12px;
  }

  .stat-icon {
    font-size: 1.4rem;
    margin-bottom: 0;
  }

  .stat-value {
    font-size: 1.4rem;
  }

  .stat-label {
    font-size: 0.74rem;
  }

  .day-header {
    padding: 12px 10px;
    gap: 8px;
  }

  .dh-date {
    font-size: 0.82rem;
  }

  .dh-day {
    font-size: 0.78rem;
  }

  .dh-total {
    font-size: 0.7rem;
    padding: 2px 8px;
  }

  .dwi-main {
    padding: 8px 10px;
    gap: 8px;
  }

  .dwi-time {
    font-size: 0.82rem;
  }

  .dwi-dur {
    font-size: 0.7rem;
    padding: 2px 8px;
  }

  .dwi-between {
    font-size: 0.64rem;
  }
}

/* Very small screens */
@media (max-width: 380px) {
  .stat-value {
    font-size: 1.2rem;
  }

  .dh-date {
    font-size: 0.78rem;
  }

  .dh-total {
    font-size: 0.66rem;
  }
}

/* Tablet and up */
@media (min-width: 601px) {
  .date-range-row {
    gap: 20px;
  }

  .date-field input[type="date"] {
    font-size: 1.05rem;
  }

  .stat-value {
    font-size: 2rem;
  }

  .day-header {
    padding: 14px 18px;
  }

  .dwi-main {
    padding: 12px 18px;
  }
}
