/* ==========================================================================
   Lab Runbooks CMS — Stylesheet
   ========================================================================== */

/* --- Fonts --- */
@font-face {
    font-family: 'NVIDIA Sans';
    src: url('/static/fonts/nvidiasans-regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'NVIDIA Sans';
    src: url('/static/fonts/nvidiasans-medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'NVIDIA Sans';
    src: url('/static/fonts/nvidiasans-bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* --- CSS Custom Properties --- */
:root {
    --font-sans: 'NVIDIA Sans', system-ui, -apple-system, BlinkMacSystemFont,
                 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'IBM Plex Mono', 'Roboto Mono', SFMono-Regular, Menlo,
                 Monaco, Consolas, 'Liberation Mono', monospace;

    /* Colors */
    --color-text: #1D1D1D;
    --color-text-secondary: #6E6E6E;
    --color-text-muted: #9E9E9E;
    --color-bg: #FFFFFF;
    --color-surface: #F7F7F7;
    --color-border: #E5E5E5;
    --color-border-strong: #D0D0D0;
    --color-brand: #76B900;
    --color-brand-hover: #91C733;
    --color-error: #FF5252;

    /* Layout */
    --header-height: 64px;
    --nav-height: 45px;
    --content-max-width: 960px;
    --content-gutter: 32px;
    --sidebar-width: 320px;
}

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

/* --- Scrollbar layout shift fix --- */
html {
    scrollbar-gutter: stable;
}

/* --- Base --- */
body {
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 400;
    line-height: 26px;
    letter-spacing: normal;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Admin Sidebar
   ========================================================================== */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px 20px 12px;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0 12px;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}

/* Site group */
.sidebar-site {
    margin-bottom: 4px;
}

.sidebar-site-header {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.1s;
    gap: 6px;
}

.sidebar-site-header:hover {
    background: var(--color-border);
}

.sidebar-toggle {
    width: 14px;
    flex-shrink: 0;
    font-size: 10px;
    color: var(--color-text-muted);
    text-align: center;
}

.sidebar-site-icon {
    font-size: 14px;
    flex-shrink: 0;
    line-height: 1;
}

.sidebar-site-name {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-site--active > .sidebar-site-header .sidebar-site-name {
    color: var(--color-brand);
}

/* Shared action button (delete) */
.sidebar-action {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
}

.sidebar-action--delete {
    font-size: 18px;
    color: var(--color-text-muted);
}

.sidebar-site-header:hover .sidebar-action,
.sidebar-page:hover .sidebar-action {
    display: block;
}

.sidebar-action--edit {
    font-size: 14px;
    color: var(--color-text-muted);
}

.sidebar-action--edit:hover {
    color: var(--color-brand);
}

.sidebar-action--delete:hover {
    color: var(--color-error);
}

/* Page list — indented under site */
.sidebar-pages {
    padding: 2px 0 4px 0;
    margin-left: 20px;
    border-left: 1px solid var(--color-border);
}

.sidebar-page {
    display: flex;
    align-items: center;
    padding: 3px 16px 3px 0;
    gap: 2px;
}

.sidebar-page:hover {
    background: var(--color-border);
}

.sidebar-page-icon {
    width: 20px;
    text-align: center;
    font-size: 10px;
    color: var(--color-border-strong);
    flex-shrink: 0;
}

.sidebar-page-link {
    flex: 1;
    font-size: 13px;
    color: var(--color-text-secondary);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-page--active .sidebar-page-link {
    color: var(--color-brand);
    font-weight: 500;
}

/* "Add Page" button inside page list */
.sidebar-add-btn {
    display: block;
    width: 100%;
    padding: 5px 16px 5px 22px;
    font-size: 12px;
    font-family: var(--font-sans);
    font-weight: 500;
    color: var(--color-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: color 0.1s;
}

.sidebar-add-btn:hover {
    color: var(--color-brand);
}

/* --- Inline forms (replace browser prompt dialogs) --- */
.sidebar-inline-form {
    padding: 6px 12px;
}

.sidebar-inline-form--rename {
    padding: 0;
    flex: 1;
}

.sidebar-inline-input {
    width: 100%;
    padding: 6px 10px;
    font-size: 13px;
    font-family: var(--font-sans);
    border: 1px solid var(--color-brand);
    border-radius: 4px;
    background: var(--color-bg);
    color: var(--color-text);
    outline: none;
    box-shadow: 0 0 0 2px rgba(118, 185, 0, 0.15);
}

.sidebar-inline-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.sidebar-inline-ok,
.sidebar-inline-cancel {
    padding: 4px 12px;
    font-size: 12px;
    font-family: var(--font-sans);
    font-weight: 500;
    border-radius: 4px;
    border: none;
    cursor: pointer;
}

.sidebar-inline-ok {
    background: var(--color-brand);
    color: #000000;
}

.sidebar-inline-ok:hover {
    background: var(--color-brand-hover);
}

.sidebar-inline-cancel {
    background: transparent;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.sidebar-inline-cancel:hover {
    background: var(--color-bg);
}

/* New site multi-field form */
.sidebar-new-site-form {
    padding: 12px 16px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}

.sidebar-form-group {
    margin-bottom: 10px;
}

.sidebar-form-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.sidebar-form-hint {
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    color: var(--color-text-muted);
}

.sidebar-form-hint strong {
    color: var(--color-brand);
    font-weight: 500;
}

.sidebar-form-error {
    display: block;
    font-size: 12px;
    color: var(--color-error);
    margin-top: 3px;
    min-height: 16px;
}

/* Admin body shift — push everything right when sidebar is visible */
.body--admin {
    padding-left: var(--sidebar-width);
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
    height: var(--header-height);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.header-inner {
    display: flex;
    align-items: center;
    height: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 24px;
}

.header-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    text-decoration: none;
}

.header-logo img {
    display: block;
}

.header-divider {
    width: 1px;
    height: 24px;
    background: var(--color-border-strong);
    margin: 0 12px;
    flex-shrink: 0;
}

.header-title {
    font-size: 18px;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: var(--header-height);
}

.header-spacer {
    flex: 1;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Small button variant */
.btn--sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* ==========================================================================
   Navigation Tabs
   ========================================================================== */

.site-nav {
    height: var(--nav-height);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.nav-inner {
    display: flex;
    align-items: stretch;
    height: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 24px;
    gap: 0;
    overflow-x: auto;
}

.nav-tab {
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 400;
    line-height: 21px;
    letter-spacing: normal;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}

.nav-tab:first-child {
    padding-left: 0;
}

.nav-tab:hover {
    color: var(--color-text);
}

.nav-tab--active {
    color: var(--color-brand);
    font-weight: 500;
    border-bottom-color: var(--color-brand);
}

/* ==========================================================================
   Main Content
   ========================================================================== */

.site-content {
    position: relative;
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 40px var(--content-gutter) 80px;
    width: 100%;
}

/* Edit button (floating, top-right of content) */
.edit-btn {
    position: absolute;
    top: 40px;
    right: var(--content-gutter);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-sans);
    color: var(--color-text-secondary);
    text-decoration: none;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.edit-btn:hover {
    background: var(--color-surface);
    color: var(--color-text);
}

/* ==========================================================================
   Landing Page
   ========================================================================== */

.landing {
    max-width: 800px;
}

.landing-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 32px;
}

.landing-title {
    font-size: 36px;
    font-weight: 700;
    line-height: 45px;
    letter-spacing: -0.9px;
    margin-bottom: 8px;
}

.landing-subtitle {
    font-size: 16px;
    color: var(--color-text-secondary);
    margin-bottom: 0;
}

.site-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.site-card {
    display: block;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg);
    text-decoration: none;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.site-card:hover {
    border-color: var(--color-brand);
    box-shadow: 0 4px 16px rgba(118, 185, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.site-card-accent {
    height: 4px;
    background: var(--color-brand);
}

.site-card-body {
    padding: 20px 24px 24px;
}

.site-card-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
    line-height: 24px;
}

.site-card-desc {
    font-size: 14px;
    line-height: 20px;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
}

.site-card-meta {
    font-size: 13px;
    color: var(--color-text-muted);
}

.landing-empty {
    color: var(--color-text-muted);
    font-size: 14px;
}

/* ==========================================================================
   Content Typography (rendered markdown)
   ========================================================================== */

.contents > * + * {
    margin-top: 16px;
}

.contents > h1 {
    font-size: 36px;
    font-weight: 700;
    line-height: 45px;
    letter-spacing: -0.9px;
    margin-top: 0;
    margin-bottom: 16px;
}

.contents > h2 {
    font-size: 30px;
    font-weight: 600;
    line-height: 36px;
    letter-spacing: -0.375px;
    margin-top: 48px;
}

.contents > h3 {
    font-size: 24px;
    font-weight: 600;
    line-height: 32px;
    letter-spacing: -0.3px;
    margin-top: 32px;
}

.contents > h4 {
    font-size: 18px;
    font-weight: 600;
    line-height: 24px;
    margin-top: 24px;
}

.contents h2 + p,
.contents h3 + p,
.contents h4 + p {
    margin-top: 8px;
}

.contents > :first-child {
    margin-top: 0;
}

.contents p {
    font-size: 16px;
    line-height: 26px;
}

.contents a {
    color: var(--color-text);
    text-decoration: underline;
    text-decoration-color: var(--color-brand);
    text-decoration-thickness: 1.12px;
    text-underline-offset: 3px;
    transition: text-decoration-color 0.15s;
}

.contents a:hover {
    text-decoration-color: var(--color-text);
}

/* Lists */
.contents ul,
.contents ol {
    padding-left: 24px;
}

.contents li {
    margin-top: 6px;
    line-height: 26px;
}

.contents li > p {
    margin-top: 0;
}

/* Code */
.contents code {
    font-family: var(--font-mono);
    font-size: 12.25px;
    line-height: 20px;
    background: var(--color-surface);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--color-border);
}

.contents pre {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 16px 20px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 12.25px;
    line-height: 20px;
}

.contents pre code {
    background: none;
    padding: 0;
    border: none;
    border-radius: 0;
}

/* Tables */
.contents table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    line-height: 21px;
    margin-top: 16px;
}

.contents thead {
    background: var(--color-surface);
}

.contents th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-border);
}

.contents td {
    padding: 12px 16px;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
}

.contents tr:hover td {
    background: rgba(0, 0, 0, 0.02);
}

/* Blockquotes (used as callouts) */
.contents blockquote {
    border-left: 3px solid var(--color-brand);
    padding: 12px 16px;
    margin: 16px 0;
    background: color-mix(in srgb, var(--color-brand) 4%, var(--color-bg));
    border-radius: 0 6px 6px 0;
}

.contents blockquote p {
    color: var(--color-text-secondary);
    font-size: 14px;
}

/* Horizontal rules */
.contents hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 32px 0;
}

/* Images */
.contents img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

/* ==========================================================================
   Editor
   ========================================================================== */

.editor-container {
    max-width: 100%;
}

.editor-header {
    margin-bottom: 16px;
}

.editor-body {
    margin-bottom: 16px;
}

.editor-actions {
    display: flex;
    gap: 8px;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--color-text);
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: var(--font-sans);
    background: var(--color-bg);
    border: 1px solid var(--color-border-strong);
    border-radius: 6px;
    color: var(--color-text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: 0 0 0 2px rgba(118, 185, 0, 0.15);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
    text-decoration: none;
}

.btn--primary {
    background: var(--color-brand);
    color: #000000;
    border-color: transparent;
}

.btn--primary:hover {
    background: var(--color-brand-hover);
}

.btn--ghost {
    background: transparent;
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn--ghost:hover {
    background: var(--color-surface);
}

.btn--full {
    width: 100%;
}

/* ==========================================================================
   Login Page
   ========================================================================== */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-surface);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 40px;
}

.login-logo {
    margin-bottom: 32px;
}

.login-title {
    font-size: 24px;
    font-weight: 600;
    line-height: 32px;
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-bottom: 24px;
}

.login-error {
    padding: 10px 14px;
    margin-bottom: 16px;
    border-radius: 6px;
    font-size: 14px;
    color: var(--color-error);
    background: color-mix(in srgb, var(--color-error) 6%, var(--color-bg));
    border: 1px solid color-mix(in srgb, var(--color-error) 20%, var(--color-bg));
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .header-title {
        display: none;
    }
    .header-divider {
        display: none;
    }
    .site-content {
        padding: 24px 16px 48px;
    }
    .nav-tab {
        padding: 0 12px;
        font-size: 13px;
    }
    .edit-btn {
        top: 24px;
        right: 16px;
    }
    .sidebar {
        width: 260px;
    }
    .body--admin {
        padding-left: 260px;
    }
}
