/* ================================================================
   base.css
   RepoPatch Studio CSS -- split from app.css by css_split.py
   Load order: base.css -> components.css -> panels.css
   ================================================================ */

/* -- DESIGN TOKENS -- */

:root,
[data-theme="light"] {
    /* Surfaces (Nexus Beige) */
    --bg:              #f7f6f2;
    --bg-deep:         #f3f0ec;
    --surface:         #f9f8f5;
    --surface-2:       #fbfbf9;
    --border:          #d4d1ca;
    --divider:         #dcd9d5;
    --white:           #f0f4ff;

    --acid: #5f8f00;
    --acid-hover: #4f7800;

    /* Text */
    --text:            #28251d;
    --muted:           #7a7974;
    --faint:           #bab9b4;
    --on-accent:       #f9f8f4;

    /* Semantic */
    --accent:          #01696f;
    --accent-hover:    #0c4e54;
    --accent-active:   #0f3638;
    --accent-highlight: #cedcd8;
    --warning:         #964219;
    --success:         #437a22;
    --danger:          #a12c7b;
    --info:            #006494;

    /* Misc */
    --shadow:          0 4px 12px oklch(0.2 0.01 80 / 0.08);
    --shadow-sm:       0 1px 2px oklch(0.2 0.01 80 / 0.06);
    --shadow-lg:       0 12px 32px oklch(0.2 0.01 80 / 0.12);
    --radius-sm:       6px;
    --radius-md:       10px;
    --radius-lg:       14px;

    /* Transitions */
    --t: 180ms cubic-bezier(0.16, 1, 0.3, 1);

    /* Fonts */
    --font-body:       'Satoshi', 'Segoe UI', system-ui, sans-serif;
    --font-mono:       'Cascadia Code', 'Consolas', 'Courier New', monospace;
}

[data-theme="dark"] {
    /* Surfaces — website ink palette */
    --bg:              #0d0f14;
    --bg-deep:         #080a0e;
    --surface:         #161a22;
    --surface-2:       #1e2430;
    --border:          #2a3040;
    --divider:         #222836;

    --acid: #b8ff3c;
    --acid-hover: #7fff00;

    /* Text */
    --text:            #f0f4ff;
    --muted:           #8892a4;
    --faint:           #4a5568;
    --on-accent:       #0d0f14;

    /* Semantic — website accent colours */
    --accent:          #b8ff3c;
    --accent-hover:    #7fff00;
    --accent-active:   #5acc00;
    --accent-highlight: rgba(184,255,60,0.12);
    --warning:         #ffb340;
    --success:         #6daa45;
    --danger:          #ff4d6d;
    --info:            #2dd4bf;

    --shadow:          0 4px 12px oklch(0 0 0 / 0.4);
    --shadow-sm:       0 1px 2px oklch(0 0 0 / 0.25);
    --shadow-lg:       0 12px 32px oklch(0 0 0 / 0.55);
    --radius-sm:       6px;
    --radius-md:       10px;
    --radius-lg:       14px;

    --t: 180ms cubic-bezier(0.16, 1, 0.3, 1);

    --font-body:       'Satoshi', 'Segoe UI', system-ui, sans-serif;
    --font-mono:       'Cascadia Code', 'Consolas', 'Courier New', monospace;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg:              #0d0f14;
        --bg-deep:         #080a0e;
        --surface:         #161a22;
        --surface-2:       #1e2430;
        --border:          #2a3040;
        --divider:         #222836;
        --text:            #f0f4ff;
        --muted:           #8892a4;
        --faint:           #4a5568;
        --on-accent:       #0d0f14;
        --accent:          #b8ff3c;
        --accent-hover:    #7fff00;
        --accent-active:   #5acc00;
        --accent-highlight: rgba(184,255,60,0.12);
        --warning:         #ffb340;
        --success:         #6daa45;
        --danger:          #ff4d6d;
        --info:            #2dd4bf;
        --shadow:          0 4px 12px oklch(0 0 0 / 0.4);
        --shadow-sm:       0 1px 2px oklch(0 0 0 / 0.25);
        --shadow-lg:       0 12px 32px oklch(0 0 0 / 0.55);
        --font-body:       'Satoshi', 'Segoe UI', system-ui, sans-serif;
        --font-mono:       'Cascadia Code', 'Consolas', 'Courier New', monospace;
    }
}


