/* spa.css — SPA shell layout for Nexus */

/* ---------------------------------------------------------------------------
   Shell Layout: sidebar + main content area
   --------------------------------------------------------------------------- */

body {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
  margin: 0;
}

#sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--md-sys-color-surface-container, #f0f0f0);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--md-sys-color-outline-variant, #c4c4c4);
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 10;
}

#view {
  flex: 1;
  min-width: 0;
  padding: 16px;
  overflow-y: auto;
}

/* ---------------------------------------------------------------------------
   Sidebar Navigation
   --------------------------------------------------------------------------- */

.sidebar-logo {
  padding: 20px 16px 12px;
  font-size: 18px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface, #1a1a1a);
  letter-spacing: 0.5px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
  flex: 1;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border: none;
  background: none;
  border-radius: 28px;
  cursor: pointer;
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant, #444);
  text-decoration: none;
  transition: background 0.15s;
  font-family: inherit;
  text-align: left;
  width: 100%;
}

.sidebar-nav-item:hover {
  background: var(--md-sys-color-surface-container-highest, #e0e0e0);
}

.sidebar-nav-item.active {
  background: var(--md-sys-color-secondary-container, #cce8e8);
  color: var(--md-sys-color-on-secondary-container, #003737);
  font-weight: 500;
}

.sidebar-nav-item md-icon {
  font-size: 22px;
  --md-icon-size: 22px;
}

.sidebar-bottom {
  padding: 12px 16px;
  border-top: 1px solid var(--md-sys-color-outline-variant, #c4c4c4);
}

/* ---------------------------------------------------------------------------
   Sync Status Dot (sidebar bottom)
   --------------------------------------------------------------------------- */

.sidebar-sync {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant, #666);
}

.sidebar-sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9e9e9e;
}

.sidebar-sync-dot[data-status="synced"] {
  background: #4caf50;
}

.sidebar-sync-dot[data-status="pending"] {
  background: #ff9800;
}

.sidebar-sync-dot[data-status="error"] {
  background: #f44336;
}

/* ---------------------------------------------------------------------------
   Mobile Hamburger & Top Bar
   --------------------------------------------------------------------------- */

#mobileTopBar {
  display: none;
}

#menuToggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--md-sys-color-on-surface, #1a1a1a);
  font-size: 24px;
}

/* ---------------------------------------------------------------------------
   FAB (Floating Action Button)
   --------------------------------------------------------------------------- */

#fabBtn {
  display: none; /* Hidden on capture route, shown elsewhere via app.js */
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: none;
  background: var(--md-sys-color-primary, #006a6a);
  color: var(--md-sys-color-on-primary, #fff);
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 3px 5px -1px rgba(0,0,0,.2), 0 6px 10px 0 rgba(0,0,0,.14), 0 1px 18px 0 rgba(0,0,0,.12);
  z-index: 20;
  transition: transform 0.15s, box-shadow 0.15s;
}

#fabBtn:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 5px -3px rgba(0,0,0,.2), 0 8px 10px 1px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12);
}

#fabBtn.visible {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------------------------------------------------------------------------
   Capture Modal
   --------------------------------------------------------------------------- */

#captureModal {
  border: none;
  border-radius: 28px;
  padding: 0;
  max-width: 560px;
  width: 90vw;
  background: var(--md-sys-color-surface-container-low, #fff);
  color: var(--md-sys-color-on-surface, #1a1a1a);
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}

#captureModal::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

#captureModal[open] {
  animation: modalOpen 0.2s ease-out;
}

@keyframes modalOpen {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant, #c4c4c4);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}

.modal-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 24px;
  color: var(--md-sys-color-on-surface-variant, #666);
  padding: 4px;
  border-radius: 50%;
  line-height: 1;
}

.modal-close-btn:hover {
  background: var(--md-sys-color-surface-container-highest, #e0e0e0);
}

.modal-body {
  padding: 16px 24px 24px;
  max-height: 70vh;
  overflow-y: auto;
}

/* ---------------------------------------------------------------------------
   Offline Banner
   --------------------------------------------------------------------------- */

.offline-banner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: #ff9800;
  color: #000;
  text-align: center;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
}

body.offline .offline-banner {
  display: block;
}

/* ---------------------------------------------------------------------------
   Auth Gate — full-page sign-in when unauthenticated
   --------------------------------------------------------------------------- */

.auth-gate {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 50vh;
  padding: 24px 16px;
}

.auth-gate-card {
  max-width: 360px;
  width: 100%;
  text-align: center;
  background: var(--md-sys-color-surface-container, #f0f0f0);
  border: 1px solid var(--md-sys-color-outline-variant, #c4c4c4);
  border-radius: 16px;
  padding: 32px 24px;
}

.auth-gate-logo {
  font-size: 24px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface, #1a1a1a);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.auth-gate-text {
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant, #666);
  margin: 0 0 20px;
  line-height: 1.5;
}

.auth-gate-btn-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

/* Constrain the Google button iframe to prevent oversized logo */
.auth-gate-btn-wrap > div {
  max-width: 280px;
}

.auth-gate-hint {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant, #666);
  opacity: 0.6;
  margin: 0;
  line-height: 1.4;
}

/* ---------------------------------------------------------------------------
   SPA View Common Styles
   --------------------------------------------------------------------------- */

.view-loading, .view-error, .view-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--md-sys-color-on-surface-variant, #666);
  font-size: 14px;
}

.view-empty-hint {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant, #666);
  opacity: 0.7;
  margin-top: 4px;
}

/* ---------------------------------------------------------------------------
   Task View — Sections
   --------------------------------------------------------------------------- */

.tasks-section {
  margin-bottom: 20px;
}

.tasks-section-heading {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--md-sys-color-on-surface-variant, #666);
  margin: 0 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant, #c4c4c4);
}

/* ---------------------------------------------------------------------------
   Task View — Cards (W1.1e)
   --------------------------------------------------------------------------- */

.task-card {
  background: var(--md-sys-color-surface-container, #f0f0f0);
  border: 1px solid var(--md-sys-color-outline-variant, #c4c4c4);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

/* Priority left accent bar */
.task-card[data-priority="high"] {
  border-left: 3px solid #e53935;
}

.task-card[data-priority="medium"] {
  border-left: 3px solid #ffb300;
}

/* Overdue tint */
.task-card[data-overdue="true"] {
  background: color-mix(in srgb, #e53935 5%, var(--md-sys-color-surface-container, #f0f0f0));
}

@supports not (background: color-mix(in srgb, red 5%, white)) {
  .task-card[data-overdue="true"] {
    border-left: 3px solid #e53935;
  }
}

.task-card-title {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--md-sys-color-on-surface, #1a1a1a);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (min-width: 768px) {
  .task-card-title {
    -webkit-line-clamp: 1;
    white-space: nowrap;
    text-overflow: ellipsis;
    display: block;
  }
}

.task-card-preview {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant, #666);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 4px 0 8px;
}

.task-card-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* ---------------------------------------------------------------------------
   Task View — Badges & Chips
   --------------------------------------------------------------------------- */

.status-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  border: 1px solid var(--md-sys-color-outline-variant, #c4c4c4);
  background: var(--md-sys-color-surface-container, #f0f0f0);
  color: var(--md-sys-color-on-surface, #1a1a1a);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  min-height: 28px;
  line-height: 24px;
}

.status-chip:hover {
  background: var(--md-sys-color-surface-container-highest, #e0e0e0);
}

.status-chip.status-open {
  border-color: var(--md-sys-color-primary, #006a6a);
  color: var(--md-sys-color-primary, #006a6a);
}

.status-chip.status-in_progress {
  background: var(--md-sys-color-tertiary-container, #ffd8e4);
  color: var(--md-sys-color-on-tertiary-container, #31111d);
  border-color: transparent;
}

.status-chip.status-done {
  background: var(--md-sys-color-primary-container, #cce8e8);
  color: var(--md-sys-color-on-primary-container, #003737);
  border-color: transparent;
}

.status-chip.status-dropped {
  opacity: 0.6;
}

.priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.priority-dot.high { background: #e53935; }
.priority-dot.medium { background: #ffb300; }
.priority-dot.low { background: var(--md-sys-color-primary, #006a6a); }

/* On mobile, hide dot when card has left-accent bar */
@media (max-width: 767px) {
  .priority-dot.high,
  .priority-dot.medium {
    display: none;
  }
}

.due-badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}

.due-badge.overdue {
  background: #fbe9e7;
  color: #c62828;
}

.due-badge.today {
  background: #fff3e0;
  color: #e65100;
}

.due-badge.future {
  background: var(--md-sys-color-surface-container-highest, #e0e0e0);
  color: var(--md-sys-color-on-surface-variant, #666);
}

@media (prefers-color-scheme: dark) {
  .due-badge.overdue { background: #4e1a1a; color: #ffb4ab; }
  .due-badge.today { background: #3a2a00; color: #ffa726; }
  .due-badge.future { background: var(--md-sys-color-surface-container-highest, #2c2c2c); color: var(--md-sys-color-on-surface-variant, #b0a090); }
}

.tag-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--md-sys-color-surface-container-high, #e8e8e8);
  color: var(--md-sys-color-on-surface-variant, #666);
  font-size: 11px;
}

.task-age {
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant, #666);
}

/* ---------------------------------------------------------------------------
   Task View — Loading Skeleton (W1.1e)
   --------------------------------------------------------------------------- */

.task-skeleton {
  background: var(--md-sys-color-surface-container, #f0f0f0);
  border: 1px solid var(--md-sys-color-outline-variant, #c4c4c4);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 8px;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-line {
  height: 14px;
  background: var(--md-sys-color-surface-container-high, #e8e8e8);
  border-radius: 4px;
  margin-bottom: 8px;
}

.skeleton-line.short { width: 65%; }
.skeleton-line.shorter { width: 40%; height: 10px; }

@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---------------------------------------------------------------------------
   Notes Grid
   --------------------------------------------------------------------------- */

.notes-search-row {
  margin-bottom: 12px;
}

.notes-search-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--md-sys-color-outline-variant, #c4c4c4);
  border-radius: 28px;
  background: var(--md-sys-color-surface-container, #f0f0f0);
  color: var(--md-sys-color-on-surface, #1a1a1a);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}

.notes-search-input:focus {
  border-color: var(--md-sys-color-primary, #006a6a);
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 768px) {
  .notes-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.note-card {
  background: var(--md-sys-color-surface-container, #f0f0f0);
  border: 1px solid var(--md-sys-color-outline-variant, #c4c4c4);
  border-radius: 12px;
  padding: 12px;
  position: relative;
  overflow: hidden;
}

.note-card[data-color="red"]    { border-left: 4px solid #e53935; }
.note-card[data-color="orange"] { border-left: 4px solid #fb8c00; }
.note-card[data-color="yellow"] { border-left: 4px solid #fdd835; }
.note-card[data-color="green"]  { border-left: 4px solid #43a047; }
.note-card[data-color="teal"]   { border-left: 4px solid #00897b; }
.note-card[data-color="blue"]   { border-left: 4px solid #1e88e5; }
.note-card[data-color="gray"]   { border-left: 4px solid #757575; }

.note-pin-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 16px;
  color: var(--md-sys-color-on-surface-variant, #666);
  opacity: 0.7;
}

.note-card-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--md-sys-color-on-surface, #1a1a1a);
}

.note-card-body {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant, #666);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}

.note-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ---------------------------------------------------------------------------
   Lists View
   --------------------------------------------------------------------------- */

.list-card-spa {
  background: var(--md-sys-color-surface-container, #f0f0f0);
  border: 1px solid var(--md-sys-color-outline-variant, #c4c4c4);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 8px;
}

.list-card-header-spa {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.list-card-name-spa {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  color: var(--md-sys-color-on-surface, #1a1a1a);
}

.list-card-stats-spa {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant, #666);
}

.list-persistent-badge-spa {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--md-sys-color-tertiary-container, #ffd8e4);
  color: var(--md-sys-color-on-tertiary-container, #31111d);
}

.list-archived-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--md-sys-color-surface-container-highest, #e0e0e0);
  color: var(--md-sys-color-on-surface-variant, #666);
  opacity: 0.7;
}

.list-expand-btn {
  background: none;
  border: 1px solid var(--md-sys-color-outline-variant, #c4c4c4);
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--md-sys-color-primary, #006a6a);
  font-family: inherit;
}

.list-checklist {
  list-style: none;
  padding: 8px 0 0;
  margin: 0;
}

.list-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.list-check-item.checked .list-check-label {
  text-decoration: line-through;
  opacity: 0.6;
}

.list-check-label {
  font-size: 14px;
  color: var(--md-sys-color-on-surface, #1a1a1a);
}

/* ---------------------------------------------------------------------------
   Toast Container (keep existing position)
   --------------------------------------------------------------------------- */

#toastContainer {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 50;
}

/* ---------------------------------------------------------------------------
   Mobile Responsive
   --------------------------------------------------------------------------- */

@media (max-width: 767px) {
  #sidebar {
    position: fixed;
    left: -220px;
    top: 0;
    bottom: 0;
    transition: left 0.25s ease;
    z-index: 30;
  }

  #sidebar.open {
    left: 0;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 25;
  }

  #sidebar.open ~ .sidebar-backdrop {
    display: block;
  }

  #mobileTopBar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--md-sys-color-surface-container, #f0f0f0);
    border-bottom: 1px solid var(--md-sys-color-outline-variant, #c4c4c4);
    position: sticky;
    top: 0;
    z-index: 10;
  }

  #mobileTopBar .mobile-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface, #1a1a1a);
  }

  body {
    flex-direction: column;
  }

  #view {
    padding: 12px;
  }

  /* Modal full-screen on mobile */
  #captureModal {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
  }

  #fabBtn {
    bottom: 16px;
    right: 16px;
  }
}
