/* ---------- Minimal Black & White Design ---------- */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #f1f3f5;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-muted: #adb5bd;
  --border-light: #e9ecef;
  --border-medium: #dee2e6;
  --border-dark: #ced4da;
  --accent: #000000;
  --accent-light: #495057;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
}
/*logo size*/
.logo {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border-radius: var(--radius-sm);
}

/* Dark mode variables */
[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #404040;
  --text-primary: #e5e5e5;
  --text-secondary: #a0a0a0;
  --text-muted: #707070;
  --border-light: #404040;
  --border-medium: #555555;
  --border-dark: #666666;
  --accent: #ffffff;
  --accent-light: #cccccc;
  --success: #4caf50;
  --danger: #f44336;
  --warning: #ff9800;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.3);
}

/* Ensure dark mode styles are applied properly */
[data-theme="dark"] body {
  background: var(--bg-primary);
  color: var(--text-primary);
}

[data-theme="dark"] .panel {
  background: var(--bg-secondary);
  border-color: var(--border-light);
}

[data-theme="dark"] .metric.widget {
  background: var(--bg-secondary);
  border-color: var(--border-light);
}

[data-theme="dark"] .task {
  background: var(--bg-secondary);
  border-color: var(--border-light);
}

[data-theme="dark"] .input,
[data-theme="dark"] textarea {
  background: var(--bg-tertiary);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

[data-theme="dark"] .input:focus,
[data-theme="dark"] textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.1);
}

[data-theme="dark"] .sidebar {
  background: var(--bg-secondary);
  border-color: var(--border-light);
}

[data-theme="dark"] .main {
  background: var(--bg-primary);
}

[data-theme="dark"] .header {
  background: var(--bg-primary);
  border-color: var(--border-light);
}

[data-theme="dark"] .tabs {
  background: var(--bg-tertiary);
  border-color: var(--border-medium);
}

[data-theme="dark"] .tabs button.active {
  background: var(--bg-primary);
  color: var(--text-primary);
}

[data-theme="dark"] .btn {
  background: var(--accent);
  color: var(--bg-primary);
}

[data-theme="dark"] .nav button {
  color: var(--text-secondary);
  background: transparent;
}

[data-theme="dark"] .nav button:hover {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .nav button.active {
  background: var(--accent);
  color: var(--bg-primary);
}

[data-theme="dark"] .pill {
  background: var(--bg-tertiary);
  border-color: var(--border-medium);
  color: var(--text-secondary);
}

[data-theme="dark"] .check {
  border-color: var(--border-dark);
}

[data-theme="dark"] .check:hover {
  border-color: var(--accent);
}

[data-theme="dark"] .check.done {
  background: var(--success);
  border-color: var(--success);
}

[data-theme="dark"] .drawer {
  background: var(--bg-primary);
  border-color: var(--border-light);
}

[data-theme="dark"] .drawer header,
[data-theme="dark"] .drawer footer {
  border-color: var(--border-light);
}

[data-theme="dark"] .chip {
  background: var(--bg-tertiary);
  border-color: var(--border-medium);
  color: var(--text-secondary);
}

[data-theme="dark"] .chip.due {
  background: rgba(255, 152, 0, 0.15);
  border-color: var(--warning);
  color: var(--warning);
}

[data-theme="dark"] .chip.cat {
  background: rgba(76, 175, 80, 0.15);
  border-color: var(--success);
  color: var(--success);
}

[data-theme="dark"] .icon-btn {
  background: var(--bg-tertiary);
  border-color: var(--border-medium);
  color: var(--text-secondary);
}

[data-theme="dark"] .icon-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--border-dark);
}

[data-theme="dark"] .icon-btn.danger {
  border-color: rgba(244, 67, 54, 0.3);
  background: rgba(244, 67, 54, 0.05);
  color: var(--danger);
}

[data-theme="dark"] .icon-btn.danger:hover {
  background: rgba(244, 67, 54, 0.1);
}

[data-theme="dark"] .mobile-menu-toggle span {
  background: var(--text-primary);
}

[data-theme="dark"] .sidebar-overlay {
  background: rgba(0, 0, 0, 0.7);
}

* {
  box-sizing: border-box;
}