[data-theme="vibrant"] {
    /* Surfaces — warm cream */
    --bg:              #fff7ed;
    --bg-deep:         #ffeed8;
    --surface:         #ffffff;
    --surface-2:       #fffaf2;
    --border:          #f0c896;
    --divider:         #f5d5a6;
    --white:           #ffffff;

    --acid: #ff6b35;
    --acid-hover: #e0521f;

    /* Text */
    --text:            #2d1810;
    --muted:           #8b5a3c;
    --faint:           #c89880;
    --on-accent:       #ffffff;

    /* Semantic — saturated magenta/orange */
    --accent:          #d6336c;
    --accent-hover:    #b8255b;
    --accent-active:   #951c4a;
    --accent-highlight: rgba(214,51,108,0.14);
    --warning:         #f59f00;
    --success:         #2f9e44;
    --danger:          #e03131;
    --info:            #1971c2;

    --shadow:          0 4px 14px oklch(0.5 0.15 25 / 0.18);
    --shadow-sm:       0 1px 3px oklch(0.5 0.15 25 / 0.12);
    --shadow-lg:       0 14px 36px oklch(0.5 0.15 25 / 0.22);
    --radius-sm:       6px;
    --radius-md:       10px;
    --radius-lg:       14px;

    --t: 180ms cubic-bezier(0.16, 1, 0.3, 1);

    --font-body:       'Satoshi', 'Segoe UI', system-ui, sans-serif;
    --font-mono:       'Cascadia Code', 'Consolas', 'Courier New', monospace;
}

[data-theme="modern"] {
    /* Surfaces — cool slate */
    --bg:              #1a1f2e;
    --bg-deep:         #131722;
    --surface:         #232938;
    --surface-2:       #2d3447;
    --border:          #3a4258;
    --divider:         #2f3649;
    --white:           #e8edf5;

    --acid: #00d4ff;
    --acid-hover: #00b8df;

    /* Text */
    --text:            #e8edf5;
    --muted:           #94a3b8;
    --faint:           #5a6478;
    --on-accent:       #0a0e18;

    /* Semantic — electric blue */
    --accent:          #3b82f6;
    --accent-hover:    #2563eb;
    --accent-active:   #1d4ed8;
    --accent-highlight: rgba(59,130,246,0.16);
    --warning:         #f59e0b;
    --success:         #10b981;
    --danger:          #ef4444;
    --info:            #06b6d4;

    --shadow:          0 4px 14px oklch(0 0 0 / 0.35);
    --shadow-sm:       0 1px 3px oklch(0 0 0 / 0.22);
    --shadow-lg:       0 14px 36px oklch(0 0 0 / 0.5);
    --radius-sm:       6px;
    --radius-md:       10px;
    --radius-lg:       14px;

    --t: 180ms cubic-bezier(0.16, 1, 0.3, 1);

    --font-body:       'Satoshi', 'Segoe UI', system-ui, sans-serif;
    --font-mono:       'Cascadia Code', 'Consolas', 'Courier New', monospace;
}

/* -- RESET / BASE -- */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
    -webkit-font-smoothing: antialiased;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
}

button,
input,
textarea,
select {
    font: inherit;
    color: inherit;
}

ul {
    list-style: none;
}

/* -- LAYOUT SHELL -- */


.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 12px;
    padding: 12px;
}

/* -- PANELS & TOP BAND -- */


.top-band,
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
}

.top-band {
    padding: 16px;
}

