/*
 * Dashboard styles. Colours, type, radii and shadows mirror the marketing
 * site's design tokens (website/marketing: app/globals.css and
 * tailwind.config.ts) so the dashboard looks like part of the same product.
 * Change a colour there, change it here too.
 */

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
}

:root {
    color-scheme: light;
    --background: 255 255 255;
    --surface: 255 255 255;
    --surface-muted: 248 250 252;
    --border: 226 232 240;
    --foreground: 15 23 42;
    --accent: 79 70 229;
    --accent-foreground: 255 255 255;
    --accent-muted: 199 210 254;
    --success: 22 163 74;
    --danger: 220 38 38;
    --warning: 217 119 6;
    --shadow-soft: 0 1px 2px rgb(0 0 0 / 0.04), 0 8px 24px rgb(0 0 0 / 0.06);
}

/* Dark theme: follows the OS unless the header toggle picked one (theme.js). */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --background: 2 6 23;
        --surface: 15 23 42;
        --surface-muted: 30 41 59;
        --border: 51 65 85;
        --foreground: 241 245 249;
        --accent: 129 140 248;
        --accent-foreground: 15 23 42;
        --accent-muted: 67 56 202;
        --success: 74 222 128;
        --danger: 248 113 113;
        --warning: 251 191 36;
        --shadow-soft: 0 1px 2px rgb(0 0 0 / 0.2), 0 8px 24px rgb(0 0 0 / 0.35);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --background: 2 6 23;
    --surface: 15 23 42;
    --surface-muted: 30 41 59;
    --border: 51 65 85;
    --foreground: 241 245 249;
    --accent: 129 140 248;
    --accent-foreground: 15 23 42;
    --accent-muted: 67 56 202;
    --success: 74 222 128;
    --danger: 248 113 113;
    --warning: 251 191 36;
    --shadow-soft: 0 1px 2px rgb(0 0 0 / 0.2), 0 8px 24px rgb(0 0 0 / 0.35);
}

/* ---- Base ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background: rgb(var(--background));
    color: rgb(var(--foreground));
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p, dl, dd { margin: 0; }

a { color: rgb(var(--accent)); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid rgb(var(--accent)); outline-offset: 2px; }

code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

code {
    font-size: 0.8125rem;
    background: rgb(var(--surface-muted));
    border: 1px solid rgb(var(--border));
    border-radius: 0.25rem;
    padding: 0.05rem 0.35rem;
    overflow-wrap: anywhere;
}

.is-hidden { display: none !important; }

.skip-link {
    position: absolute;
    left: 1rem;
    top: -3rem;
    z-index: 50;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    background: rgb(var(--accent));
    color: rgb(var(--accent-foreground));
    font-size: 0.875rem;
    font-weight: 500;
}
.skip-link:focus { top: 0.75rem; }

/* ---- Header -------------------------------------------------------------- */

.container {
    margin: 0 auto;
    width: 100%;
    max-width: 72rem;
    padding: 0 1rem;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid rgb(var(--border));
    background: rgb(var(--surface) / 0.9);
    backdrop-filter: blur(8px);
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    height: 3.5rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    border-radius: 0.375rem;
}
.brand img { display: block; height: 2rem; width: auto; }

.header-actions { display: flex; align-items: center; gap: 0.5rem; }
.header-actions form { margin: 0; }

.user-name {
    display: none;
    font-size: 0.875rem;
    color: rgb(var(--foreground) / 0.6);
}

/* ---- Layout -------------------------------------------------------------- */

