/* Devinote — Telnyx-inspired dashboard theme */

:root {
    --ds-success: #16A34A;
    --ds-error: #DC2626;
    --ds-warning: #EA580C;
    --ds-success-muted: rgba(22, 163, 74, 0.12);
    --ds-error-muted: rgba(220, 38, 38, 0.12);
    --ds-warning-muted: rgba(234, 88, 12, 0.12);
    --ds-accent: #00A870;
    --ds-accent-muted: rgba(0, 168, 112, 0.1);
    --ds-border: #E2E8F0;
    --ds-border-subtle: #F1F5F9;
    --ds-surface: #FFFFFF;
    --ds-surface-raised: #F8FAFC;
    --ds-bg: #F8FAFC;
    --ds-text-muted: #64748B;
    --ds-link: #2563EB;
}

html.mud-theme-dark {
    --ds-success: #22C55E;
    --ds-error: #EF4444;
    --ds-warning: #F97316;
    --ds-success-muted: rgba(34, 197, 94, 0.15);
    --ds-error-muted: rgba(239, 68, 68, 0.15);
    --ds-warning-muted: rgba(249, 115, 22, 0.15);
    --ds-accent: #00E699;
    --ds-accent-muted: rgba(0, 230, 153, 0.12);
    --ds-border: #262626;
    --ds-border-subtle: #1f1f1f;
    --ds-surface: #141414;
    --ds-surface-raised: #1a1a1a;
    --ds-bg: #0B0B0B;
    --ds-text-muted: #9CA3AF;
    --ds-link: #60A5FA;
}

html, body {
    background: var(--ds-bg);
}

/* ── App shell ─────────────────────────────────────────────── */
.ds-appbar {
    background: var(--ds-bg) !important;
    border-bottom: 1px solid var(--ds-border);
    color: var(--mud-palette-text-primary);
}

.ds-appbar-inner {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 4px;
}

.ds-appbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.ds-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.ds-brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--ds-accent) 0%, #00b377 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    color: #0B0B0B;
}

.ds-brand-name {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.ds-suite-label {
    color: var(--ds-text-muted);
    font-size: 0.8125rem;
    padding-left: 12px;
    border-left: 1px solid var(--ds-border);
    white-space: nowrap;
}

.ds-search {
    max-width: 320px;
    min-width: 180px;
}

.ds-search .mud-input-root {
    background: var(--ds-surface) !important;
    border-radius: 8px !important;
}

.ds-appbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

@media (max-width: 767.98px) {
    .ds-appbar-inner {
        gap: 8px;
        padding: 0;
    }

    .ds-appbar-left {
        gap: 6px;
    }

    .ds-appbar-right {
        gap: 2px;
    }

    .ds-brand-name {
        font-size: 0.9375rem;
    }

    .ds-user-chip {
        padding: 2px 6px 2px 2px;
        max-width: 148px;
        gap: 4px;
    }

    .ds-user-email {
        font-size: 0.75rem;
    }
}

@media (min-width: 768px) and (max-width: 1023.98px) {
    .ds-user-chip {
        max-width: 176px;
    }
}

.ds-user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    border: 1px solid var(--ds-border);
    background: var(--ds-surface);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    max-width: 220px;
}

.ds-user-chip:hover {
    background: var(--ds-surface-raised);
}

.ds-user-email {
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.ds-drawer {
    background: var(--ds-bg) !important;
    border-right: 1px solid var(--ds-border) !important;
}

.ds-drawer-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 8px 0;
}

.ds-nav-group-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ds-text-muted);
    padding: 16px 20px 6px;
}

.ds-nav-menu .mud-nav-link {
    border-radius: 8px;
    margin: 2px 10px;
    min-height: 40px;
    font-size: 0.875rem;
}

.ds-nav-menu .mud-nav-link.active {
    background: var(--ds-surface-raised) !important;
    color: var(--mud-palette-text-primary) !important;
}

.ds-nav-menu .mud-nav-link:hover:not(.active) {
    background: rgba(255, 255, 255, 0.04) !important;
}

.ds-sidebar-footer {
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid var(--ds-border);
}

.ds-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ds-success);
    box-shadow: 0 0 0 3px var(--ds-success-muted);
}

/* ── Main content ──────────────────────────────────────────── */
.ds-main {
    background: var(--ds-bg);
    min-height: calc(100vh - 56px);
}

.ds-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 28px 40px;
}

@media (max-width: 767.98px) {
    .ds-page {
        padding: 16px 16px 32px;
    }
}

