/* ════════════════════════════════════════════
   StudyFlow AI — style.css
   Design: Dark-first, neon accents, Syne font
════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
  --bg:        #0d0f1a;
  --surface:   #141627;
  --surface2:  #1c1f35;
  --border:    rgba(255,255,255,0.07);
  --text:      #e8eaf6;
  --text-muted:#7b82b0;
  --accent:    #6c63ff;
  --accent2:   #00d4aa;
  --accent3:   #ff6b6b;
  --accent4:   #ffa94d;
  --blue:      #4fc3f7;
  --green:     #69f0ae;
  --orange:    #ffb74d;
  --purple:    #ce93d8;
  --glow:      0 0 30px rgba(108,99,255,0.25);
  --radius:    14px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
  --transition: 0.25s ease;
}

[data-theme="light"] {
  --bg:        #f0f2ff;
  --surface:   #ffffff;
  --surface2:  #e8ecff;
  --border:    rgba(0,0,0,0.08);
  --text:      #1a1d35;
  --text-muted:#6b72a0;
  --glow:      0 0 30px rgba(108,99,255,0.12);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}

h1,h2,h3,h4 { font-family: 'Syne', sans-serif; }

button { cursor: pointer; font-family: 'DM Sans', sans-serif; border: none; }

input, select, textarea {
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  width: 100%;
}

input::placeholder { color: var(--text-muted); }

/* ════ AUTH ════ */
.auth-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  background-image:
    radial-gradient(ellipse at 20% 20%, rgba(108,99,255,0.18) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(0,212,170,0.12) 0%, transparent 60%);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.5rem 2rem;
  width: min(420px, 92vw);
  box-shadow: var(--glow), 0 24px 80px rgba(0,0,0,0.4);
  animation: slideUp 0.5s ease;
}

.auth-logo {
  font-family: 'Syne', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 1.8rem;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}

.logo-icon { font-size: 1.4em; filter: drop-shadow(0 0 8px var(--accent)); }

.auth-tabs {
  display: flex;
  background: var(--surface2);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 1.5rem;
  gap: 4px;
}

.auth-tab {
  flex: 1;
  padding: 0.55rem;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  transition: all var(--transition);
}

.auth-tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 16px rgba(108,99,255,0.4);
}

.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form.hidden { display: none; }

.input-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  transition: border-color var(--transition);
}

.input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}

.input-group i { color: var(--text-muted); width: 16px; flex-shrink: 0; font-size: 0.9rem; }
.input-group.inline { flex: 1; }

.auth-hint { text-align: center; font-size: 0.8rem; color: var(--text-muted); }

.auth-error {
  background: rgba(255,107,107,0.15);
  border: 1px solid rgba(255,107,107,0.4);
  color: var(--accent3);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  text-align: center;
}

/* ════ BUTTONS ════ */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  background: linear-gradient(135deg, var(--accent), #9c63ff);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--transition);
  box-shadow: 0 4px 20px rgba(108,99,255,0.35);
  white-space: nowrap;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(108,99,255,0.5);
}

.btn-primary.full { width: 100%; }
.btn-primary.sm { padding: 0.5rem 1rem; font-size: 0.82rem; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.9rem;
  transition: all var(--transition);
}

.btn-secondary:hover { color: var(--text); border-color: var(--text-muted); }

/* ════ APP LAYOUT ════ */
.app {
  display: flex;
  min-height: 100vh;
}

.app.hidden { display: none; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform var(--transition);
  padding: 1.5rem 1rem;
}

.sidebar-header {
  display: flex; align-items: center; gap: 0.6rem;
  font-family: 'Syne', sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 2rem;
  padding: 0 0.5rem;
}

.sidebar-nav {
  display: flex; flex-direction: column; gap: 0.4rem;
  flex: 1;
}

.nav-btn {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  width: 100%;
  transition: all var(--transition);
}

.nav-btn i { width: 18px; }

.nav-btn:hover, .nav-btn.active {
  background: rgba(108,99,255,0.15);
  color: var(--accent);
}

