/* ==========================================================================
   TaskFlow Layout — App Shell, Sidebar, Sticky Glass Header & Responsive Grid
   ========================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
  background-color: var(--bg-canvas);
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-3);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  z-index: var(--z-sidebar);
  flex-shrink: 0;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background-color: var(--bg-overlay);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: calc(var(--z-sidebar) - 1);
  animation: tf-fade-in var(--duration-fast) var(--ease-out);
}

/* Brand Header */
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  padding: var(--space-1) var(--space-1-5);
  border-radius: var(--radius-md);
}

.brand-logo {
  width: 32px;
  height: 32px;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-logo svg {
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 2px 6px var(--accent-glow));
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: var(--text-on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.brand-name {
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  line-height: 1.15;
}

.brand-tag,
.brand-subtitle {
  font-size: var(--text-2xs);
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#btn-sidebar-close,
.sidebar .sidebar-close-btn {
  display: none;
  margin-left: auto;
}

/* Primary Navigation */
.nav-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-1-5);
}

.sidebar-section-label {
  padding: 0 var(--space-2-5);
  margin-bottom: var(--space-1);
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  border: 1px solid transparent;
}

.nav-item svg,
.nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color var(--duration-fast) var(--ease-out);
}

.nav-item:hover {
  background-color: var(--bg-surface-subtle);
  color: var(--text-primary);
}

.nav-item:hover svg,
.nav-item:hover .nav-icon {
  color: var(--text-primary);
}

.nav-item.active {
  background-color: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent-border);
  font-weight: 600;
}

.nav-item.active svg,
.nav-item.active .nav-icon {
  color: var(--accent);
}

.nav-label {
  flex: 1 1 auto;
  min-width: 0;
}

.nav-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-full);
  font-size: var(--text-2xs);
  font-weight: 600;
  background-color: var(--bg-surface-subtle);
  color: var(--text-secondary);
}

.nav-item.active .nav-badge {
  background-color: var(--accent);
  color: var(--text-on-accent);
}

/* Sidebar Mini Progress Card */
#sidebar-mini-progress,
.sidebar-mini-progress {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sidebar-widget-header,
.mini-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
}

.sidebar-widget-title {
  color: var(--text-secondary);
}

.sidebar-widget-value,
.mini-progress-value {
  color: var(--text-primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.mini-progress-track {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-subtle);
  overflow: hidden;
}

.mini-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width var(--duration-slow) var(--ease-out);
}

.sidebar-widget-meta,
.mini-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--text-2xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.streak-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background-color: var(--warning-soft);
  color: var(--warning-text);
  font-weight: 600;
}

/* Sidebar Categories */
#sidebar-categories,
.sidebar-categories {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.category-pill-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  border: 1px solid transparent;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.category-pill-nav:hover {
  background-color: var(--bg-surface-subtle);
  color: var(--text-primary);
}

.category-pill-nav.active {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-subtle);
  box-shadow: var(--shadow-xs);
  font-weight: 600;
}

.category-pill-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  background-color: var(--text-muted);
}

.category-dot[data-category="work"],
.category-pill-nav[data-category="work"] .category-dot {
  background-color: var(--cat-work);
}

.category-dot[data-category="health"],
.category-pill-nav[data-category="health"] .category-dot {
  background-color: var(--cat-health);
}

.category-dot[data-category="learning"],
.category-pill-nav[data-category="learning"] .category-dot {
  background-color: var(--cat-learning);
}

.category-dot[data-category="personal"],
.category-pill-nav[data-category="personal"] .category-dot {
  background-color: var(--cat-personal);
}

.category-dot[data-category="admin"],
.category-pill-nav[data-category="admin"] .category-dot {
  background-color: var(--cat-admin);
}

.category-pill-count {
  margin-left: auto;
  font-size: var(--text-2xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-footer-btn {
  width: 100%;
  justify-content: flex-start;
  padding: 0 var(--space-2-5);
  height: 34px;
}

.sidebar-footer-btn .kbd {
  margin-left: auto;
}

/* --------------------------------------------------------------------------
   Main Wrapper & Sticky Glass Header
   -------------------------------------------------------------------------- */
.main-wrapper {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.top-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2-5) var(--space-6);
  background-color: var(--bg-header);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1 1 0%;
  min-width: 0;
}

.header-heading,
.header-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#header-title,
.header-title {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#header-subtitle,
.header-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right,
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 0 0 auto;
  flex-wrap: nowrap;
  max-width: 100%;
}

/* Search Input in Header */
.header-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 185px;
  min-width: 145px;
  max-width: 100%;
  flex: 0 1 185px;
}