/* Smooth transition for theme changes */
*, *::before, *::after {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden; /* Prevent page scrolling */
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}
@media (max-width: 575.98px) {
  html, body {
    overflow: auto !important;
    height: 100% !important;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== APP LAYOUT ===== */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas: 
    "sidebar header"
    "sidebar main";
  height: 100vh;
  width: 100vw;
  background: var(--bg-primary);
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  grid-area: sidebar;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-light);
  padding: 24px 16px;
  overflow: hidden;
  height: 100vh;
  transition: transform 0.3s ease;
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 900; /* Lower z-index to not interfere with main content */
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
  pointer-events: all;
}

/* Ensure main content is not affected by overlay unless sidebar is open */
@media (max-width: 991px) {
  .main {
    z-index: 950; /* Higher than overlay */
    pointer-events: all;
  }
  
  .sidebar-overlay.active + * .main {
    z-index: 1; /* Lower when overlay is active */
  }
}

.sidebar.mobile-open {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  z-index: 999 !important; /* Higher than overlay */
  width: 280px !important;
  height: 100vh !important;
  transform: translateX(0) !important;
  display: block !important;
  box-shadow: var(--shadow-lg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  margin-bottom: 32px;
}

.brand .logo {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border-radius: var(--radius-sm);
}

.brand strong {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.nav {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav button {
  all: unset;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  margin-bottom: 4px;
}

.nav button:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav button.active {
  background: var(--accent);
  color: white;
}

.nav .tag {
  margin-left: right;
  margin-right: -4px; /* Move closer to the edge */
  background: var(--border-medium);
  color: var(--text-primary);
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 500;
  min-width: 18px;
  text-align: center;
}

/* ===== HEADER ===== */
.header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  overflow: hidden;
  min-height: 80px;
  max-height: 80px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0; /* Allow flex item to shrink */
}

.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  width: 40px;
  height: 40px;
  justify-content: space-around;
  align-items: center;
  flex-shrink: 0;
}

.mobile-menu-toggle span {
  display: block;
  width: 24px;
  height: 3px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.mobile-menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

.hello {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 0; /* Allow flex item to shrink */
  flex: 1;
}

.hello small {
  display: block;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 4px;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0; /* Prevent userbox from shrinking */
}

.pill {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  color: var(--text-secondary);
}

.logout {
  all: unset;
  cursor: pointer;
  padding: 8px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.logout:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-dark);
}

/* Dark mode toggle button */
.theme-toggle {
  all: unset;
  cursor: pointer;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
}

.theme-toggle:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-dark);
  transform: scale(1.05);
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* ===== MAIN CONTENT ===== */
.main {
  grid-area: main;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 32px;
  padding: 32px;
  background: var(--bg-primary);
  overflow: hidden;
  height: calc(100vh - 80px); /* Full height minus header */
  max-height: calc(100vh - 80px);
  position: relative;
  z-index: 1; /* Ensure main content is above background elements */
}

.panel {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px - 64px); /* Full height minus header and main padding */
  max-height: calc(100vh - 80px - 64px);
  overflow: hidden;
  position: relative;
  z-index: 2; /* Ensure panel is above overlay when closed */
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-title h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.tabs {
  display: inline-flex;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  padding: 4px;
  border-radius: var(--radius);
  position: relative;
  z-index: 10; /* Ensure tabs are above other elements */
}

.tabs button {
  all: unset;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
  z-index: 11;
  /* Better touch handling */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.tabs button.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
  border: 2px solid var(--color-primary);
}

/* ===== TASK FORM ===== */
.task-form {
  display: grid;
  grid-template-columns: 2fr 1.5fr 1fr auto;
  gap: 12px;
  margin-bottom: 24px;
}