.nav-btn.active {
  background: linear-gradient(135deg, rgba(108,99,255,0.2), rgba(156,99,255,0.1));
  color: var(--accent);
  font-weight: 600;
  border-left: 3px solid var(--accent);
}

.sidebar-footer {
  display: flex; flex-direction: column; gap: 0.5rem;
}

.theme-toggle, .logout-btn {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  width: 100%;
  transition: all var(--transition);
}

.theme-toggle:hover { color: var(--accent); }
.logout-btn:hover { color: var(--accent3); }

/* ── Mobile Header ── */
.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  z-index: 300;
  align-items: center;
  justify-content: space-between;
  font-size: 1.1rem;
  font-weight: 700;
}

.hamburger, .theme-toggle-sm {
  background: transparent;
  color: var(--text);
  font-size: 1.1rem;
  padding: 0.4rem;
}

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  padding: 2.5rem;
  flex: 1;
  max-width: 100%;
}

/* ── Sections ── */
.section { display: none; animation: fadeIn 0.35s ease; }
.section.active { display: block; }

.section-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem;
  margin-bottom: 2rem;
}

.section-title {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 800;
  line-height: 1.2;
  background: linear-gradient(135deg, var(--text) 40%, var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section-sub { color: var(--text-muted); margin-top: 0.3rem; font-size: 0.9rem; }

/* ── Streak Badge ── */
.streak-badge {
  background: linear-gradient(135deg, #ff6b35, #ff4d6d);
  color: #fff;
  padding: 0.6rem 1.2rem;
  border-radius: 50px;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex; align-items: center; gap: 0.4rem;
  box-shadow: 0 4px 20px rgba(255,107,53,0.4);
  animation: pulse 2s infinite;
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative; overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
}

.accent-blue::before   { background: linear-gradient(90deg, var(--blue), #1976d2); }
.accent-green::before  { background: linear-gradient(90deg, var(--green), #00c853); }
.accent-orange::before { background: linear-gradient(90deg, var(--orange), #ff6d00); }
.accent-purple::before { background: linear-gradient(90deg, var(--purple), #7b1fa2); }

.stat-card:hover { transform: translateY(-4px); box-shadow: var(--glow); }

.stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.accent-blue   .stat-icon { background: rgba(79,195,247,0.15); color: var(--blue); }
.accent-green  .stat-icon { background: rgba(105,240,174,0.15); color: var(--green); }
.accent-orange .stat-icon { background: rgba(255,183,77,0.15);  color: var(--orange); }
.accent-purple .stat-icon { background: rgba(206,147,216,0.15); color: var(--purple); }

.stat-num { font-family: 'Syne', sans-serif; font-size: 1.8rem; font-weight: 800; display: block; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--text);
}

.card h3 i { color: var(--accent); }

/* ── Dashboard Bottom ── */
.dash-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }

.progress-percent {
  font-family: 'Syne', sans-serif;
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.75rem;
}

.progress-bar-wrap {
  background: var(--surface2);
  border-radius: 50px;
  height: 12px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 50px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.6s ease;
  box-shadow: 0 0 10px rgba(108,99,255,0.5);
}

.motivational {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

/* Focus list */
.focus-list { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }

.focus-item {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  display: flex; align-items: center; gap: 0.6rem;
  border-left: 3px solid var(--accent);
}

.focus-item.done { border-left-color: var(--green); opacity: 0.6; text-decoration: line-through; }

/* ── Task Form ── */
.task-form { display: flex; flex-direction: column; gap: 0.75rem; }
.form-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* ── Task List ── */
.task-list { display: flex; flex-direction: column; gap: 0.75rem; }

.task-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  display: flex; align-items: flex-start; gap: 1rem;
  transition: all var(--transition);
  animation: slideIn 0.3s ease;
}

.task-item:hover { border-color: rgba(108,99,255,0.3); transform: translateX(3px); }

.task-item.completed {
  opacity: 0.55;
  border-color: transparent;
}

.task-item.completed .task-subject { text-decoration: line-through; }

.task-checkbox {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: transparent;
  flex-shrink: 0; margin-top: 2px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
  color: transparent;
  font-size: 0.7rem;
}

.task-item.completed .task-checkbox {
  background: var(--green);
  border-color: var(--green);
  color: #000;
}

.task-body { flex: 1; }

.task-subject {
  font-family: 'Syne', sans-serif;
  font-weight: 700; font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

.task-desc { font-size: 0.82rem; color: var(--text-muted); }

.task-time {
  font-size: 0.78rem;
  color: var(--accent);
  margin-top: 0.3rem;
  display: flex; align-items: center; gap: 0.3rem;
}

.task-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.task-btn {
  width: 32px; height: 32px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}

.task-btn:hover { background: rgba(108,99,255,0.15); color: var(--accent); border-color: var(--accent); }
.task-btn.delete:hover { background: rgba(255,107,107,0.15); color: var(--accent3); border-color: var(--accent3); }

/* ── Date Picker ── */
.date-picker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color var(--transition);
}

.date-picker:focus { outline: none; border-color: var(--accent); }

/* ── AI Section ── */
.ai-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.25rem;
  align-items: start;
}

.ai-gen-btn { margin-top: 0.5rem; }

.ai-output {
  min-height: 300px;
  display: flex; flex-direction: column; gap: 1rem;
}

.ai-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1rem; height: 250px;
  color: var(--text-muted);
  text-align: center;
}

.ai-day-block {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: slideIn 0.3s ease;
}

.ai-day-header {
  padding: 0.65rem 1rem;
  background: rgba(108,99,255,0.15);
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--accent);
}

.ai-session {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  display: flex; justify-content: space-between; align-items: center;
}

.ai-session:last-child { border-bottom: none; }
.ai-session-time { color: var(--text-muted); font-size: 0.78rem; }

/* ── Quotes ── */
.quotes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.quote-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  position: relative;
  overflow: hidden;
  animation: slideUp 0.4s ease;
  transition: transform var(--transition);
}

.quote-card:hover { transform: translateY(-4px); }

.quote-card::before {
  content: '"';
  position: absolute; top: -10px; left: 15px;
  font-size: 8rem;
  font-family: 'Syne', sans-serif;
  color: var(--accent);
  opacity: 0.08;
  line-height: 1;
}

.quote-text {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  position: relative;
  z-index: 1;
}

.quote-author {
  font-family: 'Syne', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
}

.quote-card:nth-child(2n) { background: linear-gradient(135deg, var(--surface), rgba(108,99,255,0.05)); }
.quote-card:nth-child(3n) { border-top: 3px solid var(--accent2); }
.quote-card:nth-child(4n) { border-top: 3px solid var(--orange); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 2rem; right: 2rem;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex; align-items: center; gap: 0.75rem;
  z-index: 9999;
  box-shadow: var(--glow), 0 8px 30px rgba(0,0,0,0.3);
  animation: slideUp 0.35s ease;
  min-width: 280px;
  max-width: 360px;
}

.toast i { color: var(--accent); }
.toast button { margin-left: auto; background: transparent; color: var(--text-muted); font-size: 1rem; padding: 0; }

/* ── AI Loader ── */
.ai-loader {
  position: fixed; inset: 0;
  background: rgba(13,15,26,0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.ai-loader.hidden { display: none; }

.ai-loader-inner {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
}

.spinner {
  width: 50px; height: 50px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Empty State ── */
.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
  font-size: 0.9rem;
}

/* ── Animations ── */
@keyframes fadeIn   { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp  { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn  { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes pulse    { 0%,100% { box-shadow: 0 4px 20px rgba(255,107,53,0.4); } 50% { box-shadow: 0 4px 30px rgba(255,107,53,0.7); } }

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }

/* ════ RESPONSIVE ════ */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .mobile-header { display: flex; }
  .main-content { margin-left: 0; padding: 5.5rem 1.25rem 2rem; }
  .dash-bottom { grid-template-columns: 1fr; }
  .ai-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 500px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .section-title { font-size: 1.5rem; }
  .auth-card { padding: 2rem 1.25rem; }
}