.app-main {
    margin: 0 auto;
    width: 100%;
    max-width: 72rem;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.content {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidenav {
    border: 1px solid rgb(var(--border));
    border-radius: 0.75rem;
    background: rgb(var(--surface));
    padding: 0.75rem;
}
.sidenav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
.sidenav a {
    display: block;
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: rgb(var(--foreground) / 0.8);
}
.sidenav a:hover { background: rgb(var(--surface-muted)); color: rgb(var(--foreground)); text-decoration: none; }
.sidenav a[aria-current="page"] { background: rgb(var(--accent-muted) / 0.35); color: rgb(var(--accent)); }

@media (min-width: 640px) {
    .container, .app-main { padding-left: 1.5rem; padding-right: 1.5rem; }
    .user-name { display: inline; }
}

@media (min-width: 1024px) {
    .container { padding-left: 2rem; padding-right: 2rem; }
    .app-main { flex-direction: row; padding: 2rem; }
    .sidebar { width: 14rem; flex-shrink: 0; }
}

/* ---- Page heading -------------------------------------------------------- */

.page-head h1 {
    font-size: 1.5rem;
    line-height: 2rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}
.page-head p {
    margin-top: 0.5rem;
    max-width: 42rem;
    font-size: 0.875rem;
    color: rgb(var(--foreground) / 0.75);
}

/* ---- Cards --------------------------------------------------------------- */

.card {
    border: 1px solid rgb(var(--border));
    border-radius: 0.75rem;
    background: rgb(var(--surface));
    box-shadow: var(--shadow-soft);
    padding: 1.5rem;
}
.card h2 { font-size: 1.125rem; line-height: 1.75rem; font-weight: 600; }
.card-text { margin-top: 0.5rem; font-size: 0.875rem; color: rgb(var(--foreground) / 0.7); }

.card-grid { display: grid; gap: 1.5rem; }

.stat-grid { display: grid; gap: 1rem; }
.stat { padding: 1rem; }
.stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgb(var(--foreground) / 0.5);
}
.stat-value {
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    line-height: 2rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.stat-sub { margin-top: 0.25rem; font-size: 0.75rem; color: rgb(var(--foreground) / 0.5); }

.cta-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-color: rgb(var(--accent-muted));
    background: linear-gradient(135deg, rgb(var(--accent-muted) / 0.25), rgb(var(--surface)) 60%);
}

@media (min-width: 640px) {
    .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .cta-card { flex-direction: row; align-items: center; justify-content: space-between; }
}

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

.status-dot {
    display: inline-block;
    flex-shrink: 0;
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 999px;
    background: rgb(var(--foreground) / 0.3);
}
.status-dot.active { background: rgb(var(--success)); box-shadow: 0 0 0 3px rgb(var(--success) / 0.2); }
.status-dot.inactive { background: rgb(var(--danger)); box-shadow: 0 0 0 3px rgb(var(--danger) / 0.2); }

.details {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 0.5rem 1.5rem;
    font-size: 0.875rem;
}
.details dt { color: rgb(var(--foreground) / 0.6); }
.details dd { min-width: 0; }

/* ---- Buttons ------------------------------------------------------------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 2.5rem;
    padding: 0 1rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s, opacity 0.15s;
}
.button:hover { text-decoration: none; }
.button:disabled { opacity: 0.5; pointer-events: none; }

.button-primary, .button.is-primary {
    background: rgb(var(--accent));
    color: rgb(var(--accent-foreground));
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}
.button-primary:hover, .button.is-primary:hover { opacity: 0.95; }

.button-secondary {
    border-color: rgb(var(--border));
    background: rgb(var(--surface-muted));
    color: rgb(var(--foreground));
}
.button-secondary:hover { background: rgb(var(--surface-muted) / 0.8); }

.button-ghost { background: transparent; color: rgb(var(--foreground)); }
.button-ghost:hover { background: rgb(var(--surface-muted)); }

.button-sm { height: 2.25rem; padding: 0 0.75rem; }
.button-lg { height: 2.75rem; padding: 0 1.5rem; font-size: 1rem; }
.button-block { width: 100%; }
.icon-button { width: 2.5rem; padding: 0; font-size: 1.125rem; }

.button-row { margin-top: 1.25rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.button-row form { margin: 0; }

/* ---- Alerts -------------------------------------------------------------- */

.messages { display: grid; gap: 0.75rem; }

.alert, .notification {
    border: 1px solid rgb(var(--border));
    border-left-width: 4px;
    border-left-color: rgb(var(--accent));
    border-radius: 0.5rem;
    background: rgb(var(--surface));
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
}
.card > .alert { margin-top: 1rem; }
.alert-success { border-left-color: rgb(var(--success)); }
.alert-error, .alert-danger { border-left-color: rgb(var(--danger)); }
.alert-warning { border-left-color: rgb(var(--warning)); }

/* ---- Forms --------------------------------------------------------------- */

.form-grid { display: grid; gap: 1.5rem; }
@media (min-width: 900px) {
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

.field { margin-top: 1rem; }
.field > label { display: block; font-size: 0.875rem; font-weight: 500; }

.input,
.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea {
    display: block;
    margin-top: 0.5rem;
    width: 100%;
    height: 2.5rem;
    padding: 0 0.75rem;
    border: 1px solid rgb(var(--border));
    border-radius: 0.375rem;
    background: rgb(var(--surface));
    color: rgb(var(--foreground));
    font: inherit;
    font-size: 0.875rem;
}
.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: 2px solid rgb(var(--accent));
    outline-offset: 0;
    border-color: transparent;
}
.field input.is-danger { border-color: rgb(var(--danger)); }

.checkbox-field > label {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
}
input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: rgb(var(--accent));
}

