/* ============================
   RESET & BASE
   ============================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f6fa;
  --sidebar-bg: #1e2030;
  --sidebar-hover: #2a2d45;
  --sidebar-active: #3b4fd4;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --white: #ffffff;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --prio-red: #ef4444;
  --prio-orange: #f59e0b;
  --prio-blue: #3b82f6;
  --prio-gray: #94a3b8;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; background: var(--bg); color: var(--text); }

/* ============================
   LAYOUT
   ============================ */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================
   SIDEBAR
   ============================ */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--sidebar-bg);
  color: #c9d1d9;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-logo {
  padding: 20px 18px 12px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--sidebar-active);
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-name { font-size: 13px; color: #e2e8f0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout {
  background: none; border: none; color: #64748b; cursor: pointer; font-size: 16px; padding: 2px;
  transition: color 0.2s;
}
.btn-logout:hover { color: var(--danger); }

.sidebar-section { padding: 12px 0 0; }
.sidebar-label {
  font-size: 11px; font-weight: 600; color: #4a5568;
  padding: 0 18px 6px; text-transform: uppercase; letter-spacing: 0.8px;
}
.sidebar-nav { display: flex; flex-direction: column; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 13.5px;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-icon { font-size: 15px; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: rgba(255,255,255,0.12);
  color: #c9d1d9;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,0.25); color: #fff; }

/* ============================
   POMODORO SIDEBAR PANEL
   ============================ */
.sidebar-pomo {
  margin: 16px 12px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.08);
}
.pomo-label { font-size: 11px; color: #4a5568; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 6px; }
.pomo-task-name { font-size: 12px; color: #94a3b8; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pomo-timer-display {
  font-size: 36px; font-weight: 700; color: #fff;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  text-align: center; margin-bottom: 4px;
}
.pomo-mode-badge {
  text-align: center; font-size: 11px;
  color: var(--success); font-weight: 600;
  margin-bottom: 10px;
}
.pomo-sidebar-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-bottom: 10px; }
.pomo-btn {
  border: none; border-radius: 5px; padding: 5px 10px; font-size: 11px;
  cursor: pointer; font-weight: 600; transition: opacity 0.15s;
}
.pomo-btn:hover { opacity: 0.85; }
.pomo-btn-green { background: var(--success); color: #fff; }
.pomo-btn-yellow { background: var(--warning); color: #fff; }
.pomo-btn-red { background: var(--danger); color: #fff; }
.pomo-btn-gray { background: #475569; color: #fff; }
.pomo-stat-row { font-size: 12px; color: #64748b; text-align: center; }

/* ============================
   MAIN CONTENT
   ============================ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px 12px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}
.toolbar-left { display: flex; align-items: baseline; gap: 10px; }
.view-title { font-size: 20px; font-weight: 700; color: var(--text); }
.view-date { font-size: 13px; color: var(--text-muted); }
.toolbar-right { display: flex; align-items: center; gap: 10px; }
.search-input {
  padding: 6px 12px; border: 1px solid var(--border);
  border-radius: 20px; font-size: 13px; outline: none;
  background: var(--bg); color: var(--text); width: 200px;
  transition: border-color 0.2s, width 0.2s;
}
.search-input:focus { border-color: var(--primary); width: 260px; }

/* ============================
   VIEW PANELS
   ============================ */
.view-panel { display: none; flex: 1; overflow: hidden; }
.view-panel.active { display: flex; flex-direction: column; }

/* ============================
   TASK LIST
   ============================ */
.task-list-wrap { flex: 1; overflow-y: auto; padding: 16px 28px; }
.task-list { display: flex; flex-direction: column; gap: 6px; }
.section-header {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.8px;
  padding: 14px 0 6px; border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.task-item {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 10px 14px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
  position: relative;
}
.task-item:hover { box-shadow: var(--shadow); border-color: #cbd5e1; }
.task-item.task-done { opacity: 0.55; }

.task-prio-bar {
  width: 3px; border-radius: 2px; align-self: stretch;
  flex-shrink: 0; min-height: 20px;
}
.task-check {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0; cursor: pointer;
  margin-top: 2px;
  appearance: none; -webkit-appearance: none;
  transition: background 0.15s, border-color 0.15s;
}
.task-check:checked { background: var(--success); border-color: var(--success); }
.task-check:hover { border-color: var(--success); }

.task-body { flex: 1; min-width: 0; }
.task-title-text { font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-done .task-title-text { text-decoration: line-through; }
.task-note-text { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meta { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.task-date-label { font-size: 11px; color: var(--text-muted); }
.task-pomo-label { font-size: 11px; color: #e06c75; }
.btn-set-pomo {
  margin-left: auto; background: none; border: none; cursor: pointer;
  font-size: 16px; opacity: 0.4; transition: opacity 0.15s; flex-shrink: 0;
}
.btn-set-pomo:hover { opacity: 1; }
.task-item.pomo-active .btn-set-pomo { opacity: 1; }
.task-item.pomo-active { border-left: 3px solid var(--danger); }

/* ============================
   WEEK VIEW
   ============================ */
.week-columns {
  display: flex; flex: 1; overflow: hidden;
  padding: 16px 28px;
  gap: 10px;
  overflow-x: auto;
}
.week-col {
  min-width: 160px; flex: 1;
  display: flex; flex-direction: column;
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.week-col-header {
  padding: 10px 12px;
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.week-col-header.today { color: var(--primary); background: #eff6ff; }
.week-col-body { padding: 8px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.week-task-chip {
  font-size: 12px; padding: 5px 8px; border-radius: 5px;
  background: #f1f5f9; color: var(--text);
  cursor: pointer; transition: background 0.15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-left: 3px solid var(--prio-gray);
}
.week-task-chip:hover { background: #e2e8f0; }
.week-task-chip.prio-3 { border-left-color: var(--prio-red); }
.week-task-chip.prio-2 { border-left-color: var(--prio-orange); }
.week-task-chip.prio-1 { border-left-color: var(--prio-blue); }
.week-task-chip.done { text-decoration: line-through; opacity: 0.5; }

/* ============================
   CALENDAR VIEW
   ============================ */
#fullcalendar-container {
  flex: 1; overflow: hidden; padding: 16px 28px;
}
#fullcalendar-container .fc { height: 100%; }
.fc-event {
  border-radius: 3px; border: none; padding: 1px 4px;
  font-size: 11.5px; cursor: pointer;
}
.fc-event.prio-3 { background: #fee2e2; color: #991b1b; }
.fc-event.prio-2 { background: #fef3c7; color: #92400e; }
.fc-event.prio-1 { background: #dbeafe; color: #1e40af; }
.fc-event.prio-0 { background: #f1f5f9; color: #475569; }
.fc-event.done { opacity: 0.5; text-decoration: line-through; }

/* ============================
   STATS VIEW
   ============================ */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; padding: 24px 28px 16px;
}
.stat-card {
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px; text-align: center;
}
.stat-num { font-size: 36px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-muted); }
.stats-chart-wrap {
  background: var(--white); margin: 0 28px; padding: 20px;
  border-radius: var(--radius); border: 1px solid var(--border);
}
.stats-chart-wrap h3 { font-size: 14px; color: var(--text-muted); margin-bottom: 14px; }

/* ============================
   MODAL
   ============================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}
.modal-card {
  background: var(--white); border-radius: 12px;
  width: 480px; max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.modal-input, .modal-textarea, .modal-input-sm, .modal-select {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; outline: none; color: var(--text);
  font-family: inherit;
  transition: border-color 0.2s;
}
.modal-input:focus, .modal-textarea:focus, .modal-input-sm:focus, .modal-select:focus {
  border-color: var(--primary);
}
.modal-textarea { resize: vertical; }
.modal-row { display: flex; align-items: center; gap: 12px; }
.modal-row label { font-size: 13px; color: var(--text-muted); white-space: nowrap; width: 52px; }
.modal-input-sm { flex: 1; }
.modal-select { flex: 1; }
.modal-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 20px; border-top: 1px solid var(--border);
}

/* ============================
   BUTTONS
   ============================ */
.btn-primary {
  background: var(--primary); color: #fff;
  border: none; border-radius: 6px;
  padding: 8px 18px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-ghost {
  background: none; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 16px; font-size: 13px; cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover { border-color: #94a3b8; color: var(--text); }
.btn-danger {
  background: none; color: var(--danger);
  border: 1px solid var(--danger); border-radius: 6px;
  padding: 7px 14px; font-size: 13px; cursor: pointer;
}
.btn-danger:hover { background: #fee2e2; }

/* ============================
   LOGIN SCREEN
   ============================ */
.login-screen {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #1e2030 0%, #2d3561 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.login-card {
  background: var(--white); border-radius: 16px;
  padding: 40px 36px; width: 360px; max-width: 95vw;
  box-shadow: 0 30px 80px rgba(0,0,0,0.3);
  text-align: center;
}
.login-logo { font-size: 48px; margin-bottom: 10px; }
.login-title { font-size: 26px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }
.login-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-form input {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none; color: var(--text);
  transition: border-color 0.2s;
}
.login-form input:focus { border-color: var(--primary); }
.login-form .btn-primary { padding: 11px; font-size: 14px; border-radius: 8px; }
.login-error { font-size: 13px; color: var(--danger); background: #fee2e2; padding: 8px 12px; border-radius: 6px; }
.login-back { font-size: 12px; color: var(--text-muted); text-align: center; text-decoration: none; }
.login-back:hover { color: var(--primary); }

/* ============================
   TOAST
   ============================ */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1e293b; color: #fff;
  padding: 10px 18px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  z-index: 9999; animation: fadeInUp 0.2s ease;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================
   EMPTY STATE
   ============================ */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ============================
   SCROLLBARS
   ============================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 768px) {
  .sidebar { width: 200px; min-width: 200px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { padding: 12px 16px; }
  .task-list-wrap { padding: 12px 16px; }
}
@media (max-width: 560px) {
  .sidebar { display: none; }
  .pomo-timer-display { font-size: 28px; }
}
