/* Aurora Wake-Up Call System — Stylesheet */

/* ── Variables ────────────────────────────────────────── */
:root {
    --bg-base: #f0f2f5;
    --bg-surface: #ffffff;
    --bg-elevated: #ffffff;
    --bg-sidebar: #0c1222;
    --bg-sidebar-hover: #162032;
    --bg-sidebar-active: #1c2d44;

    --text-primary: #1a1d23;
    --text-secondary: #525866;
    --text-muted: #8b919a;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #f1f5f9;

    --border: #e2e5ea;
    --border-light: #eef0f3;
    --border-focus: #0d9488;

    --primary: #0d9488;
    --primary-hover: #0f766e;
    --primary-light: #f0fdfa;
    --primary-50: rgba(13, 148, 136, .08);

    --green: #059669;
    --green-bg: #ecfdf5;
    --red: #dc2626;
    --red-bg: #fef2f2;
    --amber: #d97706;
    --amber-bg: #fffbeb;
    --blue: #2563eb;
    --blue-bg: #eff6ff;
    --gray: #6b7280;
    --gray-bg: #f3f4f6;

    --aurora-green: #22c55e;
    --aurora-glow: rgba(34, 197, 94, .25);

    --radius: 10px;
    --radius-sm: 7px;
    --radius-lg: 14px;
    --sidebar-width: 248px;
    --topbar-height: 60px;
    --transition: 180ms ease;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
    --shadow-md: 0 2px 4px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.06);
    --shadow-lg: 0 4px 8px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.08);

    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* ── Reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--bg-base);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
hr { border: none; border-top: 1px solid var(--border-light); }

/* ── Layout ───────────────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-base);
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
    border-right: 1px solid rgba(255,255,255,.04);
}

.sidebar-header {
    padding: 1.25rem 1.35rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    text-decoration: none;
}

.brand-icon {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--primary), #06b6d4);
    color: #fff;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -.02em;
    box-shadow: 0 2px 8px rgba(13, 148, 136, .3);
}

.brand-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -.01em;
}

.sidebar-nav {
    flex: 1;
    padding: .75rem 0;
    overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.sidebar-nav ul {
    list-style: none;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem 1.35rem;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 450;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    margin: 1px 0;
}

.nav-link:hover {
    background: var(--bg-sidebar-hover);
    color: #e2e8f0;
    text-decoration: none;
}

.nav-link.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    border-left-color: var(--primary);
    font-weight: 500;
}

.nav-link svg {
    opacity: .65;
    flex-shrink: 0;
    transition: opacity var(--transition);
}
.nav-link:hover svg,
.nav-link.active svg { opacity: 1; }

.nav-section-label {
    padding: 1.5rem 1.35rem .45rem;
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,.28);
}

.sidebar-footer {
    padding: .85rem 1.35rem;
    border-top: 1px solid rgba(255,255,255,.06);
}

.tenant-badge {
    font-size: .78rem;
    color: var(--text-sidebar);
    opacity: .6;
    font-weight: 450;
}

/* ── Topbar ───────────────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.75rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 0 rgba(0,0,0,.03);
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    flex: 1;
    letter-spacing: -.01em;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: .85rem;
}

.locale-select {
    padding: .3rem .55rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary);
    font-family: var(--font);
    transition: border-color var(--transition);
}
.locale-select:hover { border-color: var(--text-muted); }

.user-name {
    font-size: .85rem;
    color: var(--text-secondary);
    font-weight: 450;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: .25rem;
}

/* ── Page content ─────────────────────────────────────── */
.page-content {
    padding: 1.75rem;
    flex: 1;
    max-width: 1400px;
}

/* ── Cards ────────────────────────────────────────────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.35rem;
    border-bottom: 1px solid var(--border-light);
}

.card-header h2 {
    font-size: .95rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -.01em;
}

.card-body {
    padding: 1.35rem;
}

/* ── Stats ────────────────────────────────────────────── */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: .35rem;
    font-weight: 450;
    letter-spacing: .01em;
}

.stat-pending .stat-value { color: var(--blue); }
.stat-completed .stat-value { color: var(--green); }
.stat-failed .stat-value { color: var(--red); }

