/* ============================================================
   CSS Custom Properties — single source of truth for all colors
   ============================================================ */
:root {
  --bg-primary: #121212;
  --bg-surface: #1a1a1a;
  --bg-elevated: #252525;
  --bg-border: #2e2e2e;

  --accent: #4db6ac;
  --accent-hover: #3d9d94;
  --accent-rgb: 77, 182, 172;
  --accent-subtle: rgba(77, 182, 172, 0.14);

  --text-heading: #4db6ac;
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-muted: #707070;

  --danger: #e74c3c;
  --danger-subtle: rgba(231, 76, 60, 0.12);
  --success: #2ecc71;
  --success-subtle: rgba(46, 204, 113, 0.12);

  --navbar-height: 56px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --transition: 150ms ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

/* ── Custom scrollbar (global) ── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-border) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--bg-border);
  border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

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

a:hover {
  color: var(--accent-hover);
}

button, input, textarea, select {
  font-family: var(--font);
  font-size: 1rem;
}

/* ============================================================
   Navbar
   ============================================================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--navbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--bg-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
}

.navbar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
  text-decoration: none;
  flex-shrink: 0;
}

.navbar-brand:hover {
  color: var(--accent-hover);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle-btn {
  min-width: 4.25rem;
  justify-content: center;
}

.nav-user {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-right: 4px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-md);
  line-height: 1;
}

.hamburger:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

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

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

.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-subtle);
}

.btn-full {
  width: 100%;
  justify-content: center;
}

/* ============================================================
   Forms
   ============================================================ */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  transition: border-color var(--transition);
}

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

.form-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ============================================================
   Flash messages
   ============================================================ */
.flash {
  padding: 12px 24px;
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 3px solid;
  animation: fadeIn 200ms ease;
}

.flash-error {
  background: var(--danger-subtle);
  border-color: var(--danger);
  color: #ff8a7a;
}

.flash-success {
  background: var(--success-subtle);
  border-color: var(--success);
  color: #5ddf96;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Light theme (default :root dark tokens unchanged) */
html[data-theme="light"] {
  --bg-primary: #f0f2f4;
  --bg-surface: #ffffff;
  --bg-elevated: #e8eaed;
  --bg-border: #dadce0;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-rgb: 13, 148, 136;
  --accent-subtle: rgba(13, 148, 136, 0.12);
  --text-heading: #0f766e;
  --text-primary: #1a1c1e;
  --text-secondary: #5f6368;
  --text-muted: #80868b;
  --danger: #c0392b;
  --danger-subtle: rgba(192, 57, 43, 0.1);
  --success: #1e8449;
  --success-subtle: rgba(30, 132, 73, 0.12);
}

/* ============================================================
   Inline form utility (used for logout button in navbar)
   ============================================================ */
.inline-form {
  display: inline;
}

/* ============================================================
   Icon button
   ============================================================ */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
  line-height: 1;
  flex-shrink: 0;
}

.btn-icon:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.btn-icon.danger:hover {
  background: var(--danger-subtle);
  color: var(--danger);
}

/* ============================================================
   Mobile
   ============================================================ */
@media (max-width: 768px) {
  .navbar {
    padding: 0 16px;
  }

  .navbar-actions {
    gap: 8px;
  }

  .navbar-links {
    display: none;
    position: absolute;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--bg-border);
    padding: 12px 16px;
    z-index: 99;
  }

  .navbar-links.open {
    display: flex;
  }

  .navbar-links .btn {
    width: 100%;
    justify-content: flex-start;
  }

  .nav-user {
    max-width: 100%;
    padding: 6px 0;
  }

  .hamburger {
    display: flex;
  }
}
