/* ===========================
   STUDYFLOW — style.css
   =========================== */

:root {
  --bg: #f4f2ef;
  --surface: #ffffff;
  --surface2: #f9f8f6;
  --border: #e8e4df;
  --text: #1a1714;
  --text-muted: #7a736b;
  --accent: #3d6af0;
  --accent-soft: #e8eeff;
  --teal: #0f9b8e;
  --teal-soft: #e0f5f3;
  --amber: #e07b2a;
  --amber-soft: #fef3e8;
  --red: #d94040;
  --red-soft: #fde8e8;
  --green: #2a9a5c;
  --green-soft: #e4f7ee;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
  --radius: 16px;
  --radius-sm: 10px;
  --font-display: 'DM Serif Display', serif;
  --font-body: 'DM Sans', sans-serif;
  --transition: 0.2s ease;
}

body.dark {
  --bg: #111210;
  --surface: #1c1c1a;
  --surface2: #242422;
  --border: #2e2e2b;
  --text: #f0ede8;
  --text-muted: #7a766f;
  --accent-soft: #1e2a55;
  --teal-soft: #0d2e2c;
  --amber-soft: #2e1e0a;
  --red-soft: #2e1010;
  --green-soft: #0e2a1c;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

/* HEADER */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon { font-size: 22px; color: var(--accent); }

.logo-text {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* THEME TOGGLE */
.theme-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  transition: all var(--transition);
}
.theme-toggle:hover { background: var(--accent-soft); border-color: var(--accent); }

/* POMODORO */
.pomodoro-widget { position: relative; }

.pomo-toggle-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.pomo-toggle-btn:hover { background: var(--red-soft); border-color: var(--red); }
.pomo-toggle-btn.active { background: var(--red-soft); border-color: var(--red); }

.pomo-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  width: 200px;
  z-index: 200;
  animation: fadeDown 0.15s ease;
}
.pomo-panel.open { display: block; }

.pomo-display {
  font-family: var(--font-display);
  font-size: 42px;
  color: var(--text);
  letter-spacing: 2px;
  line-height: 1;
  margin-bottom: 14px;
}

.pomo-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 10px;
}

.pomo-controls button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 16px;
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--transition);
}
.pomo-controls button:hover { opacity: 0.85; }
.pomo-controls button:last-child {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.pomo-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* MAIN LAYOUT */
.app-main {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* CARD */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  transition: background var(--transition), border-color var(--transition);
}

.section-title {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--text);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* PROGRESS */
.stats-row {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.stat-box {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.stat-num {
  display: block;
  font-family: var(--font-display);
  font-size: 30px;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.progress-bar-wrap {
  height: 10px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  border-radius: 99px;
  transition: width 0.5s cubic-bezier(0.4,0,0.2,1);
}

/* FORM */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.form-group input,
.form-group select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input::placeholder { color: var(--text-muted); }

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* BUTTONS */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 12px 22px;
}
.btn-primary:hover {
  background: #2c58d0;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(61,106,240,0.3);
}

.plan-btn-wrap { display: flex; justify-content: center; }

.btn-plan {
  background: linear-gradient(135deg, var(--teal), var(--accent));
  color: #fff;
  padding: 14px 32px;
  font-size: 15px;
  border-radius: 99px;
  box-shadow: 0 4px 20px rgba(15,155,142,0.25);
}
.btn-plan:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(15,155,142,0.35);
}

/* TODAY'S PLAN */
.plan-badge {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  background: var(--teal-soft);
  color: var(--teal);
  padding: 3px 10px;
  border-radius: 99px;
}

.plan-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.plan-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  animation: fadeUp 0.3s ease forwards;
  opacity: 0;
}

.plan-card-subject {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.plan-card-task {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 12px;
}

/* TASKS */
.tasks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.tasks-header .section-title { margin-bottom: 0; }

.filter-row { display: flex; gap: 6px; }

.filter-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 6px 14px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  transition: all var(--transition);
  animation: fadeUp 0.25s ease forwards;
  opacity: 0;
}
.task-item:hover { border-color: var(--accent); box-shadow: 0 2px 12px rgba(61,106,240,0.08); }
.task-item.completed { opacity: 0.55; }
.task-item.completed .task-name { text-decoration: line-through; color: var(--text-muted); }

.task-check {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  transition: all var(--transition);
  font-size: 11px;
  color: transparent;
  background: var(--surface);
}
.task-item.completed .task-check {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.task-check:hover { border-color: var(--green); }

.task-body { flex: 1; min-width: 0; }

.task-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.task-subject {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.task-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* BADGES */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
}
.badge-high { background: var(--red-soft); color: var(--red); }
.badge-medium { background: var(--amber-soft); color: var(--amber); }
.badge-low { background: var(--green-soft); color: var(--green); }
.badge-easy { background: var(--green-soft); color: var(--green); }
.badge-medium-diff { background: var(--amber-soft); color: var(--amber); }
.badge-hard { background: var(--red-soft); color: var(--red); }

.task-date { font-size: 11px; color: var(--text-muted); }

.task-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: all var(--transition);
  line-height: 1;
}
.task-delete:hover { background: var(--red-soft); color: var(--red); }

/* EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* TOAST */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 22px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* UTILITY */
.hidden { display: none !important; }

/* ANIMATIONS */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* RESPONSIVE */
@media (max-width: 600px) {
  .app-main { padding: 20px 14px 48px; }
  .card { padding: 20px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-row { gap: 10px; }
  .stat-box { padding: 12px 8px; }
  .stat-num { font-size: 24px; }
  .plan-cards { grid-template-columns: 1fr; }
  .tasks-header { flex-direction: column; align-items: flex-start; }
}