/* ==========================================================================
   Mobile-First Design System (Tailored exclusively for Smartphone Displays)
   ========================================================================== */
:root {
  /* Dark Theme Color Tokens (Default) */
  --primary: #a78bfa;
  --primary-hover: #c4b5fd;
  --primary-light: #2e1065;
  --primary-gradient: linear-gradient(135deg, #a78bfa 0%, #f472b6 100%);
  --primary-gradient-subtle: linear-gradient(135deg, rgba(167, 139, 250, 0.18) 0%, rgba(244, 114, 182, 0.18) 100%);

  --secondary: #f472b6;
  --secondary-light: #4c1133;

  --accent: #34d399;
  --accent-light: #064e3b;

  /* Subject Colors (Dark Mode) */
  --islamic-color: #c4b5fd;
  --islamic-bg: #221544;
  --islamic-border: #4c2889;

  --math-color: #f472b6;
  --math-bg: #3b112c;
  --math-border: #701a53;

  --arabic-color: #38bdf8;
  --arabic-bg: #0c2b45;
  --arabic-border: #0369a1;

  --history-color: #fbbf24;
  --history-bg: #3d2406;
  --history-border: #78350f;

  --revision-color: #34d399;
  --revision-bg: #063c2c;
  --revision-border: #047857;

  /* Surfaces & Backgrounds (Dark Theme) */
  --bg-app: #0d0b18;
  --bg-card: #18142a;
  --bg-subtle: #231d3d;
  --bg-glass: rgba(24, 20, 42, 0.94);

  /* Typography Colors */
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --text-light: #94a3b8;

  /* Borders & Shadows */
  --border: #312952;
  --border-subtle: #272044;

  --shadow-sm: 0 2px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 6px 18px -3px rgba(0, 0, 0, 0.65);
  --shadow-lg: 0 12px 28px -4px rgba(0, 0, 0, 0.85);
  --shadow-nav: 0 -4px 18px rgba(0, 0, 0, 0.6);

  /* Radii */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-full: 9999px;

  /* Animations */
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Mobile Reset & Global Styles
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: 'Cairo', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100%;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  touch-action: manipulation;
}

/* Container Frame for Mobile App */
.mobile-app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 40px rgba(139, 92, 246, 0.06);
}

/* ==========================================================================
   Fixed Top Header Bar
   ========================================================================== */
.app-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 999;
  background: var(--bg-glass);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  box-shadow: var(--shadow-sm);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.app-title {
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text-main);
}

.app-subtitle {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.header-progress-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: var(--primary-gradient-subtle);
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 800;
}

/* ==========================================================================
   Main Content Area & Tab Screens
   ========================================================================== */
.app-main {
  flex: 1;
  padding: calc(env(safe-area-inset-top, 0px) + 68px) 14px calc(env(safe-area-inset-bottom, 0px) + 80px);
  width: 100%;
}

.tab-screen {
  display: none;
  animation: fadeInMobile 0.25s ease;
}

.tab-screen.active {
  display: block;
}

@keyframes fadeInMobile {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.screen-header-title {
  margin-bottom: 16px;
}

.screen-header-title h2 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

.screen-header-title p {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ==========================================================================
   Screen 1: Plan (Mobile Hero, Search, Filters, Weeks)
   ========================================================================== */
.mobile-hero-card {
  background: var(--primary-gradient);
  border-radius: var(--radius-lg);
  padding: 16px 16px;
  color: #ffffff;
  box-shadow: var(--shadow-md);
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}

.hero-quote-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.15);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  padding: 8px 12px;
  border-radius: var(--radius-md);
}

.sparkle-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.hero-quote-row p {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.4;
}

.hero-metrics-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  text-align: center;
  margin-bottom: 12px;
}

.hero-metric-item {
  display: flex;
  flex-direction: column;
}

.hero-metric-item .metric-label {
  font-size: 0.68rem;
  opacity: 0.85;
}

.hero-metric-item .metric-num {
  font-size: 0.95rem;
  font-weight: 800;
}

.hero-metric-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.25);
}

.hero-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hero-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 700;
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: #ffffff;
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 0.5s ease;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

/* Mobile Search Bar */
.mobile-search-wrap {
  position: relative;
  margin-bottom: 12px;
}

.mobile-search-wrap input {
  width: 100%;
  padding: 10px 40px 10px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 0.86rem;
  color: var(--text-main);
  outline: none;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.mobile-search-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.search-svg {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* Swipeable Filter Chips */
.scroll-filters-container {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.scroll-filters-container::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
}

.filter-chip.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.25);
}

/* Status Filter Row */
.status-filters-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.status-pills {
  display: flex;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.status-btn {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.74rem;
  font-weight: 700;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
}

.status-btn.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.reset-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Weeks List Accordions */
.weeks-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.week-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition-fast);
}

.week-card.week-complete {
  border-color: var(--accent);
}

.week-card.current-week-card {
  border: 1.5px solid var(--primary);
}

.week-header {
  padding: 14px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  gap: 10px;
  border-bottom: 1px solid transparent;
}

