/* --- VOLTA BRIEF DESIGN SYSTEM --- */
:root {
  /* Light Theme Defaults */
  --bg-color: #f8fafc;
  --sidebar-bg: #ffffff;
  --card-bg: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --accent-blue: #2563eb;
  --accent-light: #eff6ff;
  --accent-green: #10b981;
  --accent-purple: #8b5cf6;
  --danger-color: #ef4444;
  --font-main: 'Outfit', sans-serif;
  --font-mono: 'Roboto', monospace;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --hover-bg: #f1f5f9;
}

[data-theme="dark"] {
  /* Dark Theme Overrides */
  --bg-color: #000000;
  --sidebar-bg: #18181b;
  --card-bg: #18181b;
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --border-color: #27272a;
  --accent-blue: #60a5fa;
  --accent-light: rgba(96, 165, 250, 0.15);
  --accent-green: #34d399;
  --accent-purple: #c084fc;
  --danger-color: #f87171;
  --shadow-sm: none;
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --hover-bg: #27272a;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
    /* This prevents the "rubber-band" effect on iPad that breaks sticky headers */
    width: 100%;
    margin: 0;
    padding: 0;
}

/* --- BASE STYLES --- */
* {
  box-sizing: border-box;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: var(--font-main);
  background: var(--bg-color);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--text-secondary); border-radius: 4px; opacity: 0.5; }

/* --- SIDEBAR & NAVIGATION --- */
#sidebar {
  width: 300px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform 0.3s ease, width 0.3s ease;
  flex-shrink: 0;
}

.sidebar-header { padding: 24px; border-bottom: 1px solid var(--border-color); }
.sidebar-title { font-size: 16px; font-weight: 700; text-transform: uppercase; color: var(--text-secondary); letter-spacing: 1px; margin-bottom: 10px; }

.history-list { flex: 1; overflow-y: auto; padding: 20px; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }

.history-item {
  padding: 12px;
  border-radius: 8px;
  background: var(--bg-color);
  margin-bottom: 10px;
  border-left: 3px solid var(--text-secondary);
  font-size: 15px;
}

.history-item.deep { border-color: var(--accent-purple); }
.history-item.shallow { border-color: var(--accent-green); }
.history-time { font-size: 13px; color: var(--text-secondary); display: block; margin-top: 4px; }

/* --- GAMIFICATION WIDGETS --- */
.xp-badge {
  background: linear-gradient(135deg, #FFD700 0%, #FDB931 100%);
  color: #78350f;
  padding: 6px 14px;
  border-radius: 50px;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-right: 16px;
  cursor: help;
  white-space: nowrap;
}

.level-card {
  margin: 10px;
  padding: 16px;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  height: 92px;
}

.level-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.xp-progress-container {
  width: 100%;
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.xp-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
  width: 0%;
  transition: width 0.5s ease-out;
}

.level-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
  text-align: right;
}

/* --- MAIN CONTENT & HEADER --- */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0; /* CRITICAL: Prevents flex children from pushing width */
    overflow-x: hidden;
}
header {
  height: 64px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-left, .header-right { display: flex; align-items: center; gap: 16px; }

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-primary);
  padding: 8px;
  border-radius: 50%;
}

.logo-text { font-size: 20px; font-weight: 700; color: var(--text-primary); text-decoration: none; }
.logo-accent { color: var(--accent-blue); }
.logo-area span { font-size: 20px !important; font-weight: 700; color: var(--accent-blue); }

.theme-toggle {
  background: transparent;
  border: none;
  color: var(--text-primary);
  /* width: 40px;
  height: 40px; */
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 8px;
}

.theme-toggle:hover { background: var(--hover-bg); }

.mobile-xp-panel {
  display: none;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 8px 16px;
  justify-content: center;
}

/* --- CONTENT AREA --- */
#content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 30px;
  padding-bottom: env(safe-area-inset-bottom);
}

.container {
    width: 100%;
    max-width: 1000px; /* Ensures it never goes wider than the screen */
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box; /* Includes padding in the width calculation */
}

/* --- HERO FOCUS CARD --- */
.focus-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  margin-bottom: 30px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.focus-card.active-mode {
  border-color: var(--accent-blue);
  box-shadow: 0 0 20px rgba(37, 99, 235, 0.15);
}

