/* ═══════════════════════════════════════════════════════════════════════════
   MAIN CSS — Design System + Global Layout
   ═════════════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Tokens ────────────────────────────────────────────────────────────── */
:root {
  --bg:            #0f0f1a;
  --bg-secondary:  #16192a;
  --bg-card:       #1e2235;
  --bg-hover:      #252840;
  --sidebar-bg:    #13152b;
  --sidebar-w:     260px;
  --border:        rgba(255,255,255,0.07);
  --text:          #e4e6f0;
  --text-muted:    #7b80a0;
  --text-dim:      #50566e;
  --accent:        #7c5cbf;
  --accent-glow:   rgba(124,92,191,0.35);
  --accent-hover:  #9070d6;
  --success:       #3ecf8e;
  --danger:        #e05c5c;
  --warning:       #e8a246;
  --info:          #5cb8e0;
  --radius:        10px;
  --radius-lg:     16px;
  --shadow:        0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:     0 8px 40px rgba(0,0,0,0.6);
  --transition:    all 0.18s ease;

  /* Status colors */
  --status-open:        #5cb8e0;
  --status-in-progress: #7c5cbf;
  --status-review:      #e8a246;
  --status-hold:        #e05c5c;
  --status-closed:      #3ecf8e;

  /* Priority colors */
  --priority-baja:    #3ecf8e;
  --priority-normal:  #5cb8e0;
  --priority-alta:    #e8a246;
  --priority-urgente: #e05c5c;
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

/* ── Layout ────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 10;
}

#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

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

/* ── Reusable Utilities ────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  user-select: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 2px 18px var(--accent-glow); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { filter: brightness(1.15); }
.btn-icon {
  padding: 6px;
  line-height: 1;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-size: 15px;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Badge ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

/* ── Status Badge ──────────────────────────────────────────────────────── */
.status-badge {
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
/* ── Due date badges ────────────────────────────────────────────────────── */
.due-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.due-overdue { background: rgba(224,92,92,0.18);  color: #e05c5c; }
.due-today   { background: rgba(232,162,70,0.18); color: #e8a246; }
.due-soon    { background: rgba(232,162,70,0.10); color: #b87830; }
.due-future  { background: rgba(255,255,255,0.06); color: var(--text-dim); }

.status-Open         { background: rgba(92,184,224,0.18); color: var(--status-open); }
.status-In.Progress  { background: rgba(124,92,191,0.18); color: var(--status-in-progress); }
.status-In-Progress  { background: rgba(124,92,191,0.18); color: var(--status-in-progress); }
.status-Review       { background: rgba(232,162,70,0.18); color: var(--status-review); }
.status-Hold         { background: rgba(224,92,92,0.18);  color: var(--status-hold); }
.status-Closed       { background: rgba(62,207,142,0.18); color: var(--status-closed); }

/* ── Priority Badge ────────────────────────────────────────────────────── */
.priority-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}
.priority-Baja    .priority-dot, .priority-dot.Baja    { background: var(--priority-baja); }
.priority-Normal  .priority-dot, .priority-dot.Normal  { background: var(--priority-normal); }
.priority-Alta    .priority-dot, .priority-dot.Alta    { background: var(--priority-alta); }
.priority-Urgente .priority-dot, .priority-dot.Urgente { background: var(--priority-urgente); }

/* ── Avatar ────────────────────────────────────────────────────────────── */
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.avatar-sm { width: 22px; height: 22px; font-size: 9px; }
.avatar-lg { width: 36px; height: 36px; font-size: 13px; }

/* ── Form Controls ─────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.form-control {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  padding: 8px 12px;
  transition: var(--transition);
  outline: none;
  width: 100%;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text-dim); }
select.form-control { cursor: pointer; }
select.form-control option { background: var(--bg-card); color: var(--text); }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Topbar ────────────────────────────────────────────────────────────── */
#topbar {
  height: 54px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
}
#topbar .topbar-left  { display: flex; align-items: center; gap: 12px; }
#topbar .topbar-center { display: flex; align-items: center; justify-content: center; flex: 1; padding: 0 16px; }
#topbar .topbar-right { display: flex; align-items: center; gap: 10px; }
#topbar .project-title { font-size: 16px; font-weight: 600; color: var(--text); }

/* ── Global timer widget ───────────────────────────────────────────────── */
.global-timer-widget {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(62,207,142,0.1);
  border: 1px solid rgba(62,207,142,0.3);
  border-radius: 20px;
  padding: 5px 12px 5px 10px;
  animation: timer-pulse 2s ease-in-out infinite;
  cursor: pointer;
}
.global-timer-widget:hover {
  background: rgba(62,207,142,0.16);
}
@keyframes timer-pulse {
  0%, 100% { border-color: rgba(62,207,142,0.3); }
  50%       { border-color: rgba(62,207,142,0.7); }
}
.global-timer-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  animation: dot-blink 1s ease-in-out infinite;
}
@keyframes dot-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}
.global-timer-task {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.global-timer-display {
  font-size: 13px;
  font-weight: 700;
  color: var(--success);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
  min-width: 58px;
}
.global-timer-stop {
  background: rgba(224,92,92,0.15);
  border: 1px solid rgba(224,92,92,0.3);
  border-radius: 12px;
  color: var(--danger);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
}
.global-timer-stop:hover {
  background: rgba(224,92,92,0.3);
  border-color: var(--danger);
}

/* ── View Toggle ───────────────────────────────────────────────────────── */
.view-toggle {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
}
.view-toggle button {
  padding: 5px 12px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}
.view-toggle button.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.view-toggle button:not(.active):hover { background: var(--bg-hover); color: var(--text); }

/* ── Storage warning banner ────────────────────────────────────────────── */
.storage-warning-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  background: rgba(232,162,70,0.12);
  border-bottom: 1px solid rgba(232,162,70,0.3);
  flex-shrink: 0;
}
.storage-warning-icon { font-size: 14px; flex-shrink: 0; }
.storage-warning-text {
  flex: 1;
  font-size: 12.5px;
  color: var(--warning);
  line-height: 1.4;
}
.storage-warning-text strong { color: #f0b855; }
.storage-warning-close {
  background: transparent;
  border: none;
  color: var(--warning);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: var(--transition);
}
.storage-warning-close:hover { opacity: 1; background: rgba(232,162,70,0.15); }

/* ── Page Area ─────────────────────────────────────────────────────────── */
#page {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Empty State ───────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}
.empty-state .empty-icon { font-size: 56px; opacity: 0.4; }
.empty-state h3 { font-size: 18px; color: var(--text); }
.empty-state p { font-size: 14px; max-width: 360px; }

/* ── User switcher ─────────────────────────────────────────────────────── */
.user-switcher {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.user-switcher-dropdown {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.8);
  min-width: 220px;
  z-index: 9999;
  overflow: hidden;
  display: none;
}
.user-switcher-dropdown.open { display: block; }
.user-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 13px;
}
.user-option:hover { background: var(--bg-hover); }
.user-option.active { background: rgba(124,92,191,0.15); color: var(--accent); }

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE  (≤ 768px)
   ═════════════════════════════════════════════════════════════════════════ */

/* Hamburger button — hidden on desktop */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 8px;
  flex-shrink: 0;
  transition: var(--transition);
}
.hamburger-btn:hover { background: var(--bg-hover); color: var(--text); }

/* Sidebar overlay backdrop */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 199;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

@media (max-width: 768px) {
  body { overflow: hidden; }

  /* ── Layout ── */
  #sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.4,0,0.2,1);
    box-shadow: none;
  }
  #sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,0.6);
  }
  #main-content { width: 100%; min-width: 0; }

  /* ── Topbar ── */
  .hamburger-btn { display: flex; }
  #topbar { padding: 0 10px; gap: 6px; height: 50px; }
  #topbar .topbar-left { gap: 6px; }
  #topbar .project-title { font-size: 14px; }
  #topbar .topbar-center { padding: 0 6px; }
  .search-trigger-text { display: none; }
  .search-trigger-kbd  { display: none; }
  .search-trigger { padding: 7px 10px; gap: 6px; min-width: 36px; justify-content: center; }
  .view-toggle button { padding: 5px 8px; font-size: 11px; gap: 3px; }
  .global-timer-task { display: none; }
  .global-timer-display { font-size: 12px; min-width: 48px; }
  .global-timer-stop { display: none; }

  /* ── Storage banner ── */
  .storage-warning-text { font-size: 11.5px; }

  /* ── Page ── */
  #page { overflow-y: auto; }
}