@media (min-width: 768px) and (max-width: 1023.98px) {
    .ds-page {
        padding: 20px 20px 36px;
    }
}

/* ── Page header ───────────────────────────────────────────── */
.ds-page-header-wrap {
    margin-bottom: 24px;
}

.ds-back-link {
    display: inline-flex;
    align-items: center;
    color: var(--ds-text-muted) !important;
    font-size: 0.875rem;
    margin-bottom: 12px;
    transition: color 0.15s;
}

.ds-back-link:hover {
    color: var(--mud-palette-text-primary) !important;
}

.ds-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.ds-page-title {
    font-weight: 700 !important;
    letter-spacing: -0.02em;
    line-height: 1.2 !important;
}

.ds-page-subtitle {
    color: var(--ds-text-muted);
    margin-top: 4px;
}

.ds-page-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ds-page-tabs {
    margin-top: 20px;
    border-bottom: 1px solid var(--ds-border);
}

.ds-page-tabs .mud-tabs-toolbar {
    background: transparent !important;
}

/* ── Section cards ─────────────────────────────────────────── */
.ds-section-card {
    background: var(--ds-surface) !important;
    border: 1px solid var(--ds-border) !important;
    border-radius: 12px !important;
    padding: 24px !important;
    margin-bottom: 20px;
}

@media (max-width: 767.98px) {
    .ds-page-header-wrap {
        margin-bottom: 16px;
    }

    .ds-page-header {
        gap: 10px;
    }

    .ds-page-actions {
        width: 100%;
    }

    .ds-section-card {
        padding: 16px !important;
        border-radius: 10px !important;
    }
}

@media (min-width: 768px) and (max-width: 1023.98px) {
    .ds-section-card {
        padding: 20px !important;
    }
}

.ds-section-title {
    font-weight: 600 !important;
    margin-bottom: 4px !important;
}

.ds-section-description {
    color: var(--ds-text-muted);
    margin-bottom: 16px;
}

/* ── Detail grid (Telnyx Details section) ──────────────────── */
.ds-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px 32px;
}

.ds-detail-item label,
.ds-detail-label {
    display: block;
    font-size: 0.8125rem;
    color: var(--ds-text-muted);
    margin-bottom: 4px;
}

.ds-detail-value {
    font-size: 0.9375rem;
    font-weight: 500;
    word-break: break-word;
}

.ds-plan-current {
    border-color: var(--ds-accent) !important;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--ds-accent) 35%, transparent);
}

.ds-plan-current .mud-card-content {
    background: color-mix(in srgb, var(--ds-accent) 8%, transparent);
}

.ds-status-active {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ds-success);
    font-size: 0.875rem;
}

.ds-status-active::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ds-success);
}

/* ── Stats row ─────────────────────────────────────────────── */
.ds-stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.ds-stat-card {
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: 12px;
    padding: 20px;
}

.ds-stat-label {
    font-size: 0.8125rem;
    color: var(--ds-text-muted);
    margin-bottom: 8px;
}

.ds-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;
}

