/* AtlasBridge Dashboard — Brand System v1
   Tokens: docs/branding.md | No framework, no CDN */

/* ----------------------------------------------------------------
   Brand tokens — Dark mode (default)
   ---------------------------------------------------------------- */
:root {
    /* Surfaces */
    --ab-bg: #071D2B;
    --ab-panel: #0D2B3E;
    --ab-panel-hover: #133A52;
    --ab-border: #1A4A64;
    --ab-banner-bg: #0A2233;

    /* Text */
    --ab-text: #E6EEF5;
    --ab-text-muted: #A8B3BD;

    /* Brand */
    --ab-primary: #0B2A3C;
    --ab-accent: #1F8A8C;

    /* Status */
    --ab-success: #1E7E34;
    --ab-warning: #C77D00;
    --ab-danger: #A4161A;
    --ab-warning-alt: #B86E00;

    /* Typography */
    --ab-font: Inter, "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --ab-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

/* ----------------------------------------------------------------
   Brand tokens — Light mode
   ---------------------------------------------------------------- */
body.light {
    --ab-bg: #F5F7F9;
    --ab-panel: #FFFFFF;
    --ab-panel-hover: #EDF0F3;
    --ab-border: #D1D9E0;
    --ab-banner-bg: #EDF0F3;

    --ab-text: #0B2A3C;
    --ab-text-muted: #6E7A86;

    --ab-accent: #1F8A8C;

    --ab-success: #1E7E34;
    --ab-warning: #9A6700;
    --ab-danger: #A4161A;
    --ab-warning-alt: #B86E00;
}

/* ----------------------------------------------------------------
   Reset + base
   ---------------------------------------------------------------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--ab-font);
    background: var(--ab-bg);
    color: var(--ab-text);
    font-weight: 400;
    line-height: 1.6;
    min-height: 100vh;
}

/* ----------------------------------------------------------------
   Banner
   ---------------------------------------------------------------- */
.banner {
    background: var(--ab-banner-bg);
    border-bottom: 1px solid var(--ab-border);
    text-align: center;
    padding: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--ab-warning);
}

/* ----------------------------------------------------------------
   Nav
   ---------------------------------------------------------------- */
nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 2rem;
    border-bottom: 1px solid var(--ab-border);
    background: var(--ab-panel);
}

nav .brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--ab-accent);
    text-decoration: none;
    margin-right: auto;
}

nav a {
    color: var(--ab-text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

nav a:hover { color: var(--ab-text); }

.nav-btn {
    background: transparent;
    border: 1px solid var(--ab-border);
    color: var(--ab-text-muted);
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--ab-font);
}

.nav-btn:hover { color: var(--ab-text); background: var(--ab-panel-hover); }

/* ----------------------------------------------------------------
   Main content
   ---------------------------------------------------------------- */
main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem;
}

h1 { font-size: 1.5rem; font-weight: 600; margin-bottom: 1.5rem; }
h2 { font-size: 1.2rem; font-weight: 600; margin: 2rem 0 1rem; color: var(--ab-text-muted); }

/* ----------------------------------------------------------------
   Stats grid
   ---------------------------------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--ab-panel);
    border: 1px solid var(--ab-border);
    border-radius: 8px;
    padding: 1.25rem;
    text-align: center;
}

.stat-card.card-ok { border-color: var(--ab-success); }
.stat-card.card-error { border-color: var(--ab-danger); }

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--ab-accent);
}

.card-ok .stat-value { color: var(--ab-success); }
.card-error .stat-value { color: var(--ab-danger); }

.stat-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ab-text-muted);
    margin-top: 0.25rem;
}

/* ----------------------------------------------------------------
   Filter bar
   ---------------------------------------------------------------- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--ab-panel);
    border: 1px solid var(--ab-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-input {
    flex: 1;
    min-width: 150px;
    padding: 0.4rem 0.6rem;
    background: var(--ab-bg);
    color: var(--ab-text);
    border: 1px solid var(--ab-border);
    border-radius: 4px;
    font-family: var(--ab-font);
    font-size: 0.85rem;
}

.filter-input:focus {
    outline: none;
    border-color: var(--ab-accent);
}

.filter-select {
    padding: 0.4rem 0.6rem;
    background: var(--ab-bg);
    color: var(--ab-text);
    border: 1px solid var(--ab-border);
    border-radius: 4px;
    font-family: var(--ab-font);
    font-size: 0.85rem;
}

.filter-btn {
    padding: 0.4rem 1rem;
    background: var(--ab-panel-hover);
    color: var(--ab-accent);
    border: 1px solid var(--ab-border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: var(--ab-font);
}

.filter-btn:hover { background: var(--ab-border); }

.filter-clear {
    color: var(--ab-text-muted);
    font-size: 0.85rem;
}

/* ----------------------------------------------------------------
   Tables
   ---------------------------------------------------------------- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
}

th, td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--ab-border);
    font-size: 0.9rem;
}

th {
    color: var(--ab-text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Zebra striping */
tbody tr:nth-child(even) td { background: var(--ab-panel); }
tr:hover td { background: var(--ab-panel-hover); }

/* Detail table (key-value) */
.detail-table { max-width: 700px; }
.detail-table th { width: 140px; white-space: nowrap; }

/* ----------------------------------------------------------------
   Status badges
   ---------------------------------------------------------------- */
