/* =============================================================================
 * Dialer testing suite — shared design system
 *
 * All pages (login, dashboard, test, agent, health) pull this single file.
 * Tokens live at :root so components can be themed without duplicating values.
 * =============================================================================
 */

:root {
    /* surfaces */
    --surface-0: #0d1117;       /* app bg */
    --surface-1: #10151d;       /* raised bg (behind cards) */
    --surface-2: #161b22;       /* card bg */
    --surface-3: #1f242c;       /* hover / selected */
    --surface-4: #262c36;       /* deeper */
    --surface-inset: #0a0d13;   /* inputs, log boxes */

    /* borders */
    --border-subtle: #21262d;
    --border: #30363d;
    --border-strong: #484f58;

    /* text */
    --text-primary: #f0f6fc;
    --text: #e1e4e8;
    --text-muted: #8b949e;
    --text-faint: #6e7681;
    --text-inverse: #0d1117;

    /* accents */
    --accent: #1f6feb;
    --accent-hover: #388bfd;
    --accent-soft: rgba(56, 139, 253, 0.18);
    --accent-ring: rgba(56, 139, 253, 0.35);

    --success: #238636;
    --success-hover: #2ea043;
    --success-soft: rgba(63, 185, 80, 0.15);
    --success-fg: #3fb950;

    --warn: #d29922;
    --warn-soft: rgba(210, 153, 34, 0.15);
    --warn-fg: #e3b341;

    --danger: #da3633;
    --danger-hover: #f85149;
    --danger-soft: rgba(248, 81, 73, 0.12);
    --danger-fg: #ff7b72;

    /* layout */
    --radius-sm: 4px;
    --radius: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 6px 18px rgba(0, 0, 0, 0.32);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.38);

    --shell-max: 1220px;

    /* motion */
    --ease: cubic-bezier(0.2, 0, 0.2, 1);
    --motion-fast: 120ms;
    --motion: 180ms;
}

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

html {
    background: var(--surface-0);
}

body.suite-body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--surface-0);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

code, kbd, pre {
    font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Fira Code', Menlo, monospace;
}

/* -----------------------------------------------------------------------------
 * Top navigation
 * --------------------------------------------------------------------------- */

.nav-top {
    position: sticky;
    top: 0;
    z-index: 80;
    background: rgba(13, 17, 23, 0.9);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.28);
}

.nav-inner {
    max-width: var(--shell-max);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem 1.25rem;
    padding: 0.7rem 1.25rem;
    flex-wrap: wrap;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.nav-brand .product {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.nav-brand .badge-brand {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #d29922;
    background: linear-gradient(180deg, #4d3a00 0%, #3b2e00 100%);
    border: 1px solid rgba(154, 103, 0, 0.65);
    border-radius: 6px;
    padding: 0.18rem 0.5rem;
}

.nav-cluster {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: #010409;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

.nav-link,
.nav-link:link,
.nav-link:visited {
    display: inline-block;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius);
    font-size: 0.81rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid transparent;
    transition: color var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease);
}

.nav-link:hover {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--border);
}

.nav-link:focus-visible {
    outline: 2px solid var(--accent-hover);
    outline-offset: 2px;
}

.nav-link.active,
.nav-link.active:link,
.nav-link.active:visited {
    color: var(--text-primary);
    background: var(--accent);
    border-color: var(--accent-hover);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Account dropdown */

.nav-account {
    position: relative;
}

.nav-account .account-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.7rem;
    background: #010409;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease);
}

.nav-account .account-btn:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
}

.nav-account .account-btn .chev {
    font-size: 0.6rem;
    color: var(--text-faint);
    transition: transform var(--motion) var(--ease);
}

.nav-account[data-open="true"] .account-btn .chev { transform: rotate(180deg); }

.nav-account .account-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.45rem);
    min-width: 210px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.35rem;
    display: none;
    z-index: 90;
}

.nav-account[data-open="true"] .account-menu { display: block; }

.account-menu .row {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.55rem 0.65rem;
    background: transparent;
    border: none;
    color: var(--text);
    font: inherit;
    font-size: 0.83rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    box-sizing: border-box;
}

.account-menu a.row { display: block; }
.account-menu a.row:hover { text-decoration: none; }

.account-menu .row:hover { background: var(--surface-3); }

.account-menu .row.danger { color: var(--danger-fg); }

.account-menu .sep {
    height: 1px;
    background: var(--border-subtle);
    margin: 0.35rem 0;
}

