/*
 * IMEI Admin -- app.css
 * Implements the approved UI-SPEC design tokens (01-UI-SPEC.md):
 * spacing scale, typography (2 weights only), color (WCAG AA-verified
 * status + accent palette), focus ring, card grid, neutral banners,
 * problem-list rows, and 44px minimum touch targets for icon-only
 * controls. No CDN references, no @import of third-party stylesheets --
 * this file plus the self-hosted bootstrap.min.css are the entire CSS
 * surface, keeping CSP 'self' intact.
 */

:root {
    /* Spacing scale (multiples of 4) */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Touch target minimum for icon-only controls (WCAG 2.5.5) */
    --touch-target: 44px;

    /* Typography: 2 weights only (400 regular, 600 semibold) */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --text-label: 14px;
    --text-body: 16px;
    --text-heading: 20px;
    --text-display: 28px;
    --weight-regular: 400;
    --weight-semibold: 600;

    /* Color: dominant/secondary/accent/destructive */
    --color-page: #FFFFFF;
    --color-surface: #F1F3F4;
    --color-accent: #185ABC;
    --color-destructive: #C5221F;
    --color-text: #202124;

    /* Status colors (icon + color + text together, never color alone) */
    --color-healthy: #137333;
    --color-warning: #9A5700;
    --color-warning-tint: #FEF7E0;
    --color-critical: #C5221F;
    --color-unknown: #5F6368;
    --color-disabled: #5F6368;
    --color-maintenance: #1967D2;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--color-page);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--text-body);
    font-weight: var(--weight-regular);
    line-height: 1.5;
}

h1,
h2,
h3 {
    font-weight: var(--weight-semibold);
    line-height: 1.2;
    margin: 0 0 var(--space-md) 0;
}

h1.heading,
h2.heading,
h3.heading {
    font-size: var(--text-heading);
}

code,
.mono {
    font-family: var(--font-mono);
}

a {
    color: var(--color-accent);
}

/* Focus ring: accent color on every interactive element */
a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Visually-hidden: clip-to-1px-offscreen, kept in the accessibility tree
   (never display:none, which removes it entirely). */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------------------------------------------------------------------- */
/* Top nav */
/* ---------------------------------------------------------------------- */

.app-nav {
    background: var(--color-surface);
    padding: 0 var(--space-lg);
}

.app-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    min-height: var(--touch-target);
    gap: var(--space-md);
}

.app-nav-wordmark {
    font-size: var(--text-heading);
    font-weight: var(--weight-semibold);
}

.app-nav-links {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.app-nav-link {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch-target);
    font-size: var(--text-label);
    font-weight: var(--weight-regular);
    text-decoration: none;
    color: var(--color-text);
    border-bottom: 2px solid transparent;
    background: none;
    border-left: none;
    border-right: none;
    border-top: none;
    padding: 0;
    cursor: pointer;
}

.app-nav-link-active {
    font-weight: var(--weight-semibold);
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

.app-nav-logout {
    display: inline-flex;
    margin: 0;
}

.app-nav-logout-button {
    font-family: inherit;
}

/* Mobile nav disclosure: hidden by default (desktop), shown <768px */
.nav-disclosure {
    display: none;
}

.nav-disclosure summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-target);
    height: var(--touch-target);
    cursor: pointer;
    list-style: none;
}

.nav-disclosure summary::-webkit-details-marker {
    display: none;
}

.nav-disclosure-links {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-sm) 0 var(--space-md) 0;
}

@media (max-width: 767px) {
    .app-nav-links {
        display: none;
    }

    .nav-disclosure {
        display: block;
    }
}

/* ---------------------------------------------------------------------- */
/* Icons */
/* ---------------------------------------------------------------------- */

.icon {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
}

/* ---------------------------------------------------------------------- */
/* Status badges -- icon + color + text together, never color alone */
/* ---------------------------------------------------------------------- */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--text-label);
    font-weight: var(--weight-semibold);
}

.status-badge-text {
    font-weight: var(--weight-semibold);
}

.status-healthy {
    color: var(--color-healthy);
}

.status-warning {
    color: var(--color-warning);
}

.status-critical {
    color: var(--color-critical);
}

.status-unknown {
    color: var(--color-unknown);
}

.status-disabled {
    color: var(--color-disabled);
}

.status-maintenance {
    color: var(--color-maintenance);
}

/* ---------------------------------------------------------------------- */
/* Neutral banners (staleness / session-expired) -- gray-blue, never
   red/amber: these signal data freshness, not a target failure. */
/* ---------------------------------------------------------------------- */