/* ===== BULK ACTIONS BAR ===== */
.bulk-controls-bar {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  z-index: 10;
  animation: slideDown 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.bulk-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.bulk-info span {
  font-weight: 500;
  margin-right: 32px;
}

.btn-exit {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all 0.2s ease;
}

.btn-exit:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.bulk-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Pastel Button Styles */
.btn-pastel {
  all: unset;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-pastel-blue {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.btn-pastel-blue:hover {
  background: #bfdbfe;
  border-color: #93c5fd;
  transform: translateY(-1px);
}

.btn-pastel-gray {
  background: #f3f4f6;
  color: #374151;
  border-color: #e5e7eb;
}

.btn-pastel-gray:hover {
  background: #e5e7eb;
  border-color: #d1d5db;
  transform: translateY(-1px);
}

.btn-pastel-red {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fecaca;
}

.btn-pastel-red:hover {
  background: #fecaca;
  border-color: #fca5a5;
  transform: translateY(-1px);
}

.btn-pastel-green {
  background: #dcfce7;
  color: #16a34a;
  border-color: #bbf7d0;
}

.btn-pastel-green:hover {
  background: #bbf7d0;
  border-color: #86efac;
  transform: translateY(-1px);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== MOBILE BULK CONTROLS STYLES ===== */
@media (max-width: 768px) {
  .bulk-controls-bar {
    padding: 20px 16px;
    margin: 0 -16px 16px -16px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  
  .bulk-info {
    margin-bottom: 28px;
    padding-bottom: 16px;
    font-size: 14px;
  }
  
  .bulk-info span {
    font-weight: 500;
    margin-right: 28px;
    display: block;
    margin-bottom: 12px;
  }
  
  .bulk-buttons {
    gap: 8px;
    justify-content: center;
  }
  
  .btn-pastel {
    padding: 12px 16px;
    font-size: 14px;
    min-height: 44px;
    flex: 1;
    min-width: 80px;
  }
}

@media (max-width: 768px) {
  .task-form {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    margin-bottom: 20px !important;
  }
}

@media (max-width: 1024px) {
  .task-form {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

.input, textarea {
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  border-radius: var(--radius);
  padding: 12px 16px;
  outline: none;
  font-size: 14px;
  transition: all 0.2s ease;
  margin: 0;
  box-sizing: border-box;
  width: 100%;
}

.input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.1);
}

.input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

.btn {
  all: unset;
  cursor: pointer;
  padding: 12px 24px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
  text-align: center;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* ===== TASKS ===== */
.tasks {
  display: grid;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
  padding-right: 4px; /* Space for scrollbar */
}

/* Custom scrollbar for task list */
.tasks::-webkit-scrollbar {
  width: 6px;
}

.tasks::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 3px;
}

.tasks::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}

.tasks::-webkit-scrollbar-thumb:hover {
  background: var(--border-dark);
}

.task {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-primary);
  transition: all 0.2s ease;
}

.task.selection-mode {
  grid-template-columns: auto auto 1fr auto;
}

.task:not(.selection-mode) {
  grid-template-columns: auto 1fr auto;
}

.task:not(.selection-mode) .task-select {
  display: none !important;
}

.task:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-sm);
}

.task.selected {
  border-color: var(--color-primary);
  background: rgba(139, 92, 246, 0.05);
}

.task-select {
  display: flex;
  align-items: center;
  margin-top: 2px;
}

.task-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.check {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-dark);
  border-radius: var(--radius-sm);
  margin-top: 2px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.check:hover {
  border-color: var(--accent);
}

.check.done {
  background: var(--success);
  border-color: var(--success);
}

.check svg {
  width: 12px;
  height: 12px;
  opacity: 0;
  transition: opacity 0.2s ease;
  stroke: white;
}

.check.done svg {
  opacity: 1;
}

.task-body {
  min-width: 0;
}

.task .top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.task .name {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 15px;
}

.task .desc {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
}

.task .chips {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  padding: 4px 8px;
  border-radius: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
}

.chip.due {
  background: rgba(255, 193, 7, 0.1);
  border-color: var(--warning);
  color: #856404;
}

.chip.cat {
  background: rgba(40, 167, 69, 0.1);
  border-color: var(--success);
  color: #155724;
}

.task .actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  all: unset;
  cursor: pointer;
  padding: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 14px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
}

.icon-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--border-dark);
}

.icon-btn.danger {
  border-color: rgba(220, 53, 69, 0.3);
  background: rgba(220, 53, 69, 0.05);
  color: var(--danger);
}

.icon-btn.danger:hover {
  background: rgba(220, 53, 69, 0.1);
}

/* ===== SIDEBAR METRICS ===== */
.sidecards {
  display: grid;
  gap: 24px;
}

.metrics {
  display: grid;
  gap: 16px;
}

