/* ════════════════════════════════════════════════════════════════════════════
   NGINX Field Manual — style.css
   Aesthetic: Terminal Dark — precision documentation meets editorial clarity
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
    --bg:          #080b10;
    --surface:     #0e1117;
    --surface-2:   #141820;
    --surface-3:   #1a2030;
    --border:      #1e2535;
    --border-soft: #15191f;

    --text-1: #e8edf5;
    --text-2: #8b96a8;
    --text-3: #4e5a6b;

    --green:  #4ade80;
    --blue:   #60a5fa;
    --purple: #a78bfa;
    --amber:  #fbbf24;
    --red:    #f87171;
    --pink:   #f472b6;
    --teal:   #34d399;

    --accent: var(--green);
    --mono:   'JetBrains Mono', 'Courier New', monospace;
    --sans:   'IBM Plex Sans', system-ui, sans-serif;
    --display:'Syne', system-ui, sans-serif;

    --sidebar-w: 280px;
    --radius: 8px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
    --shadow:    0 4px 16px rgba(0,0,0,.5);
    --shadow-lg: 0 8px 40px rgba(0,0,0,.7);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text-1);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ════════════════════════════════════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
    z-index: 100;
}

/* ── Logo ────────────────────────────────────────────────────────────────── */
.sidebar-header {
    padding: 28px 20px 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: var(--green);
    color: var(--bg);
    font-family: var(--display);
    font-weight: 800;
    font-size: 20px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.logo-title {
    font-family: var(--display);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-1);
    letter-spacing: 0.03em;
}

.logo-sub {
    font-size: 11px;
    color: var(--text-3);
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ── Progress ────────────────────────────────────────────────────────────── */
.progress-wrap { display: flex; flex-direction: column; gap: 6px; }

.progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-3);
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.progress-pct { color: var(--green); font-weight: 500; }

.progress-track {
    height: 3px;
    background: var(--surface-3);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--teal));
    border-radius: 2px;
    transition: width 0.8s cubic-bezier(.23,1,.32,1);
}

.progress-counts {
    font-size: 11px;
    color: var(--text-3);
    font-family: var(--mono);
}

/* ── Nav ─────────────────────────────────────────────────────────────────── */
.sidebar-nav {
    flex: 1;
    padding: 12px 0 20px;
    overflow-y: auto;
}

.nav-module {
    margin-bottom: 4px;
}

.nav-module-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 20px;
    font-family: var(--display);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
    transition: color .15s;
}

.nav-module-link:hover { color: var(--text-1); }

.nav-icon { font-size: 14px; }

.nav-sections {
    list-style: none;
    padding-left: 0;
    margin-bottom: 8px;
}

.nav-sec-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 20px 6px 36px;
    font-size: 13px;
    color: var(--text-2);
    transition: all .15s;
    border-left: 2px solid transparent;
    position: relative;
}

.nav-sec-link:hover {
    color: var(--text-1);
    background: var(--surface-2);
}

.nav-sec-link.active {
    color: var(--text-1);
    background: var(--surface-2);
    border-left-color: var(--green);
}

.nav-status { font-family: var(--mono); font-size: 11px; flex-shrink: 0; }

.nav-sec-link.status-done .nav-status        { color: var(--green); }
.nav-sec-link.status-in-progress .nav-status { color: var(--amber); }
.nav-sec-link.status-todo .nav-status        { color: var(--text-3); }

/* ── Nav Actions ─────────────────────────────────────────────────────────── */
.nav-actions {
    padding: 16px 20px 0;
    border-top: 1px solid var(--border);
    margin-top: 12px;
}

.btn-admin {
    display: block;
    padding: 9px 14px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
    font-family: var(--mono);
    color: var(--text-2);
    text-align: center;
    transition: all .15s;
}

.btn-admin:hover {
    background: var(--surface-2);
    color: var(--text-1);
    border-color: var(--text-3);
}

/* ════════════════════════════════════════════════════════════════════════════
   MAIN CONTENT
   ════════════════════════════════════════════════════════════════════════════ */
.main {
    flex: 1;
    min-width: 0;
    padding: 0 0 80px;
}

/* ── Page Header ─────────────────────────────────────────────────────────── */
.page-header {
    padding: 60px 40px 50px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.page-header::before {
    content: 'NGINX';
    position: absolute;
    right: -20px;
    top: -10px;
    font-family: var(--display);
    font-size: 160px;
    font-weight: 800;
    color: var(--border-soft);
    line-height: 1;
    pointer-events: none;
    letter-spacing: -0.04em;
    user-select: none;
}

.header-inner { max-width: 760px; position: relative; z-index: 1; }

.header-eyebrow {
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--green);
    margin-bottom: 10px;
}

.header-title {
    font-family: var(--display);
    font-size: clamp(36px, 5vw, 54px);
    font-weight: 800;
    color: var(--text-1);
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
}