[class^="status-"] {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-running, .status-starting { background: rgba(30, 126, 52, 0.15); color: var(--ab-success); }
.status-completed, .status-resolved { background: rgba(31, 138, 140, 0.15); color: var(--ab-accent); }
.status-crashed, .status-failed { background: rgba(164, 22, 26, 0.15); color: var(--ab-danger); }
.status-awaiting_reply { background: rgba(199, 125, 0, 0.15); color: var(--ab-warning); }
.status-canceled, .status-expired { background: rgba(168, 179, 189, 0.15); color: var(--ab-text-muted); }

/* ----------------------------------------------------------------
   Integrity badges
   ---------------------------------------------------------------- */
.badge-verified {
    display: inline-block;
    padding: 0.2rem 0.75rem;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 700;
    background: rgba(30, 126, 52, 0.15);
    color: var(--ab-success);
}

.badge-warning {
    display: inline-block;
    padding: 0.2rem 0.75rem;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 700;
    background: rgba(199, 125, 0, 0.15);
    color: var(--ab-warning);
}

.badge-failed {
    display: inline-block;
    padding: 0.2rem 0.75rem;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 700;
    background: rgba(164, 22, 26, 0.15);
    color: var(--ab-danger);
}

/* ----------------------------------------------------------------
   Pagination
   ---------------------------------------------------------------- */
.pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.pagination a { color: var(--ab-accent); }
.pagination span { color: var(--ab-text-muted); }

/* Result count */
.result-count {
    color: var(--ab-text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

/* ----------------------------------------------------------------
   Links
   ---------------------------------------------------------------- */
a { color: var(--ab-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ----------------------------------------------------------------
   Notice box
   ---------------------------------------------------------------- */
.notice {
    background: var(--ab-panel);
    border: 1px solid var(--ab-border);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1rem 0;
}

.notice h3 { margin-bottom: 0.75rem; }

.notice pre, pre.code-hint {
    background: var(--ab-bg);
    border: 1px solid var(--ab-border);
    border-radius: 4px;
    padding: 0.75rem;
    margin-top: 0.75rem;
    font-family: var(--ab-mono);
    font-size: 0.85rem;
    overflow-x: auto;
}

/* ----------------------------------------------------------------
   Details / summary
   ---------------------------------------------------------------- */
details { margin: 0.25rem 0; }

summary {
    cursor: pointer;
    color: var(--ab-accent);
    font-size: 0.85rem;
}

summary:hover { text-decoration: underline; }

details pre {
    background: var(--ab-bg);
    border: 1px solid var(--ab-border);
    border-radius: 4px;
    padding: 0.75rem;
    margin-top: 0.5rem;
    font-family: var(--ab-mono);
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
}

code {
    font-family: var(--ab-mono);
    font-size: 0.85rem;
    background: var(--ab-bg);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    word-break: break-all;
}

/* ----------------------------------------------------------------
   Verify button
   ---------------------------------------------------------------- */
.verify-action {
    margin: 1.5rem 0;
    display: flex;
    align-items: center;
    gap: 1rem;
}

button {
    background: var(--ab-panel);
    color: var(--ab-accent);
    border: 1px solid var(--ab-border);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--ab-font);
}

button:hover { background: var(--ab-panel-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.verify-ok { color: var(--ab-success); font-weight: 600; }
.verify-error { color: var(--ab-danger); font-weight: 600; }
.verify-warning { color: var(--ab-warning); font-weight: 600; }

/* ----------------------------------------------------------------
   Error list
   ---------------------------------------------------------------- */
.error-list {
    list-style: none;
    margin: 0.5rem 0;
}

.error-list li {
    background: rgba(164, 22, 26, 0.1);
    border-left: 3px solid var(--ab-danger);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    font-family: var(--ab-mono);
    font-size: 0.85rem;
}

/* Empty state */
.empty { color: var(--ab-text-muted); font-style: italic; }

/* ----------------------------------------------------------------
   Auto-refresh indicator
   ---------------------------------------------------------------- */
.auto-refresh-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--ab-success);
}

.auto-refresh-indicator .pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ab-success);
    animation: pulse-anim 2s ease-in-out infinite;
}

@keyframes pulse-anim {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Hamburger menu button — hidden on desktop */
.nav-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--ab-border);
    color: var(--ab-text);
    padding: 0.4rem 0.6rem;
    font-size: 1.2rem;
    line-height: 1;
    border-radius: 4px;
    cursor: pointer;
}

/* Table responsive wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ----------------------------------------------------------------
   Footer
   ---------------------------------------------------------------- */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--ab-text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--ab-border);
    margin-top: 3rem;
}

/* ----------------------------------------------------------------
   Responsive — Tablet (max-width: 768px)
   ---------------------------------------------------------------- */
@media (max-width: 768px) {
    /* Nav collapses */
    nav {
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .nav-toggle { display: inline-block; }

    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--ab-border);
    }

    .nav-links.open { display: flex; }

    .nav-links a,
    .nav-links .nav-btn {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Main content */
    main { padding: 1rem; }

    /* Stats grid: 2 columns */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Filter bar: wrap with full-width inputs */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-input,
    .filter-select {
        min-width: 0;
        width: 100%;
    }

    /* Touch targets */
    button, .nav-btn, .filter-btn {
        min-height: 44px;
        padding: 0.5rem 1rem;
    }

    a {
        padding: 0.25rem 0;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .pagination a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        padding: 0.25rem 0.5rem;
    }
}

/* ----------------------------------------------------------------
   Responsive — Phone (max-width: 480px)
   ---------------------------------------------------------------- */
@media (max-width: 480px) {
    /* Stats grid: single column */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Smaller headings */
    h1 { font-size: 1.2rem; }
    h2 { font-size: 1rem; }

    /* Detail tables stack */
    .detail-table th {
        width: auto;
        white-space: normal;
    }

    /* Reduce padding */
    main { padding: 0.75rem; }

    th, td {
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    .stat-value { font-size: 1.5rem; }
    .stat-label { font-size: 0.75rem; }
}