/* ── Dashboard grid ───────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

/* ── Tables ───────────────────────────────────────────── */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .88rem;
}

.table th {
    text-align: left;
    font-weight: 600;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    padding: .65rem .65rem;
    border-bottom: 2px solid var(--border);
    background: var(--bg-base);
    position: sticky;
    top: 0;
    white-space: nowrap;
}

.table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.table th:last-child { border-radius: 0 var(--radius-sm) 0 0; }

.table td {
    padding: .7rem .65rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.table tbody tr {
    transition: background var(--transition);
}

.table tbody tr:hover {
    background: var(--primary-50);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.font-mono {
    font-family: var(--font-mono);
    font-size: .82em;
    font-weight: 450;
    letter-spacing: -.01em;
}

/* ── Badges ───────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .6rem;
    font-size: .74rem;
    font-weight: 600;
    border-radius: 999px;
    line-height: 1.35;
    letter-spacing: .01em;
    white-space: nowrap;
}

.badge-green  { background: var(--green-bg); color: var(--green); }
.badge-red    { background: var(--red-bg); color: var(--red); }
.badge-amber  { background: var(--amber-bg); color: var(--amber); }
.badge-blue   { background: var(--blue-bg); color: var(--blue); }
.badge-gray   { background: var(--gray-bg); color: var(--gray); }

.badge-dot {
    width: 8px;
    height: 8px;
    padding: 0;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.badge-dot.badge-green  { background: var(--green); }
.badge-dot.badge-red    { background: var(--red); }
.badge-dot.badge-amber  { background: var(--amber); }
.badge-dot.badge-blue   { background: var(--blue); }
.badge-dot.badge-gray   { background: var(--gray); }

/* ── Activity list ────────────────────────────────────── */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .5rem .25rem;
    font-size: .86rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.activity-item:hover { background: var(--bg-base); }

/* ── Forms ────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.1rem;
    flex: 1;
}

.form-group label {
    display: block;
    font-size: .82rem;
    font-weight: 550;
    margin-bottom: .35rem;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: .6rem .85rem;
    font-size: .88rem;
    font-family: var(--font);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
    line-height: 1.4;
}

.form-control:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, .12);
}

.form-control::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238b919a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .85rem center;
    padding-right: 2.5rem;
}

textarea.form-control { resize: vertical; min-height: 64px; }

.form-row {
    display: flex;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: .75rem;
    margin-top: 1.35rem;
}

small.text-muted {
    font-size: .78rem;
    display: block;
    margin-top: .25rem;
}

/* ── Buttons ──────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .6rem 1.15rem;
    font-family: var(--font);
    font-size: .88rem;
    font-weight: 550;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: .005em;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.98); }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 1px 3px rgba(13, 148, 136, .2);
}
.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 2px 6px rgba(13, 148, 136, .25);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-ghost:hover {
    background: var(--bg-base);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.btn-sm {
    padding: .38rem .75rem;
    font-size: .8rem;
    border-radius: 6px;
}

.btn-cancel { color: var(--red); border-color: transparent; }
.btn-cancel:hover { background: var(--red-bg); }

/* ── Alerts ───────────────────────────────────────────── */
.alerts-container {
    padding: 0 1.75rem;
    padding-top: 1rem;
}

.alert {
    padding: .75rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: .86rem;
    font-weight: 450;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .5rem;
    border: 1px solid transparent;
}

.alert-danger  { background: var(--red-bg); color: var(--red); border-color: rgba(220,38,38,.12); }
.alert-success { background: var(--green-bg); color: var(--green); border-color: rgba(5,150,105,.12); }
.alert-warning { background: var(--amber-bg); color: var(--amber); border-color: rgba(217,119,6,.12); }
.alert-info    { background: var(--blue-bg); color: var(--blue); border-color: rgba(37,99,235,.12); }

.alert-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: inherit;
    opacity: .6;
    padding: 0 .25rem;
    transition: opacity var(--transition);
}
.alert-close:hover { opacity: 1; }

/* ── Toast ────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.toast {
    padding: .7rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: .86rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn .3s cubic-bezier(.21,1.02,.73,1);
    max-width: 380px;
    backdrop-filter: blur(8px);
}

.toast-success { background: var(--green); color: #fff; }
.toast-error   { background: var(--red); color: #fff; }
.toast-info    { background: var(--blue); color: #fff; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-12px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Modals ───────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal.open {
    display: flex;
    animation: modalFadeIn .2s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 15, 28, .45);
    backdrop-filter: blur(3px);
}

.modal-content {
    position: relative;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,.04);
    animation: modalSlideIn .25s cubic-bezier(.21,1.02,.73,1);
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-content::-webkit-scrollbar { width: 6px; }
.modal-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.35rem;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -.01em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.35rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: .15rem;
    border-radius: 4px;
    transition: all var(--transition);
    line-height: 1;
}
.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-base);
}

.modal-body {
    padding: 1.35rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: 1rem 1.35rem;
    border-top: 1px solid var(--border-light);
    background: var(--bg-base);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Audio upload ─────────────────────────────────────── */
.audio-upload-row {
    display: flex;
    gap: .5rem;
    align-items: center;
}

.audio-upload-row .form-control {
    flex: 1;
    font-size: .8rem;
    padding: .4rem .55rem;
}

.audio-status {
    margin-top: .35rem;
    font-size: .78rem;
}

.audio-status .badge { cursor: default; }

.audio-status .audio-remove {
    cursor: pointer;
    margin-left: .35rem;
    opacity: .6;
    transition: opacity var(--transition);
}
.audio-status .audio-remove:hover { opacity: 1; }

/* ── Resource meters ──────────────────────────────────── */
.resource-meters {
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
}

.resource-meter {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.resource-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.resource-label {
    font-size: .84rem;
    font-weight: 600;
    color: var(--text-primary);
}

.resource-value {
    font-size: .82rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

.meter-bar {
    height: 7px;
    background: var(--bg-base);
    border-radius: 4px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    background: var(--green);
    border-radius: 4px;
    transition: width .6s ease, background .3s ease;
}

.meter-fill.meter-warn { background: var(--amber); }
.meter-fill.meter-danger { background: var(--red); }

.resource-detail {
    font-size: .76rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ── Utility ──────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-blue  { color: var(--blue); }

/* ── Scrollbar (global) ──────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Focus visible ───────────────────────────────────── */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
    outline: none;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: block;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .page-content {
        padding: 1.25rem;
    }
    .topbar {
        padding: 0 1.25rem;
    }
    .alerts-container {
        padding: 0 1.25rem;
        padding-top: .75rem;
    }
    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .dashboard-stats {
        grid-template-columns: 1fr;
    }
    .topbar-right .user-name {
        display: none;
    }
}

/* ── Impersonate banner ───────────────────────────────── */
.impersonate-banner {
    background: #fef3c7;
    color: #92400e;
    padding: .5rem 1.5rem;
    font-size: .85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 2px solid #f59e0b;
}

/* ── Aurora Shuttle (dual listbox) ────────────────────── */
.shuttle-layout {
    display: flex;
    gap: .75rem;
    align-items: stretch;
}
.shuttle-panel { flex: 1; display: flex; flex-direction: column; }
.shuttle-label {
    font-weight: 600;
    font-size: .8rem;
    margin-bottom: .35rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .03em;
}
.shuttle-list {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .25rem;
    font-size: .85rem;
    font-family: var(--font-mono);
    background: var(--bg-surface);
    color: var(--text-primary);
    outline: none;
}
.shuttle-list option {
    padding: .3rem .5rem;
    border-radius: 4px;
    cursor: pointer;
}
.shuttle-list option:checked {
    background: var(--primary);
    color: #fff;
}
.shuttle-arrows {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: .35rem;
    padding: 0 .25rem;
}
.shuttle-arrows .btn { min-width: 36px; text-align: center; font-size: 1rem; padding: .4rem; }
@media (max-width: 600px) {
    .shuttle-layout { flex-direction: column; }
    .shuttle-arrows { flex-direction: row; justify-content: center; }
    .shuttle-list { min-height: 120px; }
}