.header-sub {
    font-size: 16px;
    color: var(--text-2);
    font-weight: 300;
    max-width: 540px;
    line-height: 1.6;
    margin-bottom: 32px;
}

.header-stats {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
}

.stat { display: flex; flex-direction: column; gap: 2px; }

.stat-val {
    font-family: var(--display);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-1);
}

.stat-label {
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-3);
}

/* ── Module ──────────────────────────────────────────────────────────────── */
.module {
    padding: 48px 40px 16px;
    border-bottom: 1px solid var(--border);
}

.module-header {
    margin-bottom: 28px;
}

.module-number {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

.module-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.module-icon { font-size: 26px; }

.module-title {
    font-family: var(--display);
    font-size: 28px;
    font-weight: 700;
    color: var(--mod-color, var(--blue));
    letter-spacing: -0.01em;
}

.module-desc {
    font-size: 14px;
    color: var(--text-2);
    max-width: 580px;
    line-height: 1.65;
    margin-bottom: 14px;
}

.module-progress-bar {
    height: 2px;
    background: var(--surface-3);
    border-radius: 2px;
    width: 200px;
    overflow: hidden;
}

.module-progress-fill {
    height: 100%;
    width: var(--pct, 0%);
    background: var(--mod-color, var(--blue));
    border-radius: 2px;
    transition: width 1s cubic-bezier(.23,1,.32,1);
}

/* ── Sections Grid ───────────────────────────────────────────────────────── */
.sections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
    align-items: start;
}

/* ── Section Card ────────────────────────────────────────────────────────── */
.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: border-color .2s, transform .2s, box-shadow .2s;
    position: relative;
}

.section-card:hover {
    border-color: var(--text-3);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.section-card.status-done    { border-left: 3px solid var(--green); }
.section-card.status-in-progress { border-left: 3px solid var(--amber); }
.section-card.status-todo    { border-left: 3px solid transparent; }

/* Card top row */
.section-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.section-meta { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; }

.tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
}

/* Status button */
.status-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    font-family: var(--mono);
    transition: all .15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.status-btn:hover { filter: brightness(1.2); transform: scale(1.02); }

.status-btn.status-done        { color: var(--green);  border-color: rgba(74,222,128,.3); background: rgba(74,222,128,.07); }
.status-btn.status-in-progress { color: var(--amber);  border-color: rgba(251,191,36,.3); background: rgba(251,191,36,.07); }
.status-btn.status-todo        { color: var(--text-3); border-color: var(--border); }

.status-sym  { font-size: 14px; }
.status-text { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }

/* Section content */
.section-title {
    font-family: var(--display);
    font-size: 17px;
    font-weight: 700;
    color: var(--text-1);
    line-height: 1.3;
}

.section-body {
    font-size: 14px;
    color: var(--text-2);
    line-height: 1.7;
}

/* Notes */
.section-note {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(251,191,36,.06);
    border: 1px solid rgba(251,191,36,.15);
    border-radius: var(--radius);
    font-size: 13px;
    color: #d4a82a;
    line-height: 1.5;
}

.note-icon { flex-shrink: 0; font-size: 14px; }

/* Code blocks */
.codeblock {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg);
}

.codeblock-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--surface-3);
    border-bottom: 1px solid var(--border);
}

.codeblock-label {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-2);
    flex: 1;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.codeblock-lang {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.copy-btn {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-3);
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    transition: all .15s;
    background: var(--surface-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.copy-btn:hover {
    color: var(--green);
    border-color: rgba(74,222,128,.4);
    background: rgba(74,222,128,.07);
}

.codeblock-pre {
    overflow-x: auto;
    padding: 16px;
}

.codeblock-pre code {
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.75;
    color: #abb2bf;
    white-space: pre;
    display: block;
}

/* Simple syntax highlight hints */
.codeblock-pre code {
    /* Comments */
}

/* Section footer */
.section-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 4px;
}

.edit-btn {
    font-size: 12px;
    font-family: var(--mono);
    color: var(--text-3);
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all .15s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.edit-btn:hover {
    color: var(--blue);
    border-color: rgba(96,165,250,.4);
    background: rgba(96,165,250,.07);
}

/* ── Add Section Card ────────────────────────────────────────────────────── */
.add-section-card {
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-3);
    font-size: 13px;
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: all .2s;
    min-height: 80px;
}

.add-section-card:hover {
    border-color: var(--green);
    color: var(--green);
    background: rgba(74,222,128,.04);
}

.add-icon {
    font-size: 22px;
    font-weight: 300;
    line-height: 1;
}

/* ── Add Module ──────────────────────────────────────────────────────────── */
.add-module-wrap {
    padding: 40px 40px 0;
    display: flex;
    justify-content: center;
}

.add-module-btn {
    padding: 14px 32px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-3);
    font-family: var(--mono);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: all .2s;
    width: 100%;
    max-width: 400px;
}

