/* ============================================================================
   DataCar — single shared stylesheet
   ----------------------------------------------------------------------------
   Every page links this file. Reusable components (public/js/components/*.js)
   also inject a <link> to it inside their shadow roots, so chrome rendered by
   a component is styled by the exact same rules as the page light-DOM content.

   SECURITY NOTE: component markup (logo.js, lang-switcher.js, etc.) is
   ALWAYS static, server-controlled strings. Never build component innerHTML /
   shadow content from user or upstream data — that is the one rule that keeps
   web components injection-safe (see SESSION_NOTES).
   ========================================================================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #0b1120;
    color: #e0e0e0;
    min-height: 100vh;
}

/* Page-specific body padding (single shared stylesheet, scoped by body class) */
body.page-sites { padding: 20px; }
body.page-admin { padding: 20px; }

a { color: inherit; }

/* ---------------------------------------------------------------------------
   2. Buttons (shared)
--------------------------------------------------------------------------- */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    display: inline-block;
    font-weight: 500;
    transition: all 0.2s;
}
.btn-primary { background: #3b82f6; color: white; }
.btn-primary:hover { background: #2563eb; }
.btn-danger { background: #dc3545; color: white; }
.btn-danger:hover { background: #c82333; }
.btn-secondary { background: #1e2130; color: #9ca3af; border: 1px solid #2d3148; }
.btn-secondary:hover { background: #2d3148; color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---------------------------------------------------------------------------
   3. Language switcher (shared) — used by <dc-lang-switcher> and pages
--------------------------------------------------------------------------- */
.lang-switcher {
    display: flex;
    gap: 2px;
    background: #1e2130;
    border-radius: 6px;
    padding: 2px;
}
.lang-btn {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #9ca3af;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.lang-btn:hover { color: white; }
.lang-btn.active { background: #3b82f6; color: white; }

/* ---------------------------------------------------------------------------
   4. Layout container
--------------------------------------------------------------------------- */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ---------------------------------------------------------------------------
   5. Home marketing site-nav (<dc-site-nav>)
--------------------------------------------------------------------------- */
nav.site-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    background: rgba(22, 24, 34, 0.95);
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 3px solid #3b82f6;
    /* biome-ignore lint/suspicious/noDuplicateProperties: pre-existing — intentionally NOT sticky (relative wins); leave as-is, flagged for future review */
    position: relative;
    overflow: hidden;
}
nav.site-nav::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 3px;
    background: repeating-linear-gradient(
        90deg,
        #3b82f6 0px,
        #3b82f6 12px,
        #1e40af 12px,
        #1e40af 24px
    );
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: white;
}
.nav-brand span {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.nav-links {
    display: flex;
    gap: 16px;
    align-items: center;
}
.nav-links a {
    color: #9ca3af;
    text-decoration: none;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.2s;
}
.nav-links a:hover { color: white; background: #1e2130; }
.btn-login {
    background: #3b82f6 !important;
    color: white !important;
    font-weight: 500;
}
.btn-login:hover { background: #2563eb !important; }
.site-nav .lang-switcher { background: #1e2130; margin-left: 8px; }

/* ---------------------------------------------------------------------------
   6. App header (<dc-app-header>) — iframe wrapper top bar (index.html)
--------------------------------------------------------------------------- */
header.app-header {
    background: #161822;
    color: white;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid #1e2130;
    min-height: 56px;
}
header.app-header a {
    color: #9ca3af;
    text-decoration: none;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.2s;
}
header.app-header a:hover { color: white; background: #1e2130; }
header.app-header .brand {
    color: white;
    font-weight: 600;
    font-size: 15px;
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}
.app-frame { flex-grow: 1; border: none; width: 100%; background: white; }

/* App wrapper layout: top bar takes its natural height (~5-8% of viewport),
   the proxied site gets every remaining pixel. Without the fixed-height flex
   column, flex-grow on .app-frame has no effect and the iframe collapses to
   its browser-default ~150px. */
body.page-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    /* biome-ignore lint/suspicious/noDuplicateProperties: intentional dvh progressive-enhancement fallback */
    height: 100dvh; /* mobile: exclude dynamic browser chrome */
    overflow: hidden; /* the iframe scrolls internally */
}

/* ---------------------------------------------------------------------------
   7. Page header (<dc-page-header>) — sites/admin card header
--------------------------------------------------------------------------- */
header.page-header {
    background: #161822;
    color: white;
    padding: 20px 24px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #1e2130;
    border-bottom: none;
    position: relative;
    overflow: hidden;
}
header.page-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: repeating-linear-gradient(
        90deg,
        #3b82f6 0px,
        #3b82f6 12px,
        #1e40af 12px,
        #1e40af 24px
    );
}
header.page-header h1 { font-size: 20px; font-weight: 600; }
.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}
.page-header .lang-switcher { background: #0f1117; }

/* ---------------------------------------------------------------------------
   8. Main content card (<dc-main>)
--------------------------------------------------------------------------- */
main.main-content {
    background: #161822;
    padding: 30px;
    border-radius: 0 0 12px 12px;
    border: 1px solid #1e2130;
    border-top: none;
}
main.main-content.admin-main { padding: 0; }
/* Content is SLOTTED light-DOM inside <dc-main>; root the selector at the
   light-DOM host (not the shadow <main>) so the descendant combinator matches. */
dc-main:not([admin]) h2 {
    color: #e0e0e0;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #1e2130;
    font-size: 18px;
}

/* ---------------------------------------------------------------------------
   9. Footer (<dc-footer>)
--------------------------------------------------------------------------- */
footer.page-footer {
    text-align: center;
    padding: 24px;
    color: #4b5563;
    font-size: 13px;
    border-top: 1px solid #1e2130;
}

/* ---------------------------------------------------------------------------
   10. Home hero
--------------------------------------------------------------------------- */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 100px 20px 80px;
    max-width: 800px;
    margin: 0 auto;
}
.hero-logo { margin-bottom: 32px; }
.hero h1 {
    font-size: 48px;
    font-weight: 800;
    color: white;
    margin-bottom: 16px;
    letter-spacing: -1px;
    line-height: 1.1;
}
.hero h1 em { font-style: normal; color: #3b82f6; }
.hero p {
    font-size: 18px;
    color: #9ca3af;
    max-width: 560px;
    line-height: 1.6;
    margin-bottom: 40px;
}
.hero-cta { display: flex; gap: 16px; }
.hero-cta a {
    padding: 14px 32px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}
.cta-primary { background: #3b82f6; color: white; }
.cta-primary:hover { background: #2563eb; transform: translateY(-1px); }
.cta-secondary { background: #1e2130; color: #e0e0e0; border: 1px solid #2d3148; }
.cta-secondary:hover { background: #2d3148; }

/* ---------------------------------------------------------------------------
   11. Home features
--------------------------------------------------------------------------- */
.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    max-width: 1000px;
    margin: 0 auto;
    padding: 60px 40px 100px;
}
.feature-card {
    background: #161822;
    border: 1px solid #1e2130;
    border-radius: 12px;
    padding: 32px 24px;
    text-align: center;
    transition: border-color 0.2s;
}
.feature-card:hover { border-color: #3b82f6; }
.feature-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 20px;
    background: #1e2130;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.feature-card h3 { font-size: 18px; color: white; margin-bottom: 8px; }
.feature-card p { font-size: 14px; color: #9ca3af; line-height: 1.5; }

/* ---------------------------------------------------------------------------
   12. Sites grid + cards (sites.html)
--------------------------------------------------------------------------- */
.sites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}
.site-card {
    border: 1px solid #1e2130;
    border-radius: 10px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
    background: #0f1117;
}
.site-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}
.site-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 14px;
    background: #1e2130;
    color: #3b82f6;
}
.site-card-name { font-size: 17px; font-weight: 600; color: #e0e0e0; margin-bottom: 6px; }
.site-card-desc { font-size: 14px; color: #6b7280; line-height: 1.4; }

/* ---------------------------------------------------------------------------
   13. Auth cards (login.html / change-password.html)
--------------------------------------------------------------------------- */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}
.auth-card {
    background: #161822;
    padding: 40px;
    border-radius: 12px;
    border: 1px solid #1e2130;
    width: 100%;
    max-width: 400px;
    position: relative;
}
.auth-header { text-align: center; margin-bottom: 32px; }
.auth-header svg { margin-bottom: 16px; }
.auth-card h1 {
    color: #e0e0e0;
    margin-bottom: 6px;
    font-size: 22px;
    font-weight: 600;
}
.auth-subtitle { color: #6b7280; font-size: 14px; }
.auth-card .lang-switcher { position: absolute; top: 16px; right: 16px; }
.auth-card .page-footer { padding: 0; margin-top: 24px; border-top: none; }

/* ---------------------------------------------------------------------------
   14. Forms (shared)
--------------------------------------------------------------------------- */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #9ca3af;
    font-weight: 500;
    font-size: 14px;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 12px 14px;
    background: #0f1117;
    border: 1px solid #1e2130;
    border-radius: 6px;
    font-size: 15px;
    color: #e0e0e0;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus { outline: none; border-color: #3b82f6; }
.form-group input::placeholder { color: #4b5563; }
button[type="submit"].btn-block {
    width: 100%;
    padding: 12px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
button[type="submit"].btn-block:hover { background: #2563eb; }

/* error / success messages (login, change-password) */
.alert { padding: 12px; border-radius: 6px; margin-bottom: 15px; font-size: 14px; }
.alert-success { background: rgba(52, 211, 153, 0.1); color: #34d399; border: 1px solid rgba(52, 211, 153, 0.3); }
.alert-error { background: rgba(248, 113, 113, 0.1); color: #f87171; border: 1px solid rgba(248, 113, 113, 0.3); }
.error-message { background: rgba(220, 53, 69, 0.1); color: #f87171; padding: 12px; border-radius: 6px; margin-bottom: 20px; display: none; border: 1px solid rgba(220, 53, 69, 0.3); font-size: 14px; }
.success-message { background: rgba(52, 211, 153, 0.1); color: #34d399; padding: 12px; border-radius: 6px; margin-bottom: 20px; display: none; border: 1px solid rgba(52, 211, 153, 0.3); font-size: 14px; }
.auth-footer { text-align: center; margin-top: 24px; color: #4b5563; font-size: 13px; }

.password-requirements { margin-top: 8px; font-size: 12px; color: #6b7280; line-height: 1.6; }
.password-requirements .met { color: #34d399; }
.password-requirements .unmet { color: #f87171; }

/* ---------------------------------------------------------------------------
   15. Admin dashboard (admin.html)
--------------------------------------------------------------------------- */
dc-main[admin] .tab-bar {
    display: flex;
    border-bottom: 1px solid #1e2130;
    background: #0f1117;
}
dc-main[admin] .tab-btn {
    padding: 14px 24px;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    white-space: nowrap;
}
dc-main[admin] .tab-btn:hover { color: #e0e0e0; background: rgba(59, 130, 246, 0.05); }
dc-main[admin] .tab-btn.active { color: #3b82f6; background: rgba(59, 130, 246, 0.1); }
dc-main[admin] .tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #3b82f6;
}
dc-main[admin] .tab-content { display: none; padding: 24px; }
dc-main[admin] .tab-content.active { display: block; }

dc-main[admin] .section { margin-bottom: 30px; }
dc-main[admin] .section h2 {
    color: #e0e0e0;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #1e2130;
    font-size: 18px;
}

dc-main[admin] .user-form {
    background: #0f1117;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #1e2130;
    margin-bottom: 20px;
}
dc-main[admin] .form-row { display: flex; gap: 15px; flex-wrap: wrap; }
dc-main[admin] .form-group { flex: 1; min-width: 150px; }
dc-main[admin] .form-group input,
dc-main[admin] .form-group select {
    width: 100%;
    padding: 10px 12px;
    background: #161822;
    border: 1px solid #1e2130;
    border-radius: 6px;
    font-size: 14px;
    color: #e0e0e0;
}
dc-main[admin] .form-group input:focus,
dc-main[admin] .form-group select:focus { outline: none; border-color: #3b82f6; }
dc-main[admin] .form-group select option { background: #161822; }

dc-main[admin] .users-table { width: 100%; border-collapse: collapse; }
dc-main[admin] .users-table th,
dc-main[admin] .users-table td { padding: 12px; text-align: left; border-bottom: 1px solid #1e2130; }
dc-main[admin] .users-table th {
    background: #0f1117;
    font-weight: 600;
    color: #9ca3af;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
dc-main[admin] .users-table tr:hover { background: rgba(59, 130, 246, 0.05); }
.status-active { color: #34d399; }
.status-expired { color: #f87171; }
.status-inactive { color: #6b7280; }
.status-locked { color: #f59e0b; }

/* ============ Inline-style migration vocabulary (SESSION_NOTES #73) ======
   All styling for dynamically rendered (template-literal) markup lives
   HERE, not in style="" attributes — ui.test.js bans style=" under public/.
   .style.x = assignments in JS remain allowed: those are show/hide BEHAVIOR. */

/* Small chips next to usernames (Short-Lived badge, Locked flag) */
.chip-locked, .chip-ephemeral {
    color: #f59e0b;
    border: 1px solid #f59e0b;
    border-radius: 4px;
    padding: 0 4px;
    font-size: 0.75rem;
}

/* Table cell helpers */
.cell-sm { font-size: 12px; }
.cell-muted { color: #6b7280; }
.cell-warn { color: #f59e0b; }
.cell-error { color: #f87171; }
.cell-nowrap { white-space: nowrap; }
.cell-mono { font-family: monospace; }
.cell-ellipsis {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cell-sub { color: #6b7280; font-size: 11px; }   /* secondary id line under a label */
.dot-status { color: #34d399; font-size: 11px; } /* green ok-dot in credential rows */

/* Audit-feed event-type colors (JS maps event -> one of these classes) */
.evt-success, .evt-error, .evt-warn, .evt-muted, .evt-info, .evt-default {
    font-weight: 500;
}
.evt-success { color: #34d399; }
.evt-error { color: #f87171; }
.evt-warn { color: #f59e0b; }
.evt-muted { color: #6b7280; }
.evt-info { color: #3b82f6; }
.evt-default { color: #9ca3af; }

/* Layout/text helpers replacing inline styles in static HTML */
.form-inline { display: inline; }
.hidden { display: none; }
.scroll-x { overflow-x: auto; }
.btn-link {
    background: none;
    border: none;
    color: #6b7280;
    text-decoration: none;
    cursor: pointer;
    padding: 0;
    font: inherit;
}
.alert-container { padding: 12px 24px 0; }
.row-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.row-gap {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}
.filter-row { flex: 0; min-width: auto; display: flex; align-items: flex-end; gap: 10px; }
.filter-label { margin: 0; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.mb-15 { margin-bottom: 15px; }
.help-top { color: #94a3b8; font-size: 0.8rem; margin-top: 10px; }
.help-block { color: #9ca3af; font-size: 0.8rem; margin: 10px 0 15px; }
.help-13 { color: #9ca3af; font-size: 13px; margin-bottom: 15px; }
.help-sm { color: #9ca3af; font-size: 12px; }
.modal-danger { color: #f87171; margin-top: 10px; }
.stats-line { font-size: 13px; color: #6b7280; margin-bottom: 10px; }
.pager-row { display: flex; justify-content: center; gap: 10px; margin-top: 15px; }
.pager-info { font-size: 13px; color: #9ca3af; padding: 5px 10px; }
.plain-link { text-decoration: none; color: inherit; }

/* Standalone (non-app-shell) pages: farewell + proxy error */
.farewell-body { background: #0b1120; }
.farewell-hero { text-align: center; padding: 96px 24px; }
.farewell-title { color: #e0e0e0; }
.farewell-message { color: #9ca3af; margin-top: 12px; }
.farewell-redirect { color: #6b7280; margin-top: 28px; font-size: 14px; }
.error-body { font-family: sans-serif; padding: 40px; background: #0b1120; color: #e5e7eb; }
.error-title { font-size: 18px; color: #f87171; }
.error-message { font-size: 14px; color: #9ca3af; }
/* ======================================================================== */

/* Small status chip for table cells (e.g. Locked next to an ephemeral
   username). Class-based on purpose — no inline styles in JS templates. */
.chip-locked {
    color: #f59e0b;
    border: 1px solid #f59e0b;
    border-radius: 4px;
    padding: 0 4px;
    font-size: 0.75rem;
}
dc-main[admin] .actions { display: flex; gap: 5px; }

dc-main[admin] #usernameFilter {
    padding: 10px 12px;
    width: 100%;
    max-width: 300px;
    background: #0f1117;
    border: 1px solid #1e2130;
    border-radius: 6px;
    font-size: 14px;
    color: #e0e0e0;
}
dc-main[admin] #usernameFilter:focus { outline: none; border-color: #3b82f6; }
dc-main[admin] #usernameFilter::placeholder { color: #4b5563; }

dc-main[admin] .filter-input {
    padding: 8px 12px;
    background: #0f1117;
    border: 1px solid #1e2130;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 13px;
    max-width: 200px;
}
dc-main[admin] .filter-input:focus { outline: none; border-color: #3b82f6; }
dc-main[admin] .filter-input::placeholder { color: #4b5563; }
dc-main[admin] .filter-select {
    padding: 8px 12px;
    background: #0f1117;
    border: 1px solid #1e2130;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 13px;
    max-width: 180px;
}

/* modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
}
.modal-content {
    background: #161822;
    border: 1px solid #1e2130;
    margin: 15% auto;
    padding: 24px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.modal-header h3 { color: #e0e0e0; font-size: 18px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #6b7280; transition: color 0.2s; }
.modal-close:hover { color: #e0e0e0; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-content .form-group label { color: #9ca3af; }

/* ---------------------------------------------------------------------------
   16. Logo host
--------------------------------------------------------------------------- */
dc-logo { display: inline-flex; align-items: center; }