.help { margin-top: 0.375rem; font-size: 0.75rem; color: rgb(var(--foreground) / 0.6); }
.field-error { margin-top: 0.375rem; font-size: 0.75rem; color: rgb(var(--danger)); }

.form-actions { margin-top: 1.5rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ---- Logs ---------------------------------------------------------------- */

.status-card { display: flex; align-items: center; gap: 1rem; border-left-width: 4px; }
.status-card .status-dot { width: 0.75rem; height: 0.75rem; }
.status-ok { border-left-color: rgb(var(--success)); }
.status-warning { border-left-color: rgb(var(--warning)); }
.status-error { border-left-color: rgb(var(--danger)); }
.status-dot.warning { background: rgb(var(--warning)); box-shadow: 0 0 0 3px rgb(var(--warning) / 0.2); }

.event-list { list-style: none; margin: 1rem 0 0; padding: 0; }
.event {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.25rem 0.75rem;
    padding: 0.875rem 0;
    border-top: 1px solid rgb(var(--border));
}
.event:first-child { border-top: 0; padding-top: 0.25rem; }
.event-dot {
    margin-top: 0.45rem;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 999px;
    background: rgb(var(--foreground) / 0.3);
}
.event-warning .event-dot { background: rgb(var(--warning)); }
.event-error .event-dot { background: rgb(var(--danger)); }
.event-title { font-size: 0.875rem; font-weight: 500; }
.event-hint { margin-top: 0.125rem; font-size: 0.8125rem; color: rgb(var(--foreground) / 0.65); }
.event-when {
    grid-column: 2;
    font-size: 0.75rem;
    color: rgb(var(--foreground) / 0.5);
    font-variant-numeric: tabular-nums;
}

@media (min-width: 640px) {
    .event { grid-template-columns: auto minmax(0, 1fr) auto; }
    .event-when { grid-column: 3; text-align: right; }
}

/* ---- Sign-in and setup pages --------------------------------------------- */

.auth-main {
    min-height: calc(100vh - 3.5rem);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 1rem;
}
.auth-card { width: 100%; max-width: 28rem; padding: 2rem; }
.auth-card h1 { text-align: center; font-size: 1.5rem; line-height: 2rem; font-weight: 600; }
.auth-card .lead { margin-top: 0.5rem; text-align: center; font-size: 0.875rem; color: rgb(var(--foreground) / 0.7); }
.auth-card .messages, .auth-card .alert { margin-top: 1.5rem; }
.auth-card form { margin-top: 1.5rem; }
.auth-card form .button,
.auth-card .details + .button { margin-top: 1.5rem; }
.auth-card .footnote { margin-top: 1.5rem; text-align: center; font-size: 0.75rem; color: rgb(var(--foreground) / 0.6); }

.auth-card .footnote a { font-weight: 500; }
.auth-card .workspace-action { margin-top: 1.5rem; }
.auth-card form.workspace-action .button { margin-top: 0; }

.workspace-status {
    margin-top: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}
.power-actions { margin-top: 0.75rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.auth-card .power-actions form { margin-top: 0; }
.auth-card .power-actions form .button { margin-top: 0; }

/* Billing box on the workspace page */
.plan {
    margin-top: 1.5rem;
    padding: 1rem;
    border: 1px solid rgb(var(--border));
    border-radius: 0.5rem;
    background: rgb(var(--surface-muted));
}
.plan-title { font-size: 0.875rem; font-weight: 600; }
.plan-text { margin-top: 0.25rem; font-size: 0.875rem; color: rgb(var(--foreground) / 0.7); }
.auth-card .plan form { margin-top: 1rem; }
.auth-card .plan form .button { margin-top: 0; }

.progress {
    display: block;
    margin-top: 1.5rem;
    width: 100%;
    height: 0.5rem;
    border: 0;
    border-radius: 999px;
    overflow: hidden;
    background: rgb(var(--surface-muted));
    accent-color: rgb(var(--accent));
}

/* ---- Remote desktop ------------------------------------------------------ */

.desktop-main { padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.desktop-frame {
    display: block;
    width: 100%;
    height: calc(100vh - 3.5rem - 4.75rem);
    min-height: 30rem;
    border: 1px solid rgb(var(--border));
    border-radius: 0.75rem;
    background: #000;
}

/* ---- Account pages ----------------------------------------------------------- */

.auth-card .account-details { margin-top: 1.5rem; }
.vm-details { margin-top: 0.75rem; }
.mfa-qr {
    display: block;
    margin: 1.5rem auto 0;
    width: 200px;
    height: 200px;
    border-radius: 0.5rem;
    background: #fff; /* scanners need the light background even in dark mode */
}