.week-header.expanded {
  border-bottom-color: var(--border-subtle);
  background: var(--bg-subtle);
}

.week-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.week-badge {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--primary-gradient-subtle);
  color: var(--primary);
}

.week-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.week-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.week-progress-pill {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.chevron-icon {
  transition: transform var(--transition-normal);
  color: var(--text-muted);
}

.expanded .chevron-icon {
  transform: rotate(180deg);
}

/* Week Body & Mobile Tasks */
.week-body {
  padding: 12px 14px;
  display: none;
}

.week-body.expanded {
  display: block;
}

.week-note {
  background: var(--secondary-light);
  border-inline-start: 3px solid var(--secondary);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 12px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Mobile Task Item */
.mobile-task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-task-item:last-child {
  border-bottom: none;
}

.task-check-wrap {
  flex-shrink: 0;
  padding-top: 2px;
}

.custom-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--bg-card);
  transition: var(--transition-fast);
}

.custom-checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.task-info-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.task-meta-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.task-day-tag {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-main);
}

.subject-pill-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
}

.pill-islamic { background: var(--islamic-bg); color: var(--islamic-color); border: 1px solid var(--islamic-border); }
.pill-math { background: var(--math-bg); color: var(--math-color); border: 1px solid var(--math-border); }
.pill-arabic { background: var(--arabic-bg); color: var(--arabic-color); border: 1px solid var(--arabic-border); }
.pill-history { background: var(--history-bg); color: var(--history-color); border: 1px solid var(--history-border); }
.pill-revision { background: var(--revision-bg); color: var(--revision-color); border: 1px solid var(--revision-border); }

.task-content-text {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.4;
}

.mobile-task-item.task-done .task-content-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* ==========================================================================
   Screen 2: Subjects, Routine & Rewards
   ========================================================================== */
.subject-cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.subject-card-mob {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.subj-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.subj-fraction {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-main);
}

.subject-progress-mini {
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 6px;
}

.subject-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.subj-card-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.mobile-section-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.section-box-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.routine-list-mob {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.routine-item-mob {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  padding: 8px 10px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
}

.day-badge {
  font-weight: 800;
  color: var(--text-main);
}

.routine-item-mob.weekend-mob {
  background: var(--secondary-light);
  border: 1px dashed var(--secondary);
}

.weekend-badge {
  color: var(--secondary);
}

.reward-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px dashed var(--border);
  margin-bottom: 8px;
  font-size: 0.8rem;
}

.reward-item.unlocked {
  background: var(--secondary-light);
  border-color: var(--secondary);
}

/* ==========================================================================
   Screen 3: Focus Pomodoro Timer
   ========================================================================== */
.timer-card-mob {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.timer-circle-wrap {
  margin: 10px 0 20px;
}

.timer-display {
  font-size: 3.4rem;
  font-weight: 800;
  font-family: 'Plus Jakarta Sans', monospace;
  letter-spacing: 2px;
  color: var(--primary);
  line-height: 1;
}

.timer-status-hint {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  display: block;
  margin-top: 8px;
}

.timer-presets-mob {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.preset-pill {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
}

.preset-pill.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.timer-actions-mob {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.timer-main-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-full);
  background: var(--primary-gradient);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 800;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
  transition: var(--transition-fast);
}

.timer-main-btn:active {
  transform: scale(0.96);
}

.timer-reset-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ==========================================================================
   Screen 4: Notes & Tips
   ========================================================================== */
.add-note-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.notes-textarea-mob {
  width: 100%;
  min-height: 90px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 0.86rem;
  color: var(--text-main);
  resize: vertical;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
  transition: var(--transition-fast);
}

.notes-textarea-mob:focus {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
}

.add-note-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-full);
  background: var(--primary-gradient);
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 800;
  border: none;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(167, 139, 250, 0.35);
  transition: var(--transition-fast);
}

.add-note-btn:active {
  transform: scale(0.97);
}

.notes-items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.single-note-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  transition: var(--transition-fast);
}

.single-note-card:hover {
  border-color: var(--primary);
}

.note-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.note-date-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}

.delete-note-btn {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.delete-note-btn:active {
  transform: scale(0.9);
}

.note-text-body {
  font-size: 0.86rem;
  color: var(--text-main);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-notes-hint {
  text-align: center;
  padding: 16px 10px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.tip-item-mob {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.tip-item-mob:last-child {
  border-bottom: none;
}

.tip-dot {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 800;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ==========================================================================
   Fixed Mobile Bottom Navigation Bar (4 Native Tabs)
   ========================================================================== */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 999;
  background: var(--bg-glass);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-nav);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 8px 10px calc(env(safe-area-inset-bottom, 0px) + 8px);
}

.nav-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.nav-tab-btn span {
  font-size: 0.72rem;
  font-weight: 700;
}

.nav-tab-btn.active {
  color: var(--primary);
}

.nav-tab-btn.active .tab-icon {
  stroke: var(--primary);
  transform: translateY(-2px);
}

.tab-icon {
  transition: transform var(--transition-fast);
}