.banner {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: 4px;
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-md);
    font-size: var(--text-label);
}

.banner .icon {
    color: #1967D2;
}

/* ---------------------------------------------------------------------- */
/* Problem list */
/* ---------------------------------------------------------------------- */

.problem-list {
    margin: 0 0 var(--space-xl) 0;
    padding: 0;
    list-style: none;
}

.problem-list-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--color-surface);
}

.problem-list-group + .problem-list-group {
    border-top: 1px solid var(--color-surface);
    margin-top: var(--space-md);
    padding-top: var(--space-md);
}

/* ---------------------------------------------------------------------- */
/* Card grid: 1 col <768px, 2 cols 768-1199px, 3-4 cols >=1200px */
/* ---------------------------------------------------------------------- */

.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
}

@media (min-width: 768px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1200px) {
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.card {
    background: var(--color-surface);
    border-radius: 4px;
    padding: var(--space-md);
}

.card-heading {
    font-size: var(--text-heading);
    font-weight: var(--weight-semibold);
}

/* ---------------------------------------------------------------------- */
/* Empty states */
/* ---------------------------------------------------------------------- */

.empty-state {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
}

/* ---------------------------------------------------------------------- */
/* Icon-only controls: 44x44px minimum touch target (visual icon stays
   16-24px; padding pads out the hit area). */
/* ---------------------------------------------------------------------- */

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-target);
    height: var(--touch-target);
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
}

/* ---------------------------------------------------------------------- */
/* Guest layout (login page) */
/* ---------------------------------------------------------------------- */

.guest-body {
    background: var(--color-page);
}

.guest-main {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-3xl) var(--space-lg);
}

.guest-card {
    width: 100%;
    max-width: 400px;
    background: var(--color-surface);
    border-radius: 8px;
    padding: var(--space-xl);
}

.guest-wordmark {
    font-size: var(--text-display);
    font-weight: var(--weight-semibold);
    text-align: center;
    margin-bottom: var(--space-lg);
}

/* ---------------------------------------------------------------------- */
/* Projects (01-20): page header, buttons, forms, table/stacked-list      */
/* toggle, confirmation dialog -- extends the tokens above. No new        */
/* colors are introduced; every value below reuses the existing custom    */
/* properties (01-20 deviation: 01-06 shipped tokens/nav/cards/badges     */
/* only, not buttons/forms/tables, which this plan is the first to need). */
/* ---------------------------------------------------------------------- */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch-target);
    padding: var(--space-sm) var(--space-md);
    border-radius: 4px;
    border: 1px solid transparent;
    font-size: var(--text-label);
    font-weight: var(--weight-semibold);
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary {
    background: var(--color-accent);
    color: #FFFFFF;
}

.btn-destructive {
    background: var(--color-destructive);
    color: #FFFFFF;
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-surface);
}

.field-group {
    margin-bottom: var(--space-md);
}

.field-label {
    display: block;
    font-size: var(--text-label);
    font-weight: var(--weight-semibold);
    margin-bottom: var(--space-xs);
}

.field-check {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--text-label);
}

.field-input,
.field-select,
.field-textarea {
    width: 100%;
    max-width: 480px;
    padding: var(--space-sm);
    border: 1px solid var(--color-surface);
    border-radius: 4px;
    font-size: var(--text-body);
    font-family: inherit;
}

.field-error {
    color: var(--color-destructive);
    font-size: var(--text-label);
    margin-top: var(--space-xs);
}

.form-errors {
    background: var(--color-surface);
    border-left: 4px solid var(--color-destructive);
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
}

.form-section {
    background: var(--color-surface);
    border-radius: 4px;
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
}

.form-section summary {
    font-size: var(--text-heading);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
}

.review-list dt {
    font-weight: var(--weight-semibold);
    margin-top: var(--space-sm);
}

.review-list dd {
    margin: 0 0 0 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-surface);
}

.row-actions {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
}

.row-action-form {
    display: inline-flex;
    margin: 0;
}

.monitor-list {
    list-style: none;
    padding: 0;
    margin: 0 0 var(--space-md) 0;
}

.monitor-list li {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) 0;
    border-bottom: 1px solid #FFFFFF;
}

.confirm-dialog {
    max-width: 480px;
}

/* Desktop table / mobile stacked-card-list toggle (reuses .card/.card-grid
   from 01-06, not a parallel component). */
@media (max-width: 767px) {
    .table-desktop {
        display: none;
    }
}

@media (min-width: 768px) {
    .stacked-list {
        display: none;
    }
}