.account-menu .hint {
    padding: 0.45rem 0.65rem 0.25rem;
    font-size: 0.7rem;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* -----------------------------------------------------------------------------
 * Page shell
 * --------------------------------------------------------------------------- */

.page-wrap {
    max-width: var(--shell-max);
    margin: 0 auto;
    padding: 1.5rem 1.25rem 2.5rem;
}

.page-heading {
    margin: 0 0 1.25rem;
}
.page-heading h1 {
    font-size: 1.35rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.page-heading .lead {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.page-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 1.25rem;
    align-items: flex-start;
}

.page-grid > .side-rail {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow: auto;
}

@media (max-width: 960px) {
    .page-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .page-grid > .side-rail {
        position: relative;
        top: 0;
        max-height: none;
        order: -1;
    }
}

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

.card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.2rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: 0; }

.card h2, .card .card-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    margin: 0 0 0.7rem;
}

.card-title-lg {
    font-size: 1.02rem !important;
    font-weight: 600 !important;
    text-transform: none !important;
    letter-spacing: -0.01em !important;
    color: var(--text-primary) !important;
    margin: 0 0 0.35rem !important;
}

.card-desc {
    margin: -0.35rem 0 0.95rem;
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

.card-foot {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
}

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

.form-row { margin-bottom: 0.8rem; }
.form-row:last-child { margin-bottom: 0; }

.form-label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    font-weight: 500;
}

.form-hint {
    margin-top: 0.3rem;
    font-size: 0.72rem;
    color: var(--text-faint);
    line-height: 1.45;
}

.input, .select, .textarea,
input[type="text"].input,
input[type="password"].input,
input[type="tel"].input,
input[type="number"].input,
input[type="email"].input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease);
}

.textarea { min-height: 6rem; resize: vertical; line-height: 1.45; }