/* ── Quick actions ─────────────────────────────────────────── */
.ds-action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.ds-action-card {
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.ds-action-card:hover {
    border-color: #333;
    background: var(--ds-surface-raised);
}

.ds-action-card.disabled,
.ds-action-disabled .ds-action-card {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.ds-action-card.disabled:hover,
.ds-action-disabled .ds-action-card:hover {
    border-color: var(--ds-border);
    background: var(--ds-surface);
}

.ds-action-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--ds-accent-muted);
    color: var(--ds-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ds-action-title {
    font-weight: 600;
    font-size: 0.9375rem;
    margin-bottom: 4px;
}

.ds-action-desc {
    font-size: 0.8125rem;
    color: var(--ds-text-muted);
    line-height: 1.5;
}

.ds-action-body {
    min-width: 0;
}

/* ── Tables ────────────────────────────────────────────────── */
.ds-table-wrap {
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: 12px;
    overflow: hidden;
}

@media (max-width: 767.98px) {
    .ds-table-wrap {
        border-radius: 10px;
    }

    .ds-action-grid {
        grid-template-columns: 1fr;
    }

    .ds-stat-row {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 479.98px) {
    .ds-stat-row {
        grid-template-columns: 1fr;
    }
}

.ds-table-wrap .mud-table {
    background: transparent !important;
}

.ds-table-wrap .mud-table-head .mud-table-cell {
    background-color: var(--ds-surface-raised) !important;
    color: var(--mud-palette-text-primary) !important;
    font-weight: 600;
    font-size: 0.8125rem;
    border-bottom: 1px solid var(--ds-border) !important;
}

.ds-table-wrap .mud-table-body .mud-table-row {
    background-color: var(--ds-surface) !important;
}

.ds-table-wrap .mud-table-body .mud-table-row:nth-child(even) {
    background-color: var(--ds-surface-raised) !important;
}

.ds-table-wrap .mud-table-body .mud-table-cell {
    color: var(--mud-palette-text-primary) !important;
    border-bottom: 1px solid var(--ds-border-subtle) !important;
}

@media (max-width: 767.98px) {
    .ds-table-wrap .mud-table-head .mud-table-cell,
    .ds-table-wrap .mud-table-body .mud-table-cell {
        padding: 10px 12px !important;
    }
}

.ds-table-wrap .mud-table-body .mud-table-row:hover {
    background-color: color-mix(in srgb, var(--ds-accent) 8%, var(--ds-surface)) !important;
}

.ds-table-wrap .mud-table-body .mud-table-row:last-child .mud-table-cell {
    border-bottom: none !important;
}

/* Light mode: stronger contrast for seat / data tables */
html:not(.mud-theme-dark) .ds-table-wrap {
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

html:not(.mud-theme-dark) .ds-table-wrap .mud-table-head .mud-table-cell {
    background-color: #E2E8F0 !important;
    color: #1E293B !important;
}

html:not(.mud-theme-dark) .ds-table-wrap .mud-table-body .mud-table-cell {
    color: #0F172A !important;
}

html:not(.mud-theme-dark) .ds-table-wrap .mud-button-text {
    color: #2563EB !important;
}

html:not(.mud-theme-dark) .ds-table-wrap .mud-button-text.mud-button-color-error {
    color: var(--ds-error) !important;
}

html:not(.mud-theme-dark) .ds-seats-page .mud-typography-h6 {
    color: #0F172A;
}

html:not(.mud-theme-dark) .ds-seats-page .mud-input-outlined-border {
    border-color: #CBD5E1 !important;
}

/* ── Auth pages ────────────────────────────────────────────── */
.ds-auth-shell {
    min-height: 100vh;
    background: var(--ds-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.ds-auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--ds-surface) !important;
    border: 1px solid var(--ds-border) !important;
    border-radius: 16px !important;
    padding: 32px !important;
}

.ds-auth-split {
    width: 100%;
    max-width: 960px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--ds-border);
    background: var(--ds-surface);
}

.ds-auth-hero {
    position: relative;
    height: 100%;
    min-height: 560px;
}

.ds-auth-hero-overlay {
    position: absolute;
    inset: 0;
}

.ds-auth-hero-content {
    position: absolute;
    inset: 0;
}

.ds-auth-mobile-hero {
    position: relative;
    height: 220px;
}

@media (max-width: 767.98px) {
    .ds-auth-shell {
        padding: 12px;
    }

    .ds-auth-split {
        border-radius: 12px;
    }

    .ds-auth-mobile-hero {
        height: 180px;
    }
}

@media (min-width: 768px) and (max-width: 1023.98px) {
    .ds-auth-shell {
        padding: 16px;
    }

    .ds-auth-hero {
        min-height: 460px;
    }
}

/* ── Transcription overrides ───────────────────────────────── */
.ds-main .segment-card,
.ds-main .empty-state {
    background: var(--ds-surface) !important;
    border-color: var(--ds-border) !important;
}

.ds-main .live-segment-card {
    background: var(--ds-success-muted) !important;
    border-color: color-mix(in srgb, var(--ds-success) 35%, transparent) !important;
}

.ds-main .dt-header-status {
    border-color: var(--ds-border);
    background: var(--ds-surface);
    color: var(--ds-text-muted);
}

.ds-main .trx-container {
    border-color: var(--ds-border);
    background: var(--ds-surface);
}

.ds-main .trx-row-odd {
    background: rgba(255, 255, 255, 0.03);
}

/* Legacy dashboard — dark overrides */
.ds-main .hero-card,
.ds-main .hero-visual,
.ds-main .action-card,
.ds-main .stat-card {
    background: var(--ds-surface) !important;
    border-color: var(--ds-border) !important;
}

.ds-main .action-title,
.ds-main .stat-number,
.ds-main .hero-title {
    color: var(--mud-palette-text-primary) !important;
}

.ds-main .action-description,
.ds-main .stat-label,
.ds-main .hero-subtitle {
    color: var(--ds-text-muted) !important;
}

.ds-main .action-purple,
.ds-main .stat-purple {
    background: var(--ds-accent-muted) !important;
    color: var(--ds-accent) !important;
}

/* ── Auth theme toggle ─────────────────────────────────────── */
.ds-auth-shell {
    position: relative;
}

.ds-appearance-controls {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ds-auth-appearance {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1300;
}

.ds-auth-appearance .ds-lang-toggle {
    display: inline-flex;
    gap: 2px;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: 8px;
    padding: 2px;
}

.ds-auth-appearance .ds-lang-btn {
    min-width: 36px;
}

.ds-auth-theme-toggle {
    background: var(--ds-surface) !important;
    border: 1px solid var(--ds-border);
}

/* ── Transcripe page ─────────────────────────────────────── */
.trx-session-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px 24px;
}

.trx-controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px 20px;
    background: var(--ds-surface-raised);
    border: 1px solid var(--ds-border);
    border-radius: 10px;
    margin-bottom: 20px;
}

.trx-controls-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.trx-timer-block {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    border: 1px solid var(--ds-border);
    border-radius: 10px;
    background: var(--ds-surface);
}

.trx-timer-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    min-width: 88px;
}

@media (max-width: 767.98px) {
    .trx-controls-bar {
        padding: 12px 14px;
        gap: 10px;
    }

    .trx-controls-left {
        width: 100%;
    }

    .trx-timer-block {
        width: 100%;
        justify-content: center;
        padding: 8px 12px;
    }

    .trx-timer-value {
        min-width: 74px;
        font-size: 1.25rem;
    }
}

@media (min-width: 768px) and (max-width: 1023.98px) {
    .trx-timer-block {
        padding: 8px 12px;
    }
}

.trx-transcript-panel {
    min-height: 280px;
    max-height: 420px;
    overflow-y: auto;
    padding: 16px;
    border: 1px solid var(--ds-border);
    border-radius: 10px;
    background: var(--ds-surface-raised);
}

.trx-tabs {
    margin-top: 8px;
}

.trx-tabs .mud-tabs-toolbar {
    background: transparent !important;
    border-bottom: 1px solid var(--ds-border);
}

.trx-tabs .mud-tabs-toolbar .mud-tabs-tabbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.trx-tabs .mud-tabs-toolbar .mud-tab {
    flex: 0 0 auto;
}

.trx-tabs.trx-tabs-stacked .mud-tabs-toolbar .mud-tabs-tabbar {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100%;
}

.trx-tabs.trx-tabs-stacked .mud-tabs-toolbar .mud-tabs-tabbar-content {
    width: 100%;
}

.trx-tabs.trx-tabs-stacked .mud-tabs-toolbar .mud-tab {
    width: 100% !important;
    max-width: none !important;
    justify-content: flex-start !important;
}

@media (max-width: 767.98px) {
    .trx-tabs .mud-tabs-toolbar {
        overflow-x: auto;
    }
}

.trx-tab-panel {
    padding-top: 20px;
}

.trx-tabs .mud-tabs-panels,
.trx-tabs .mud-tabs-panels .mud-tab-panel {
    background: transparent !important;
}

.ds-main .mud-paper {
    background-color: var(--ds-surface) !important;
    color: var(--mud-palette-text-primary);
}

.ds-main .mud-tabs-panels {
    background: transparent !important;
}

.recording-pulse {
    animation: trx-pulse 1.4s ease-in-out infinite;
}

@keyframes trx-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

html:not(.mud-theme-dark) .ds-main .trx-row-odd {
    background: rgba(0, 0, 0, 0.03);
}

html.mud-theme-dark .ds-main .trx-row-odd {
    background: rgba(255, 255, 255, 0.03);
}

html:not(.mud-theme-dark) .dt-header-status.is-online .dt-header-status-dot {
    background: var(--ds-success);
    box-shadow: 0 0 0 6px var(--ds-success-muted);
}

/* Semantic status utilities */
.text-success { color: var(--ds-success) !important; }
.text-danger { color: var(--ds-error) !important; }
.text-warning { color: var(--ds-warning) !important; }

/* Connection / status cards */
.dt-status-card {
    text-align: center;
    padding: 48px 24px;
    border-radius: 12px;
    border: 1px solid var(--ds-border);
    background: var(--ds-surface);
}

.dt-status-card--error {
    border-color: var(--ds-error);
    background: var(--ds-error-muted);
}

.dt-status-icon--error {
    color: var(--ds-error) !important;
}

html:not(.mud-theme-dark) .dt-header-status {
    border-color: var(--ds-border);
    background: var(--ds-surface);
}