.timer-display {
  font-family: var(--font-mono);
  font-size: 80px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin: 20px 0;
  font-variant-numeric: tabular-nums;
}

.focus-task-title { font-size: 24px; font-weight: 500; color: var(--text-secondary); margin-bottom: 8px; word-wrap: break-word; }

.focus-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.badge-deep { background: #f3e8ff; color: #6b21a8; }
[data-theme="dark"] .badge-deep { background: #3b0764; color: #d8b4fe; }
.badge-shallow { background: #d1fae5; color: #065f46; }
[data-theme="dark"] .badge-shallow { background: #064e3b; color: #6ee7b7; }

/* --- CONTROLS & BUTTONS --- */
.controls { display: flex; justify-content: center; gap: 16px; margin-top: 24px; }

.btn-control {
  padding: 12px 32px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  border: none;
  transition: transform 0.1s;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.btn-control:active { transform: scale(0.95); }
.btn-primary { background: var(--accent-blue); color: white; }
.btn-danger { background: var(--bg-color); border: 1px solid var(--danger-color); color: var(--danger-color); }
.btn-finish { background: var(--accent-green); color: white; display: none; }

/* --- TASK INPUT --- */
.input-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 30px;
}

.input-row { display: flex; gap: 16px; margin-bottom: 16px; }

.task-input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 16px;
}

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

.type-selector { display: flex; gap: 10px; }

.type-btn {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-color);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.type-btn.selected { border-color: var(--accent-blue); background: var(--accent-light); color: var(--accent-blue); }
.type-subtext { font-size: 13px; opacity: 0.8; }

.btn-add {
  width: 100%;
  padding: 14px;
  background: var(--text-primary);
  color: var(--bg-color);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
}

.btn-add:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- TASK QUEUE --- */
.queue-header { font-size: 20px; font-weight: 600; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; }
.queue-list { display: flex; flex-direction: column; gap: 12px; }

.task-item {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 18px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.task-item:hover { border-color: var(--text-secondary); }

.task-info { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; padding-right: 8px; }
.task-info div:first-child { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.task-meta { font-size: 14px; display: flex; gap: 8px; align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-deep { background: var(--accent-purple); }
.dot-shallow { background: var(--accent-green); }

.task-actions { display: flex; align-items: center; flex-shrink: 0; }

.btn-start-mini {
  padding: 10px 16px;
  background: transparent;
  border: 1px solid var(--accent-blue);
  color: var(--accent-blue);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.btn-start-mini:hover { background: var(--accent-light); }
.btn-delete-mini { margin-left: 8px; color: var(--text-secondary); background: none; border: none; cursor: pointer; padding: 10px; }
.btn-delete-mini svg { width: 20px; height: 20px; }

/* --- INTERFACE MODES --- */
body.focus-locked .input-card,
body.focus-locked .queue-list,
body.focus-locked .btn-delete-mini {
  opacity: 0.5;
  pointer-events: none;
  filter: grayscale(1);
}

/* --- RESPONSIVE MOBILE STYLES --- */
@media (max-width: 768px) {
  #sidebar { position: fixed; height: 100%; left: -300px; box-shadow: 20px 0 30px rgba(0, 0, 0, 0.2); }
  body.sidebar-open #sidebar { transform: translateX(300px); }
  .mobile-toggle { display: block; }
  header { padding: 0 16px; }
  
  .header-right .xp-badge { display: none !important; margin-top: 10px;}
  .mobile-xp-panel { display: flex; }
  .mobile-xp-panel .xp-badge { margin-top: 10px; margin-bottom: 10px; width: 100%; justify-content: center; }

  #content-scroll { padding: 20px 16px 80px 16px; }
  .focus-card { padding: 24px 16px; }
  
  .timer-display { font-size: 18vw; margin: 16px 0; }
  .focus-task-title { font-size: 20px; }

  .controls { flex-direction: column; gap: 10px; width: 100%; }
  .btn-control { width: 100%; padding: 16px; font-size: 18px; }
  .input-row { flex-direction: column; }
  .queue-header { font-size: 18px; }
  .task-item { padding: 16px; }
  .type-selector { 
      flex-direction: column; 
  }
  /* Make the Custom input spacing look cleaner on mobile */
  #custom-time-container {
      margin-top: 4px;
  }
}

/* --- OVERLAY --- */
#mobile-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 40; display: none; }
body.sidebar-open #mobile-overlay { display: block; }

/* --- CUSTOM MODAL --- */
.modal-overlay {
    position: fixed; 
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none; /* Hidden by default */
    align-items: center; 
    justify-content: center;
    z-index: 100;
}

.modal-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.modal-buttons {
    display: flex; 
    gap: 12px; 
    justify-content: center; 
    margin-top: 24px;
}

.modal-buttons .btn-control {
    padding: 10px 24px; 
    font-size: 15px;
    width: 100%; /* Makes buttons even */
}

/* ------- */

/* Add to your Focus Badge styles */
.badge-custom { background: #e0f2fe; color: #0369a1; }
[data-theme="dark"] .badge-custom { background: #0c4a6e; color: #7dd3fc; }

/* Add to your Dot styles */
.dot-custom { background: var(--accent-blue); }

/* Add to your History Item styles */
.history-item.custom { border-color: var(--accent-blue); }

/* --- EXCEL-STYLE TAB BAR --- */
.tab-bar-wrapper {
  position: sticky;
  top: 64px; /* Matches your 64px header */
  z-index: 19; /* Just below header's z-index 20 */
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border-color);
}
.tab-bar-wrapper::before, .tab-bar-wrapper::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 40px;
  pointer-events: none; z-index: 10; opacity: 0; transition: opacity 0.3s ease;
}
.tab-bar-wrapper::before { left: 0; background: linear-gradient(to right, var(--sidebar-bg) 0%, transparent 100%); }
.tab-bar-wrapper::after { right: 0; background: linear-gradient(to left, var(--sidebar-bg) 0%, transparent 100%); }
.tab-bar-wrapper.can-scroll-left::before { opacity: 1; }
.tab-bar-wrapper.can-scroll-right::after { opacity: 1; }

.excel-tab-bar { display: flex; overflow-x: auto; scrollbar-width: none; 
    white-space: nowrap;
    -webkit-overflow-scrolling: touch; /* Enables smooth finger scrolling on iPad */
    flex-wrap: nowrap; /* Ensures tabs stay in one line */
    width: 100%;
}
.excel-tab-bar::-webkit-scrollbar { display: none; }
.tab-link {
  padding: 14px 20px; white-space: nowrap; color: var(--text-secondary);
  font-size: 14px; font-weight: 600; border-bottom: 3px solid transparent;
  cursor: pointer; transition: all 0.2s ease; display: flex;
  align-items: center; gap: 6px; background: transparent; border-top: none;
  border-left: none; border-right: none; font-family: var(--font-main); text-decoration: none;
}
.tab-link:hover { background: var(--hover-bg); color: var(--text-primary); }
.tab-link.active { color: var(--accent-blue); border-bottom-color: var(--accent-blue); background: rgba(37, 99, 235, 0.05); }

/* --- QUICK READS DROPDOWN --- */
.tab-dropdown { position: relative; display: inline-block; }
.tab-dropdown-menu {
  display: none; position: fixed; transform: translateX(-50%);
  background: var(--card-bg); min-width: 250px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  border: 1px solid var(--border-color); border-radius: 12px; z-index: 1000;
  flex-direction: column; overflow: hidden;
}
.tab-dropdown-menu.show { display: flex; animation: fadeIn 0.2s ease-in-out; }
.tab-dropdown-menu a { padding: 12px 16px; color: var(--text-secondary); font-size: 13px; font-weight: 500; border-bottom: 1px solid var(--border-color); transition: 0.2s; text-decoration: none; }
.tab-dropdown-menu a:hover { background: var(--accent-light); color: var(--accent-blue); }
.tab-dropdown-menu a:last-child { border-bottom: none; }
.dropdown-toggle.open svg { transform: rotate(180deg); }
.dropdown-toggle svg { transition: transform 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- FLOATING ACTION BUTTON (FAB) --- */
.fab-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 90;
}

.fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--accent-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}

.fab:hover {
    transform: scale(1.05);
    background-color: #1d4ed8;
}

[data-theme="dark"] .fab {
    box-shadow: 0 4px 15px rgba(96, 165, 250, 0.4);
}

/* Adjust for mobile safe areas */
@media (max-width: 768px) {
    .fab-container {
        bottom: calc(24px + env(safe-area-inset-bottom));
        right: 24px;
    }
}
