/* layout.css — App shell: sidebar + content area + bottom nav */

/* ── APP SHELL ──────────────────────────────────────────── */
.app-shell {
    min-height: 100dvh;
}

/* ── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sidebar);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    transition: width var(--tr-normal);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-5) var(--sp-5) var(--sp-3);
}

.sidebar-logo {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg-main);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-ui);
    font-weight: var(--weight-black);
    font-size: var(--text-sm);
    color: var(--accent-yellow);
    flex-shrink: 0;
}

.sidebar-title {
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
}

/* Macro pill */
.sidebar-macro {
    margin: 0 var(--sp-4) var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-macro-phase {
    font-weight: var(--weight-bold);
    color: var(--accent-teal, var(--accent-yellow));
}

.sidebar-macro-jcount {
    color: var(--text-dim);
}

/* Nav sections */
.sidebar-nav {
    padding: var(--sp-2) var(--sp-3);
}

.sidebar-nav-label {
    font-size: var(--text-xs);
    font-weight: var(--weight-semi);
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: var(--sp-2) var(--sp-3);
    margin-top: var(--sp-2);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-muted);
    transition: background var(--tr-fast), color var(--tr-fast);
    cursor: pointer;
    white-space: nowrap;
    margin-bottom: 2px;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: var(--text-main);
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-active-text);
    font-weight: var(--weight-semi);
}

.sidebar-link-icon {
    width: 20px; height: 20px;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}

.sidebar-link-icon svg {
    width: 18px; height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: var(--sp-2) var(--sp-4);
}

/* Workflow widget */
.sidebar-workflow {
    padding: var(--sp-2) var(--sp-4);
    margin-top: var(--sp-1);
}

.sidebar-workflow-title {
    font-size: var(--text-xs);
    font-weight: var(--weight-semi);
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--sp-2);
}

.workflow-step {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 6px var(--sp-3);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--tr-fast);
}

.workflow-step:hover { background: var(--sidebar-hover); }

.workflow-step-check {
    width: 16px; height: 16px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: border-color var(--tr-fast), background var(--tr-fast);
}

.workflow-step.done .workflow-step-check {
    background: var(--status-green);
    border-color: var(--status-green);
}

.workflow-step.done .workflow-step-check svg {
    stroke: #fff;
}

.workflow-step-time {
    margin-left: auto;
    font-family: var(--font-ui);
    font-size: 10px;
    color: var(--text-dim);
}

/* Quick stats */
.sidebar-stats {
    margin-top: auto;
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: var(--sp-4);
    font-family: var(--font-ui);
    font-size: var(--text-xs);
}

.sidebar-stat-label {
    color: var(--text-dim);
    font-size: 10px;
    text-transform: uppercase;
}

.sidebar-stat-value {
    font-weight: var(--weight-bold);
    color: var(--text-main);
}

/* Theme toggle */
.sidebar-footer {
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.theme-toggle {
    width: 36px; height: 36px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: background var(--tr-fast);
}

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

.theme-toggle svg {
    width: 18px; height: 18px;
    stroke: var(--text-muted);
    fill: none;
    stroke-width: 1.8;
}

/* Show sun in dark mode, moon in light mode */
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun  { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ── CONTENT AREA ───────────────────────────────────────── */
.content-area {
    margin-left: var(--sidebar-w);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.content-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in srgb, var(--bg-main) 85%, transparent);
    border-bottom: 1px solid var(--border-subtle);
    padding: var(--sp-5) var(--sp-8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    min-height: 72px;
    box-sizing: border-box;
}

/* Keep trailing element compact so header height stays fixed */
.content-header-right > * {
    max-height: 40px;
    display: inline-flex;
    align-items: center;
}

.content-header-left {
    display: flex;
    align-items: baseline;
    gap: var(--sp-4);
    flex-wrap: wrap;
    min-width: 0;
}

.content-title {
    font-size: var(--text-xl);
    font-weight: var(--weight-heavy);
    color: var(--text-main);
    letter-spacing: -0.02em;
    margin: 0;
}

.content-date {
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    color: var(--text-dim);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.content-body {
    flex: 1;
    padding: var(--content-pad);
    max-width: var(--content-max);
    width: 100%;
    margin: 0 auto;
    container-type: inline-size;
    container-name: content;
}

/* ── BOTTOM NAV (mobile) ────────────────────────────────── */
.bottom-nav {
    display: none; /* hidden on desktop */
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-h);
    background: var(--bottom-nav-bg);
    border-top: 1px solid var(--bottom-nav-border);
    z-index: var(--z-bottom-nav);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: var(--bottom-nav-h);
    max-width: 500px;
    margin: 0 auto;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-md);
    color: var(--text-dim);
    font-size: 10px;
    font-weight: var(--weight-semi);
    transition: color var(--tr-fast);
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item.active {
    color: var(--accent-teal, var(--accent-yellow));
}

/* Active indicator dot under icon */
.bottom-nav-item.active::after {
    content: '';
    display: block;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--accent-teal, var(--accent-yellow));
    margin-top: 2px;
}

.bottom-nav-item svg {
    width: 22px; height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── RESPONSIVE ─────────────────────────────────────────── */

/* Tablet: icon-only sidebar */
@media (min-width: 768px) and (max-width: 1023px) {
    .sidebar {
        width: var(--sidebar-w-icon);
    }

    .sidebar-title,
    .sidebar-macro,
    .sidebar-link span:not(.sidebar-link-icon),
    .sidebar-nav-label,
    .sidebar-workflow,
    .sidebar-stat-label,
    .sidebar-stats .sidebar-stat:not(:first-child) {
        display: none;
    }

    .sidebar-brand { justify-content: center; padding: var(--sp-4) var(--sp-2); }
    .sidebar-link { justify-content: center; padding: var(--sp-3); }
    .sidebar-footer { justify-content: center; }
    .sidebar-stats { justify-content: center; }

    .content-area {
        margin-left: var(--sidebar-w-icon);
    }
}

/* Mobile: no sidebar, bottom nav */
@media (max-width: 767px) {
    .sidebar { display: none; }

    .content-area {
        margin-left: 0;
        /* Only account for bottom-nav height; the nav itself handles safe-area */
        padding-bottom: var(--bottom-nav-h);
    }

    .content-header {
        padding: var(--sp-3) var(--sp-4);
        /* Safe-area for notch devices */
        padding-top: max(var(--sp-3), env(safe-area-inset-top, 0));
    }

    .content-body {
        padding: var(--sp-4);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .bottom-nav {
        display: block;
    }
}

/* Container queries for content-area components */
@container content (max-width: 600px) {
    .metrics-row { grid-template-columns: repeat(2, 1fr); }
}

@container content (max-width: 400px) {
    .metrics-row { grid-template-columns: 1fr; }
}