.add-module-btn:hover {
    border-color: var(--purple);
    color: var(--purple);
    background: rgba(167,139,250,.04);
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.page-footer {
    padding: 40px 40px 0;
    border-top: 1px solid var(--border);
    margin-top: 40px;
    text-align: center;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-3);
    line-height: 2;
}

.footer-sub { opacity: 0.7; }
.footer-sub code { font-family: var(--mono); color: var(--text-2); }
.footer-sub a { color: var(--green); }

/* ════════════════════════════════════════════════════════════════════════════
   MODALS
   ════════════════════════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8,11,16,.85);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-lg);
    transform: translateY(10px);
    transition: transform .2s;
    overflow: hidden;
}

.modal-overlay.active .modal { transform: translateY(0); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-family: var(--display);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-1);
}

.modal-close {
    color: var(--text-3);
    font-size: 16px;
    padding: 4px 8px;
    border-radius: var(--radius);
    transition: all .15s;
}

.modal-close:hover { color: var(--text-1); background: var(--surface-3); }

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

/* Field styles */
.field-group { display: flex; flex-direction: column; gap: 6px; }

.field-group label {
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-3);
}

.field-input, .field-textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--text-1);
    font-family: var(--sans);
    font-size: 14px;
    transition: border-color .15s;
    width: 100%;
}

.field-input:focus, .field-textarea:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(74,222,128,.1);
}

.field-textarea { resize: vertical; min-height: 80px; line-height: 1.6; }

.field-row { display: flex; gap: 12px; }
.field-sm  { flex: 1; min-width: 0; }

.field-color {
    width: 100%;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    cursor: pointer;
    padding: 2px;
}

/* Modal buttons */
.btn-cancel {
    padding: 9px 18px;
    border-radius: var(--radius);
    font-size: 13px;
    font-family: var(--mono);
    color: var(--text-2);
    border: 1px solid var(--border);
    transition: all .15s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-cancel:hover { color: var(--text-1); background: var(--surface-3); }

.btn-save {
    padding: 9px 18px;
    border-radius: var(--radius);
    font-size: 13px;
    font-family: var(--mono);
    color: var(--bg);
    background: var(--green);
    font-weight: 500;
    transition: all .15s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-save:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* ════════════════════════════════════════════════════════════════════════════
   TOAST
   ════════════════════════════════════════════════════════════════════════════ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 13px;
    color: var(--text-1);
    box-shadow: var(--shadow-lg);
    transform: translateY(80px);
    opacity: 0;
    pointer-events: none;
    transition: all .3s cubic-bezier(.23,1,.32,1);
    z-index: 999;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.toast.ok { border-left: 3px solid var(--green); }
.toast.err { border-left: 3px solid var(--red); }

/* ════════════════════════════════════════════════════════════════════════════
   MOBILE NAV TOGGLE
   ════════════════════════════════════════════════════════════════════════════ */
.nav-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 200;
    width: 42px;
    height: 42px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: var(--shadow);
}

.nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-2);
    border-radius: 2px;
    transition: all .25s;
}

.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    body { display: block; }

    .nav-toggle { display: flex; }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform .3s cubic-bezier(.23,1,.32,1);
        z-index: 150;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open { transform: translateX(0); }

    .main { width: 100%; }

    .page-header { padding: 56px 20px 36px; }

    .page-header::before { font-size: 80px; right: -10px; }

    .header-stats { gap: 20px; }

    .module { padding: 32px 20px 16px; }

    .sections-grid {
        grid-template-columns: 1fr;
    }

    .add-module-wrap { padding: 32px 20px 0; }

    .page-footer { padding: 32px 20px 0; }
}

@media (max-width: 480px) {
    .header-title { font-size: 28px; }
    .header-stats { flex-wrap: wrap; gap: 16px; }
    .stat-val { font-size: 18px; }
    .modal { margin: 10px; }
    .modal-body { padding: 16px; }
    .modal-footer { padding: 12px 16px; }
    .field-row { flex-direction: column; }
}

/* ════════════════════════════════════════════════════════════════════════════
   ADMIN PAGE STYLES
   ════════════════════════════════════════════════════════════════════════════ */
.admin-wrap {
    max-width: 800px;
    margin: 0 auto;
    padding: 48px 32px;
}

.admin-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 32px;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all .15s;
}

.admin-back:hover { color: var(--text-1); border-color: var(--text-3); }

.admin-title {
    font-family: var(--display);
    font-size: 36px;
    font-weight: 800;
    color: var(--text-1);
    margin-bottom: 8px;
}

.admin-sub {
    font-size: 14px;
    color: var(--text-2);
    margin-bottom: 40px;
}

.admin-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 20px;
}

.admin-section h2 {
    font-family: var(--display);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-1);
    margin-bottom: 6px;
}

.admin-section p {
    font-size: 13px;
    color: var(--text-3);
    margin-bottom: 20px;
    font-family: var(--mono);
}

.admin-form { display: flex; flex-direction: column; gap: 14px; }