.input:focus, .select:focus, .textarea:focus,
input:focus, select:focus, textarea:focus {
    border-color: var(--accent-hover);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.input::placeholder, .textarea::placeholder { color: var(--text-faint); }

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

.btn {
    --btn-bg: var(--success);
    --btn-bg-hover: var(--success-hover);
    --btn-fg: #fff;
    --btn-border: transparent;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.6rem 1.1rem;
    background: var(--btn-bg);
    color: var(--btn-fg);
    border: 1px solid var(--btn-border);
    border-radius: var(--radius);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}

.btn:hover:not(:disabled) { background: var(--btn-bg-hover); }

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

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { --btn-bg: var(--accent); --btn-bg-hover: var(--accent-hover); }
.btn-success { --btn-bg: var(--success); --btn-bg-hover: var(--success-hover); }
.btn-danger { --btn-bg: var(--danger); --btn-bg-hover: var(--danger-hover); }

.btn-secondary {
    --btn-bg: var(--surface-3);
    --btn-bg-hover: var(--surface-4);
    --btn-fg: var(--text);
    --btn-border: var(--border);
}

.btn-ghost {
    --btn-bg: transparent;
    --btn-bg-hover: var(--surface-3);
    --btn-fg: var(--text);
    --btn-border: var(--border);
}

.btn-sm { padding: 0.38rem 0.75rem; font-size: 0.8rem; }

.btn-block { width: 100%; }

.btn-row {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.btn-row > .btn { flex: 1 1 auto; }

/* Icon-only buttons (e.g. mute/hold) */
.btn-icon {
    width: 2.3rem;
    height: 2.3rem;
    padding: 0;
    border-radius: 50%;
}

/* Toggle state for mute/hold */
.btn.is-active {
    --btn-bg: var(--warn-soft);
    --btn-border: var(--warn);
    --btn-fg: var(--warn-fg);
}

/* -----------------------------------------------------------------------------
 * Badges / status pills
 * --------------------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.badge-info { background: var(--accent-soft); border-color: rgba(56, 139, 253, 0.4); color: var(--accent-hover); }
.badge-success { background: var(--success-soft); border-color: rgba(63, 185, 80, 0.4); color: var(--success-fg); }
.badge-warn { background: var(--warn-soft); border-color: rgba(210, 153, 34, 0.4); color: var(--warn-fg); }
.badge-danger { background: var(--danger-soft); border-color: rgba(248, 81, 73, 0.4); color: var(--danger-fg); }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 500;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--text-faint);
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(110, 118, 129, 0.12);
}

.status-dot.ok { background: var(--success-fg); box-shadow: 0 0 0 3px var(--success-soft); }
.status-dot.warn { background: var(--warn-fg); box-shadow: 0 0 0 3px var(--warn-soft); animation: dot-pulse 1.6s var(--ease) infinite; }
.status-dot.danger { background: var(--danger-fg); box-shadow: 0 0 0 3px var(--danger-soft); animation: dot-pulse 1.2s var(--ease) infinite; }
.status-dot.busy { background: var(--accent-hover); box-shadow: 0 0 0 3px var(--accent-soft); animation: dot-pulse 1.8s var(--ease) infinite; }

@keyframes dot-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

/* -----------------------------------------------------------------------------
 * Metrics grid
 * --------------------------------------------------------------------------- */

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.65rem;
}

.metric {
    background: var(--surface-inset);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 0.75rem 0.85rem;
}

.metric .value {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    font-feature-settings: "tnum";
    line-height: 1.2;
}

.metric .label {
    margin-top: 0.2rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 500;
}

/* -----------------------------------------------------------------------------
 * Segmented tabs
 * --------------------------------------------------------------------------- */

.tabs {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.tab {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 0.4rem 0.85rem;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    transition: color var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease);
}

.tab:hover { color: var(--text); background: var(--surface-3); }

.tab.active {
    color: var(--text-primary);
    background: var(--accent);
    border-color: var(--accent-hover);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* -----------------------------------------------------------------------------
 * Modal
 * --------------------------------------------------------------------------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    animation: fade-in var(--motion) var(--ease);
}

.modal {
    width: 100%;
    max-width: 440px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: pop-in 180ms var(--ease);
}

.modal-title {
    margin: 0;
    padding: 1rem 1.25rem 0.6rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.modal-body {
    padding: 0 1.25rem 1.1rem;
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.55;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.55rem;
    padding: 0 1.25rem 1.15rem;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in {
    from { opacity: 0; transform: translateY(6px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

/* -----------------------------------------------------------------------------
 * Toasts
 * --------------------------------------------------------------------------- */

.toast-region {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 150;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    max-width: min(380px, calc(100vw - 2rem));
}

.toast {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: var(--radius);
    padding: 0.7rem 0.9rem;
    font-size: 0.85rem;
    color: var(--text);
    box-shadow: var(--shadow);
    animation: toast-in 180ms var(--ease);
}

.toast.ok    { border-left-color: var(--success-fg); }
.toast.warn  { border-left-color: var(--warn-fg); }
.toast.err   { border-left-color: var(--danger-fg); }
.toast.info  { border-left-color: var(--accent-hover); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(12px); }
    to { opacity: 1; transform: none; }
}

/* -----------------------------------------------------------------------------
 * Keypad (DTMF)
 * --------------------------------------------------------------------------- */

.kpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    max-width: 280px;
}

.kpad-key {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    padding: 0.65rem 0.4rem;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font: inherit;
    font-size: 1.15rem;
    font-weight: 600;
    font-feature-settings: "tnum";
    cursor: pointer;
    user-select: none;
    transition: background var(--motion-fast) var(--ease), transform var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease);
}

.kpad-key:hover { background: var(--surface-4); border-color: var(--border-strong); }

.kpad-key:active,
.kpad-key.pressed {
    background: var(--accent);
    border-color: var(--accent-hover);
    color: #fff;
    transform: scale(0.97);
}

.kpad-key .sub {
    font-size: 0.6rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    color: var(--text-faint);
    text-transform: uppercase;
}

.kpad-key:active .sub,
.kpad-key.pressed .sub { color: rgba(255, 255, 255, 0.85); }

.kpad-out {
    font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', monospace;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.1em;
    background: var(--surface-inset);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    min-height: 2.1rem;
    margin-bottom: 0.7rem;
    word-break: break-all;
}

.kpad-out:empty::before {
    content: 'Press a key to send DTMF…';
    color: var(--text-faint);
    font-weight: 400;
    font-family: inherit;
    letter-spacing: 0;
}

/* -----------------------------------------------------------------------------
 * Log box
 * --------------------------------------------------------------------------- */

.log-box {
    background: var(--surface-inset);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 0.6rem 0.75rem;
    max-height: 200px;
    overflow-y: auto;
    font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', monospace;
    font-size: 0.74rem;
    line-height: 1.55;
    color: var(--text-muted);
}

.log-line { padding: 0.05rem 0; }
.log-info { color: var(--accent-hover); }
.log-ok { color: var(--success-fg); }
.log-warn { color: var(--warn-fg); }
.log-err { color: var(--danger-fg); }

/* -----------------------------------------------------------------------------
 * Utilities
 * --------------------------------------------------------------------------- */

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, 'SF Mono', monospace; font-feature-settings: "tnum"; }
.hidden { display: none !important; }

.stack { display: flex; flex-direction: column; gap: 0.7rem; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.row-inline { display: inline-flex; align-items: center; gap: 0.4rem; }

.kbd {
    display: inline-block;
    font-family: ui-monospace, 'SF Mono', monospace;
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    color: var(--text);
}

.skeleton {
    background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-4) 50%, var(--surface-3) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
    border-radius: var(--radius-sm);
    color: transparent;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