.metric.widget {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.metric.widget .num {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.metric.widget .label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.metric.widget .list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.metric.widget .list li {
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric.widget .list li:last-child {
  border-bottom: none;
}

.metric.widget .list li.empty {
  color: var(--text-muted);
  font-style: italic;
}

/* See more/less functionality */
.see-more-item {
  margin-top: 8px !important;
  border-bottom: none !important;
}

.see-more-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  transition: color 0.2s ease;
}

.see-more-btn:hover {
  color: var(--color-primary-hover);
}

/* Touch optimization for see more buttons */
@media (pointer: coarse) {
  .see-more-btn {
    min-height: 32px;
    padding: 8px 0;
    font-size: 14px;
    touch-action: manipulation;
  }
}

/* ===== AUTH PAGE ===== */
.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  padding: 24px;
}

.auth .hero {
  display: none;
}

.auth .panel {
  width: 100%;
  max-width: 400px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.tabs-auth {
  display: flex;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  padding: 4px;
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.tabs-auth button {
  all: unset;
  flex: 1;
  text-align: center;
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.2s ease;
}

.tabs-auth button.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.auth .grid {
  display: grid;
  gap: 16px;
  width: 100%;
}

.auth .name-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0;
}

.auth form {
  width: 100%;
  min-height: 0;
}

.auth form[style*="display: none"] {
  display: none !important;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.auth-logo {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  border-radius: var(--radius-sm);
}

.auth h1 {
  text-align: center;
  margin: 0 0 8px 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.hint {
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
  margin-bottom: 24px;
}

.error {
  color: var(--danger);
  font-size: 14px;
  margin-top: 8px;
}

/* ===== DRAWER ===== */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-light);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 1000;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.drawer.open {
  transform: translateX(0);
}

.drawer header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}

.drawer main {
  padding: 24px;
  overflow-y: auto;
}

.drawer footer {
  padding: 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.field label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

/* ===== RESPONSIVE ===== */

/* All mobile devices */
@media screen and (max-width: 991.98px) {
  .mobile-menu-toggle {
    display: flex !important;
  }
  
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 999 !important;
    width: 280px !important;
    height: 100vh !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s ease !important;
  }
  
  .app {
    grid-template-columns: 1fr !important;
    grid-template-areas: 
      "header"
      "main" !important;
  }
}

/* Mobile First Approach - Extra Small devices (phones, 576px and down) */
@media (max-width: 575.98px) {
  .app {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto 1fr !important;
    grid-template-areas: 
      "header"
      "main" !important;
  }
  
  .sidebar {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 999 !important;
    width: 280px !important;
    height: 100vh !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s ease !important;
  }
  
  .sidebar.mobile-open {
    transform: translateX(0) !important;
  }
  
  .mobile-menu-toggle {
    display: flex !important;
  }
  
  .main {
    grid-template-columns: 1fr !important;
    padding: 16px 12px !important;
    gap: 16px !important;
    overflow-x: hidden !important;
  }
  
  .main section {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }
  
  .header {
    padding: 12px 16px !important;
    min-height: 70px !important;
    max-height: 70px !important;
  }
  
  .hello {
    display: none !important;
  }
  
  .hello small {
    display: none !important;
  }
  
  .userbox {
    gap: 6px !important;
    flex-shrink: 0;
  }
  
  .pill {
    padding: 4px 8px !important;
    font-size: 11px !important;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .theme-toggle {
    padding: 6px 8px !important;
    min-width: 36px !important;
    font-size: 14px !important;
  }
  
  .logout {
    padding: 6px 12px !important;
    font-size: 11px !important;
  }
  
  .panel {
    padding: 16px !important;
    height: auto !important;
    max-height: none !important;
  }
  
  .section-title {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
  }
  
  .section-title h3 {
    font-size: 18px !important;
    margin: 0 !important;
  }
  
  .task-form {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    margin-bottom: 20px !important;
  }
  
  .task-form input {
    min-height: 48px !important;
    font-size: 16px !important; /* Prevents zoom on iOS */
    padding: 12px 16px !important;
    border-radius: 8px !important;
    border: 2px solid var(--border-light) !important;
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
  }
  
  .task-form input:focus {
    border-color: var(--color-primary) !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
  }
  
  .task-form .btn {
    min-height: 40px !important;
    width: 100% !important;
    font-size: 14px !important;
    padding: 10px 16px !important;
    border-radius: 6px !important;
    font-weight: 500 !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
    margin-top: 8px !important;
    box-sizing: border-box !important;
  }
  
  .tabs {
    width: 100% !important;
    justify-content: center !important;
    display: flex !important;
  }
  
  .tabs button {
    padding: 12px 16px !important;
    min-height: 48px !important;
    font-size: 14px !important;
    flex: 1 !important;
    text-align: center !important;
    /* Enhanced touch support */
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1) !important;
  }
  
  .tabs button:active {
    transform: scale(0.98) !important;
    transition: transform 0.1s ease !important;
  }
  
  .metric.widget {
    padding: 16px !important;
  }
  
  .metric.widget .num {
    font-size: 24px !important;
  }
  
  .task {
    padding: 12px !important;
    gap: 12px !important;
  }
  
  .task .name {
    font-size: 14px !important;
  }
  
  .task .desc {
    font-size: 12px !important;
  }
  
  .chip {
    font-size: 10px !important;
    padding: 3px 6px !important;
  }
  
  .drawer {
    width: 95vw !important;
    max-width: 95vw !important;
  }
  
  .drawer header,
  .drawer main,
  .drawer footer {
    padding: 16px !important;
  }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
  .app {
    grid-template-columns: 1fr !important;
    grid-template-areas: 
      "header"
      "main" !important;
  }
  
  .sidebar {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 999 !important;
    width: 280px !important;
    height: 100vh !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s ease !important;
  }
  
  .sidebar.mobile-open {
    transform: translateX(0) !important;
  }
  
  .mobile-menu-toggle {
    display: flex !important;
  }
  
  .main {
    grid-template-columns: 1fr !important;
    padding: 20px 16px !important;
    gap: 20px !important;
  }
  
  .header {
    padding: 14px 20px !important;
    min-height: 75px !important;
    max-height: 75px !important;
  }
  
  .hello {
    font-size: 18px !important;
  }
  
  .panel {
    padding: 20px !important;
  }
  
  .task-form {
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: auto auto !important;
    gap: 12px !important;
  }
  
  .task-form #new-name {
    grid-column: 1 / -1 !important;
  }
  
  .task-form button {
    grid-column: 1 / -1 !important;
  }
  
  /* Mobile bulk popup */
  .bulk-popup-content {
    margin: 16px !important;
    max-width: calc(100vw - 32px) !important;
    min-width: 280px !important;
  }
  
  .bulk-buttons {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  
  .btn-pastel {
    min-height: 48px !important;
    font-size: 16px !important;
  }
  
  .drawer {
    width: 90vw !important;
    max-width: 400px !important;
  }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-areas: 
      "header"
      "main";
  }
  
  .sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999;
    width: 280px;
    height: 100vh;
    transform: translateX(-100%);
  }
  
  .mobile-menu-toggle {
    display: flex;
  }
  
  .main {
    grid-template-columns: 2fr 1fr;
    padding: 24px;
    gap: 24px;
  }
  
  .header {
    padding: 16px 24px;
  }
  
  .task-form {
    grid-template-columns: 2fr 1.5fr 1fr auto;
    gap: 12px;
  }
  
  .drawer {
    width: 400px;
    max-width: 85vw;
  }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .app {
    grid-template-columns: 240px 1fr;
  }
  
  .sidebar {
    display: block;
  }
  
  .main {
    grid-template-columns: 1.8fr 1fr;
    padding: 28px;
    gap: 28px;
  }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
  .app {
    grid-template-columns: 280px 1fr;
  }
  
  .main {
    grid-template-columns: 1fr 320px;
    padding: 32px;
    gap: 32px;
  }
}