/* -- TOP AREA — brand + metadata cards -- */


.brand-block h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

.brand-block p,
.status-line,
.top-label,
.stage-state,
.item-badge,
.detail-card p,
.ghost-button {
    color: var(--muted);
}

.title span,
.h1 span,
.brand-block h1 span,
.top-summary-brand span,
.login-brand h1 span {
  color: var(--acid);
}

.top-grid {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.top-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.top-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 5px;
}

.top-value {
    font-size: 13px;
    font-weight: 600;
    word-break: break-all;
}

.status-line {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

/* -- MAIN WORKSPACE GRID -- */


.workspace-grid {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) 320px;
    gap: 12px;
    min-height: 0;
}

.left-rail,
.center-workspace,
.right-rail {
    min-height: 0;
}

/* Left rail: working state (flexible) + terminal (bounded) */
.left-rail {
    display: grid;
    grid-template-rows: minmax(0, 1fr) minmax(200px, 320px);
    gap: 12px;
}

/* -- PANELS (shared) -- */


.panel {
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

/* -- TOP REGION — collapsible wrapper -- */

/* display:contents makes the wrapper invisible to the grid —
   children (header, nav) lay out as direct grid items as before  */
.top-region {
    display: contents;
}

/* Collapsed: hide full header + workflow bar */
.top-region--collapsed > #top-band-full,
.top-region--collapsed > .workflow-bar {
    display: none;
}

/* Expanded: hide summary bar */
.top-region--expanded > .top-summary-bar {
    display: none;
}

/* Summary bar — single-row replacement when collapsed */
/* Meta pills: session-id and version in header and summary bar */
.top-meta-pill {
    font-family: var(--font-mono, monospace);
    font-size: 0.78em;
    letter-spacing: 0.02em;
    opacity: 0.72;
}

.top-summary-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    box-shadow: var(--shadow-sm);
    /* When shown it replaces row 1 of the app-shell grid */
    grid-column: 1 / -1;
}

.top-summary-brand {
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    font-family: var(--font-body);
}

.top-summary-sep {
    color: var(--faint);
    flex-shrink: 0;
}

.top-summary-item {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
}

.top-summary-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

/* Secure-session upgrade button — shown only for anonymous sessions */
.top-secure-btn {
    font-size: 11px;
    font-weight: 500;
    color: var(--warning);
    text-decoration: none;
    border-radius: var(--radius-sm);
    padding: 2px 7px;
    border: 1px solid currentColor;
    white-space: nowrap;
    transition: opacity var(--t), background var(--t);
    flex-shrink: 0;
}

.top-secure-btn:hover {
    background: color-mix(in srgb, var(--warning) 12%, transparent);
}

/* Lock icon variant inside brand-actions (icon-only, no border) */
.icon-btn-link {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--warning);
    transition: opacity var(--t), background var(--t);
}

.icon-btn-link:hover {
    background: color-mix(in srgb, var(--warning) 12%, transparent);
}


/* Session countdown pill — shared by summary bar and full header card */
.session-countdown {
    font-family: var(--font-mono, monospace);
    font-size: 0.78em;
    letter-spacing: 0.04em;
    transition: color 0.4s, background 0.4s;
}