.header-search-icon {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

#global-search-input,
.header-search-input {
  width: 100%;
  height: 34px;
  padding: 0 var(--space-3) 0 31px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-size: var(--text-xs);
  box-shadow: var(--shadow-xs);
  transition:
    width var(--duration-base) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

#global-search-input::placeholder,
.header-search-input::placeholder {
  color: var(--text-muted);
}

#global-search-input:focus,
.header-search-input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-ring);
}

/* Header Timer Widget */
#header-timer-widget,
.header-timer-widget {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.timer-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5);
  height: 34px;
  padding: 0 var(--space-1-5) 0 4px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-xs);
  font-size: var(--text-xs);
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.timer-pill.is-running {
  border-color: var(--accent-border);
  background-color: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.timer-pill.is-running.is-break {
  border-color: var(--success-border);
  background-color: var(--success-soft);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.16);
}

.timer-mode-group {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 2px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-subtle);
}

.timer-mode-btn {
  padding: 3px 6px;
  border-radius: var(--radius-xs);
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.1;
  transition:
    background-color var(--duration-fast) ease,
    color var(--duration-fast) ease;
}

.timer-mode-btn:hover {
  color: var(--text-primary);
}

.timer-mode-btn.active {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

.timer-readout {
  min-width: 44px;
  text-align: center;
  font-weight: 700;
  font-size: var(--text-xs);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  padding: 0 2px;
}

.timer-toggle-btn,
.timer-reset-btn {
  width: 26px !important;
  height: 26px !important;
  border-radius: var(--radius-sm) !important;
}

.timer-pill.is-running .timer-toggle-btn {
  background-color: var(--accent);
  color: var(--text-on-accent);
}

.timer-pill.is-running.is-break .timer-toggle-btn {
  background-color: var(--success);
  color: var(--text-on-accent);
}

.timer-task-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 110px;
  padding: 2px 6px 2px 8px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  font-size: var(--text-2xs);
  color: var(--text-secondary);
}

.timer-task-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  font-weight: 500;
}

.timer-task-title:hover {
  color: var(--accent-text);
}

.timer-task-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
}

.timer-task-clear:hover {
  background-color: var(--danger-soft);
  color: var(--danger-text);
}

/* Mobile Menu Button */
#btn-mobile-menu,
.mobile-menu-btn {
  display: none;
}

/* --------------------------------------------------------------------------
   Demo / Sample Data Banner
   -------------------------------------------------------------------------- */
.sample-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background-color: var(--accent-soft);
  border: 1px solid var(--accent-border);
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.sample-banner-text {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.sample-banner-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background-color: var(--accent);
  color: var(--text-on-accent);
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.sample-banner-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
}

/* --------------------------------------------------------------------------
   Main Content & View Panels
   -------------------------------------------------------------------------- */
.main-content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-6) var(--space-6) var(--space-12);
}

.view-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  animation: tf-fade-in var(--duration-fast) var(--ease-out);
}

.view-panel[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Responsive Breakpoints (Desktop -> Tablet -> Mobile 360px+)
   -------------------------------------------------------------------------- */
@media (max-width: 1240px) {
  .timer-task-chip,
  .header-timer-task {
    display: none;
  }
}

@media (max-width: 1120px) {
  :root {
    --sidebar-width: 236px;
  }

  .top-header {
    padding: var(--space-2-5) var(--space-4);
  }

  .main-content {
    padding: var(--space-5) var(--space-4) var(--space-10);
  }

  .header-search {
    width: 155px;
    min-width: 125px;
    flex-basis: 155px;
  }

  .header-cmd-btn .cmd-label {
    display: none;
  }
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(284px, 85vw);
    transform: translateX(-100%);
    transition: transform var(--duration-base) var(--ease-out);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  #btn-sidebar-close,
  .sidebar .sidebar-close-btn {
    display: inline-flex;
  }

  #btn-mobile-menu,
  .mobile-menu-btn {
    display: inline-flex;
  }
}

@media (max-width: 760px) {
  .top-header {
    flex-wrap: wrap;
    padding: var(--space-2-5) var(--space-3);
    gap: var(--space-2);
  }

  .header-left {
    flex: 1 1 auto;
  }

  .header-right,
  .header-actions {
    width: 100%;
    flex: 1 1 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: var(--space-1-5);
  }

  .header-search {
    flex: 1 1 150px;
    width: auto;
    min-width: 0;
  }

  .header-cmd-btn .cmd-label {
    display: none;
  }

  .main-content {
    padding: var(--space-4) var(--space-3) var(--space-8);
  }

  .view-panel {
    gap: var(--space-4);
  }
}

@media (max-width: 440px) {
  .header-cmd-btn .kbd {
    display: none;
  }

  .timer-mode-group {
    display: none;
  }

  .timer-pill {
    padding: 0 var(--space-1-5);
  }
}