/* Legacy tablet breakpoint for backwards compatibility */
@media (max-width: 1024px) {
  .task-form {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* Touch device optimizations */
@media (pointer: coarse) {
  .btn, .icon-btn, .theme-toggle, .logout {
    min-height: 44px;
    min-width: 44px;
  }
  
  .check {
    width: 24px;
    height: 24px;
  }
  
  .tabs button {
    padding: 12px 20px;
    min-height: 44px;
    /* Better touch feedback */
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2);
    transition: all 0.15s ease;
  }
  
  .tabs button:active {
    transform: scale(0.98);
    background-color: var(--color-primary) !important;
  }
  
  .nav button {
    padding: 12px 16px;
    min-height: 44px;
  }
  
  .input, textarea {
    min-height: 44px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  .task {
    min-height: 44px;
  }
  
  /* Ensure form is accessible on mobile */
  .task-form {
    position: relative;
    z-index: 10;
  }
  
  .task-form .btn {
    min-height: 48px;
    width: 100%;
    font-size: 16px;
    font-weight: 600;
  }
}

/* Very small screens (320px and below) */
@media (max-width: 320px) {
  .hello {
    font-size: 16px !important;
  }
  
  .hello small {
    display: none;
  }
  
  .userbox {
    flex-wrap: wrap;
    gap: 4px;
  }
  
  .pill {
    font-size: 10px;
    padding: 4px 8px;
  }
  
  .task-form {
    gap: 8px;
  }
  
  .panel {
    padding: 12px;
  }
  
  .section-title h3 {
    font-size: 16px;
  }
}

/* Focus visible for better accessibility */
@supports selector(:focus-visible) {
  *:focus {
    outline: none;
  }
  
  *:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .app {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* Landscape orientation for mobile devices */
@media (max-width: 767.98px) and (orientation: landscape) {
  .header {
    min-height: 60px;
    max-height: 60px;
    padding: 8px 16px;
  }
  
  .hello {
    font-size: 16px;
  }
  
  .main {
    height: calc(100vh - 60px);
    max-height: calc(100vh - 60px);
  }
  
  .panel {
    height: calc(100vh - 60px - 32px);
    max-height: calc(100vh - 60px - 32px);
  }
}

/* Print styles */
@media print {
  .header,
  .sidebar,
  .drawer,
  .theme-toggle,
  .logout,
  .btn,
  .icon-btn {
    display: none !important;
  }
  
  .app {
    grid-template-columns: 1fr !important;
    grid-template-areas: "main" !important;
    height: auto !important;
  }
  
  .main {
    grid-template-columns: 1fr !important;
    padding: 0 !important;
  }
  
  .panel {
    border: none !important;
    box-shadow: none !important;
    background: white !important;
    color: black !important;
  }
  
  .task {
    border: 1px solid #ccc !important;
    page-break-inside: avoid;
  }
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  padding: 16px 20px;
  border-radius: var(--radius);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  max-width: 300px;
  font-size: 14px;
}

.toast.error {
  background: rgba(220, 53, 69, 0.1);
  border-color: var(--danger);
  color: var(--danger);
}

/* ===== UTILITIES ===== */
.hint {
  color: var(--text-muted);
  font-size: 13px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
}
/* ===== Mobile layout fixes: make content scroll & avoid overlap ===== */
@media (max-width: 768px) {
  /* Let the page scroll */
  html, body {
    overflow: auto !important;
    height: auto !important;
  }

  /* One column, natural height */
  .app {
    grid-template-columns: 1fr !important;
    grid-template-areas:
      "header"
      "main" !important;
    height: auto !important;
  }

  .main {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    grid-template-columns: 1fr !important; /* just in case */
    padding: 16px 12px !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  /* Panels should grow naturally, not crop children */
  .panel {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  /* Order: form + tasks first, counters after */
  /* Adjust these IDs/classes to your markup if needed */
  .panel { order: 1 !important; }       /* main card containing add form + tasks */
  .sidecards, .metrics { order: 2 !important; width: 100% !important; }

  /* Task list should not be clipped; let it expand */
  .tasks {
    overflow: visible !important;
    max-height: none !important;
    padding-right: 0 !important;
  }

  /* If you enabled a sticky bulk bar, turn it off on mobile */
  .bulk-controls-bar {
    position: static !important;
    top: auto !important;
    z-index: auto !important;
    margin: 0 0 12px 0 !important;
  }

  /* Make the add button full-width under inputs for easier tapping */
  .task-form {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
  }

  /* Sidebar stays hidden on phones (no overlaying) */
  .sidebar {
    display: none !important;
    transform: translateX(-100%) !important;
  }

  /* Drawer: full width feel on phones */
  .drawer {
    width: 95vw !important;
    max-width: 95vw !important;
  }
}

/* Tiny phones: tighten spacing a bit more */
@media (max-width: 575.98px) {
  .metric.widget .num { font-size: 24px !important; }
  .task { padding: 12px !important; gap: 12px !important; }
  .hello { display: none !important; }
  .hello small { display: none !important; }
}