.session-countdown--warn {
    color: var(--amber, #b45309);
    font-weight: 600;
}

.session-countdown--expired {
    color: var(--danger, #dc2626);
    font-weight: 700;
}

.session-countdown--locked {
    color: var(--danger, #dc2626);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    fontSize: 0.70em;
}

/* Full-width expired banner pinned to the top of the viewport */
.session-expired-banner {
    position: sticky;
    top: 0;
    z-index: 9999;
    background: var(--danger-bg, #fef2f2);
    color: var(--danger-text, #991b1b);
    border-bottom: 1px solid var(--danger-border, #fca5a5);
    padding: 8px 16px;
    font-size: 13px;
    text-align: center;
}

.session-expired-banner a.session-expired-link {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    margin-left: 4px;
}

/* Full-width locked banner — permanent until midnight PST */
.session-locked-banner {
    position: sticky;
    top: 0;
    z-index: 9999;
    background: var(--danger-bg, #fef2f2);
    color: var(--danger-text, #991b1b);
    border-bottom: 2px solid var(--danger, #dc2626);
    padding: 10px 16px;
    font-size: 13px;
    text-align: center;
    font-weight: 500;
}

/* Refresh session button — shown for anonymous non-locked sessions only */
.top-refresh-btn {
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px 7px;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity var(--t), background var(--t), color var(--t), border-color var(--t);
    flex-shrink: 0;
    line-height: 1.4;
}

.top-refresh-btn:hover {
    background: var(--surface-2);
    border-color: var(--accent);
    color: var(--text);
}

/* ── F7: Job list panel ──────────────────────────────────────────────── */

.job-list-panel {
    max-height: 260px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.job-list-body {
    flex: 1;
    overflow: auto;
    fontSize: 12px;
}

.job-list-ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.job-list-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 6px;
    align-items: center;
    padding: 5px 10px;
    border-bottom: 1px solid var(--divider);
    transition: background var(--t);
}

.job-list-row:hover { background: var(--surface-2); }
.job-list-row--active { background: var(--accent-highlight); }

.job-list-id {
    font-family: var(--font-mono);
    fontSize: 11px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
}

.job-pill {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 99px;
    fontSize: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.job-pill--loaded,
.job-pill--conformed,
.job-pill--validated { color: var(--info);    border-color: var(--info); }
.job-pill--applied    { color: var(--success); border-color: var(--success); }
.job-pill--published  { color: var(--accent);  border-color: var(--accent); }
.job-pill--expired,
.job-pill--archived   { color: var(--danger);  border-color: var(--danger); }

.job-list-expiry {
    fontSize: 10px;
    color: var(--muted);
    white-space: nowrap;
}

.job-list-resume-link {
    fontSize: 11px;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
}
.job-list-resume-link:hover { text-decoration: underline; }

.job-list-empty {
    padding: 16px 12px;
    text-align: center;
    color: var(--muted);
    fontSize: 12px;
}

.job-list-empty-icon {
    display: block;
    fontSize: 22px;
    margin-bottom: 6px;
    color: var(--faint);
}

/* Brand title row — h1 + action buttons inline */
.brand-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 2px;
}

.brand-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Icon button — used for collapse/expand and theme toggle */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: color var(--t), border-color var(--t), background var(--t);
    flex-shrink: 0;
    padding: 0;
}

.icon-btn:hover {
    color: var(--text);
    border-color: var(--accent);
    background: var(--surface-2);
}

/* Override old [data-theme-toggle] rule — now uses .icon-btn */
[data-theme-toggle] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    transition: color var(--t), border-color var(--t), background var(--t);
}

[data-theme-toggle]:hover {
    color: var(--text);
    border-color: var(--accent);
    background: var(--surface-2);
}

/* ── G6: Diff drawer ─────────────────────────────────────────────────── */

.diff-drawer {
    position: fixed;
    inset: 0;
    margin: auto;
    width: min(860px, 96vw);
    max-height: 82vh;
    background: var(--surface-1, var(--surface));
    border: 1px solid var(--border);
    border-radius: var(--radius, 6px);
    padding: 0;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,.45);
    z-index: 9000;
}

.diff-drawer::backdrop {
    background: rgba(0,0,0,.55);
}

.dd-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 82vh;
}

.dd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface);
}

.dd-title-path {
    font-size: 12px;
    font-family: var(--font-mono, monospace);
    color: var(--fg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: calc(100% - 48px);
}

.dd-close-btn {
    background: none;
    border: none;
    fontSize: 20px;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
    padding: 2px 6px;
    border-radius: 3px;
    flex-shrink: 0;
}
.dd-close-btn:hover { background: var(--surface-2); color: var(--fg); }

.dd-body {
    flex: 1;
    overflow: auto;
    padding: 0;
}

.dd-source-pre {
    margin: 0;
    padding: 8px 0;
    font-family: var(--font-mono, monospace);
    fontSize: 12px;
    line-height: 1.55;
    color: var(--fg);
    background: transparent;
    white-space: pre-wrap;
    word-break: break-all;
}

.dd-line {
    display: block;
    padding: 0 14px;
}

.dd-line--del {
    background: color-mix(in srgb, var(--danger, #e55) 14%, transparent);
    color: var(--danger, #e55);
    text-decoration: line-through;
    text-decoration-color: color-mix(in srgb, var(--danger, #e55) 55%, transparent);
}

.dd-loading, .dd-notice {
    padding: 20px 16px;
    color: var(--muted);
    fontSize: 12px;
    font-style: italic;
}

.dd-error {
    padding: 16px;
    color: var(--danger);
    fontSize: 12px;
}



/* ================================================================
   BASE.CSS — RESPONSIVE ADDITIONS
   (appended to existing base.css content)
   Tablet ≤ 900px  |  Phone ≤ 600px
================================================================ */

/* ── Tablet (≤ 900px) ─────────────────────────────────────────── */

@media (max-width: 900px) {

  /* App shell: remove fixed 3-row assumption, let rows be auto */
  .app-shell {
    grid-template-rows: auto auto auto 1fr;
    gap: 10px;
    padding: 10px;
  }

  /* Workspace grid: single column
     NOTE: #workspace-grid overrides in components.css take precedence
     for the 5-column handle layout; this catches .workspace-grid class */
  .workspace-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    min-height: 0;
  }

  /* Left rail: auto height, bounded terminal */
  .left-rail {
    grid-template-rows: auto minmax(160px, 240px);
    gap: 10px;
  }

  /* Top summary bar: allow items to wrap */
  .top-summary-bar {
    flex-wrap: wrap;
    height: auto;
    gap: 6px;
    padding: 8px 12px;
  }
  .top-summary-item {
    max-width: 180px;
  }

  /* Top-band: tighten */
  .top-band { padding: 14px; }

  /* Top info grid: 2-column (also in components.css, duplicate for safety) */
  .top-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 10px;
  }

  /* Status line: smaller */
  .status-line { font-size: 12px; }
}

/* ── Phone (≤ 600px) ─────────────────────────────────────────── */

@media (max-width: 600px) {

  /* App shell: minimal padding */
  .app-shell {
    padding: 8px;
    gap: 8px;
  }

  /* Top band */
  .top-band { padding: 10px 12px; }

  /* Brand h1 */
  .brand-block h1 { font-size: 20px; }
  .brand-block p  { font-size: 12px; }

  /* Brand title row: tighter */
  .brand-title-row { gap: 8px; margin-bottom: 4px; }

  /* Icon buttons: slightly smaller target */
  .icon-btn,
  [data-theme-toggle] {
    width: 26px;
    height: 26px;
    font-size: 14px;
  }

  /* Top info grid: single column */
  .top-grid {
    grid-template-columns: 1fr;
    margin-top: 8px;
    gap: 6px;
  }
  .top-card { padding: 8px 10px; }
  .top-value { font-size: 12px; }

  /* Top summary bar: compact */
  .top-summary-bar {
    padding: 6px 10px;
    gap: 4px;
    font-size: 11px;
  }
  .top-summary-brand { font-size: 12px; }
  .top-summary-item  { max-width: 140px; font-size: 11px; }

  /* Status line */
  .status-line {
    font-size: 12px;
    margin-top: 8px;
    padding-top: 8px;
  }

  /* Panel headers */
  .panel-header {
    padding: 9px 12px;
  }
  .panel-header h2 {
    font-size: 12px;
  }

  /* Job list panel: shorter */
  .job-list-panel { max-height: 180px; }
}
