/* MTO — Main Stylesheet
   Import order: themes first, then this file.
   All colours reference CSS custom properties defined in themes/.
   ------------------------------------------------------------------ */

/* ── Reset / base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 600; margin: 0 0 0.5rem; }
p { margin: 0 0 0.75rem; }

/* ── Layout ───────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 18px 14px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-sidebar);
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  text-decoration: none;
  display: block;
}
.sidebar-logo:hover { text-decoration: none; color: #fff; }

.sidebar-section {
  padding: 10px 0 4px;
}

.sidebar-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-sidebar-muted);
  padding: 0 18px 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 18px;
  color: var(--text-sidebar);
  font-size: 0.875rem;
  transition: background 0.1s;
  text-decoration: none;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--bg-sidebar-hover);
  color: #fff;
  text-decoration: none;
}

.sidebar-icon { font-size: 1rem; opacity: 0.8; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 12px 0;
}

/* ── Main content ─────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-body {
  padding: 24px;
  flex: 1;
}

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.card-header {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-header h2 {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card-body { padding: 0; }

/* ── Task rows ────────────────────────────────────────────────────── */
.task-list { list-style: none; margin: 0; padding: 0; }

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.task-row:last-child { border-bottom: none; }
.task-row:hover { background: var(--bg-hover); }

.task-check {
  flex-shrink: 0;
  margin-top: 2px;
}
.task-check form { margin: 0; }
.task-check button {
  background: none;
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s, background 0.15s;
}
.task-check button:hover {
  border-color: var(--success);
  background: var(--success-light);
}

.task-info { flex: 1; min-width: 0; }

.task-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  display: block;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.task-title:hover { text-decoration: underline; }

.task-meta {
  display: flex;
  gap: 8px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.task-due {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.task-due.overdue { color: var(--danger); font-weight: 600; }
.task-due.today   { color: var(--warning); font-weight: 600; }

.task-project {
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--bg-badge);
  color: var(--text-secondary);
}

/* ── Priority dot ─────────────────────────────────────────────────── */
.priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}
.priority-dot.p5 { background: var(--priority-5); }
.priority-dot.p4 { background: var(--priority-4); }
.priority-dot.p3 { background: var(--priority-3); }
.priority-dot.p2 { background: var(--priority-2); }
.priority-dot.p1 { background: var(--priority-1); }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--bg-hover); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { opacity: 0.88; }

.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-icon { padding: 6px; border-radius: var(--radius); }

/* ── Forms ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-control {
  display: block;
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.form-check label { font-size: 0.875rem; cursor: pointer; margin: 0; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.invalid-feedback { color: var(--danger); font-size: 0.8rem; margin-top: 3px; }

/* ── Auth pages ───────────────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-page);
  padding: 24px;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 6px;
}
.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 24px;
}

/* ── Flash messages ───────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 12px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-light); color: var(--success); border-color: var(--success); }
.alert-danger   { background: var(--danger-light);  color: var(--danger);  border-color: var(--danger); }
.alert-info     { background: var(--info-light);    color: var(--info);    border-color: var(--info); }
.alert-warning  { background: var(--warning-light); color: var(--warning); border-color: var(--warning); }

/* ── Badge / tag chips ────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}
.badge-active   { background: var(--accent-light);   color: var(--accent); }
.badge-done     { background: var(--success-light);  color: var(--success); }
.badge-deferred { background: var(--bg-badge);       color: var(--text-muted); }
.badge-cancelled{ background: var(--bg-badge);       color: var(--text-muted); text-decoration: line-through; }

/* ── Dashboard sections ───────────────────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

.empty-state {
  padding: 20px 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ── Task detail ──────────────────────────────────────────────────── */
.task-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 20px;
}
.task-detail-title {
  font-size: 1.3rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
}
.task-detail-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-size: 0.83rem;
  color: var(--text-secondary);
}
.task-detail-meta span { display: flex; align-items: center; gap: 4px; }

.notes-list { list-style: none; padding: 0; margin: 0; }
.note-item {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
.note-item:last-child { border-bottom: none; }
.note-body { font-size: 0.9rem; white-space: pre-wrap; word-break: break-word; }
.note-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* ── Pagination ───────────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.page-link {
  padding: 5px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.85rem;
}
.page-link:hover { background: var(--bg-hover); text-decoration: none; }
.page-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Theme toggle ─────────────────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--text-sidebar-muted);
  border-radius: var(--radius);
  padding: 5px 8px;
  cursor: pointer;
  font-size: 0.85rem;
  width: calc(100% - 36px);
  margin: 0 18px;
  text-align: left;
}
.theme-toggle:hover { color: #fff; border-color: rgba(255,255,255,0.4); }

/* ── Responsive: mobile ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -220px;
    z-index: 200;
    transition: left 0.25s;
    height: 100%;
  }
  .sidebar.open { left: 0; }

  .page-body { padding: 16px; }
  .topbar { padding: 10px 16px; }

  .hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 1.2rem;
    padding: 4px;
  }
}

@media (min-width: 769px) {
  .hamburger { display: none; }
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 199;
}
.sidebar-overlay.visible { display: block; }

/* ── Misc utilities ───────────────────────────────────────────────── */
.text-muted    { color: var(--text-muted); }
.text-danger   { color: var(--danger); }
.text-success  { color: var(--success); }
.text-sm       { font-size: 0.82rem; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.flex-row { display: flex; align-items: center; gap: 8px; }
.flex-1 { flex: 1; }
.d-none { display: none; }
