/**
 * GilGamez Studio Platform — Operator Portal Styles
 * Adheres strictly to DEVELOPMENT_RULES.md (Rule #6 4-Viewport Responsive, Rule #18 Gold Scrollbars, Rule #19 Master-Detail Accordion).
 */

html, body.studio-body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    background: var(--store-surface-0, #09090b);
    color: var(--store-text-primary, #f4f4f5);
    font-family: var(--store-font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
.skip-link:focus {
    position: fixed;
    top: 12px;
    left: 12px;
    width: auto;
    height: auto;
    padding: 10px 16px;
    background: var(--store-accent-primary, #c5a059);
    color: #09090b;
    font-weight: 700;
    border-radius: 6px;
    z-index: 9999;
}

.studio-app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.studio-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    min-height: 64px;
    background: var(--store-surface-1, #121215);
    border-bottom: 1px solid rgba(197, 160, 89, 0.25);
    gap: 16px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 100;
    box-sizing: border-box;
}

.studio-header-left, .studio-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.studio-brand-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--store-text-gold, #e5c07b);
    font-weight: 800;
    font-size: 16px;
    letter-spacing: 0.03em;
}

.studio-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--store-accent-primary, #c5a059);
}

.version-pill {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(197, 160, 89, 0.15);
    color: var(--store-text-gold, #e5c07b);
    border: 1px solid rgba(197, 160, 89, 0.3);
}

.studio-top-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    max-width: 100%;
    padding: 4px 0;
}

.studio-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    min-height: 44px;
    box-sizing: border-box;
    border-radius: 6px;
    text-decoration: none;
    color: var(--store-text-secondary, #a1a1aa);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.studio-nav-link:hover {
    color: var(--store-text-primary, #f4f4f5);
    background: var(--store-surface-2, #18181b);
}

.studio-nav-link.is-active {
    color: var(--store-text-gold, #e5c07b);
    background: rgba(197, 160, 89, 0.12);
    border-color: rgba(197, 160, 89, 0.35);
}

.telemetry-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    font-size: 11px;
    font-weight: 700;
    color: var(--store-status-success, #10b981);
}

.pulse-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--store-status-success, #10b981);
    box-shadow: 0 0 8px var(--store-status-success, #10b981);
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--store-surface-2, #18181b);
    border: 1px solid var(--store-border-subtle);
    font-size: 12px;
    font-weight: 600;
}

.user-avatar-badge {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--store-accent-primary, #c5a059);
    color: #09090b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
}

.studio-main {
    flex: 1;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 32px 64px;
    box-sizing: border-box;
}

/* Page Headers & Action Decks */
.admin-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.admin-page-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--store-text-primary, #f4f4f5);
    margin: 0 0 6px 0;
}

.admin-page-subtitle {
    font-size: 13px;
    color: var(--store-text-secondary, #a1a1aa);
    margin: 0;
}

.header-action-deck {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Overview & KPI Cards */
.overview-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.overview-card {
    background: var(--store-surface-1, #121215);
    border: 1px solid var(--store-border-subtle);
    border-radius: var(--store-radius-md, 10px);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-sizing: border-box;
}

.overview-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.overview-card-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--store-text-muted, #71717a);
}

.overview-card-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--store-text-gold, #e5c07b);
    line-height: 1.2;
}

.overview-card-subtext {
    font-size: 12px;
    color: var(--store-text-secondary, #a1a1aa);
}

/* Transport Engine Matrix Cards */
.routing-mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.routing-mode-card {
    background: var(--store-surface-1, #121215);
    border: 1px solid var(--store-border-subtle);
    border-radius: var(--store-radius-md, 10px);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
}

.routing-mode-card.is-selected {
    border-color: var(--store-accent-primary, #c5a059);
    background: rgba(197, 160, 89, 0.05);
}

.mode-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.mode-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--store-text-primary, #f4f4f5);
}

.mode-card-desc {
    font-size: 12px;
    color: var(--store-text-secondary, #a1a1aa);
    line-height: 1.45;
}

/* Master-Detail Table Accordion Pattern (Rule #18 & Rule #19: Zero Horizontal Scroll) */
.table-accordion-wrapper {
    width: 100%;
    background: var(--store-surface-1, #121215);
    border: 1px solid var(--store-border-subtle);
    border-radius: var(--store-radius-md, 10px);
    overflow: visible;
    box-sizing: border-box;
    margin-bottom: 24px;
}

.table-accordion {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    overflow-x: visible;
    box-sizing: border-box;
}

.table-accordion thead tr {
    background: var(--store-surface-inset, #0d0d10);
    border-bottom: 1px solid var(--store-border-subtle);
}

.table-accordion th {
    padding: 10px 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--store-text-muted, #71717a);
    text-align: left;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: break-word;
}

.table-row-master {
    height: 56px;
    border-bottom: 1px solid var(--store-border-subtle);
    transition: background 150ms ease;
    cursor: pointer;
}

.table-row-master:hover {
    background: rgba(255, 255, 255, 0.02);
}

.table-row-master.is-expanded {
    background: rgba(197, 160, 89, 0.05);
}

.table-row-master td {
    padding: 10px 8px;
    font-size: 13px;
    vertical-align: middle;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: break-word;
}

.btn-row-expand {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--store-border-subtle);
    background: var(--store-surface-inset, #0d0d10);
    color: var(--store-text-secondary, #a1a1aa);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 200ms ease, border-color 150ms ease;
}

.table-row-master.is-expanded .btn-row-expand svg {
    transform: rotate(180deg);
}

.table-row-detail {
    display: none;
    background: var(--store-surface-inset, #0d0d10);
}

.table-row-detail.is-expanded {
    display: table-row;
}

.table-detail-cell {
    padding: 0 !important;
    border-bottom: 1px solid var(--store-border-subtle);
}

.table-detail-collapse {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.table-detail-collapse.is-expanded {
    grid-template-rows: 1fr;
}

.table-detail-inner {
    overflow: hidden;
}

.table-detail-panel {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-sizing: border-box;
}

.detail-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.detail-meta-item {
    background: var(--store-surface-1, #121215);
    padding: 12px 14px;
    border-radius: 6px;
    border: 1px solid var(--store-border-subtle);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-meta-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--store-text-muted, #71717a);
}

.detail-meta-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--store-text-primary, #f4f4f5);
    word-break: break-all;
}

.detail-action-deck {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    border-top: 1px solid var(--store-border-subtle);
    padding-top: 14px;
}

/* Badges & Buttons */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.badge-gold {
    background: rgba(197, 160, 89, 0.15);
    color: var(--store-text-gold, #e5c07b);
    border: 1px solid rgba(197, 160, 89, 0.35);
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-cyan {
    background: rgba(6, 182, 212, 0.15);
    color: #06b6d4;
    border: 1px solid rgba(6, 182, 212, 0.35);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.badge-neutral {
    background: rgba(113, 113, 122, 0.15);
    color: #a1a1aa;
    border: 1px solid rgba(113, 113, 122, 0.35);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    min-height: 44px;
    box-sizing: border-box;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 150ms ease;
    white-space: nowrap;
}

.btn-sm {
    min-height: 38px;
    padding: 6px 14px;
    font-size: 12px;
}

.btn-primary {
    background: var(--store-accent-primary, #c5a059);
    color: #09090b;
    border-color: var(--store-accent-primary, #c5a059);
}

.btn-primary:hover {
    background: var(--store-accent-hover, #d4af37);
    border-color: var(--store-accent-hover, #d4af37);
}

.btn-outline {
    background: transparent;
    border-color: var(--store-border-medium);
    color: var(--store-text-primary, #f4f4f5);
}

.btn-outline:hover {
    border-color: var(--store-accent-primary, #c5a059);
    color: var(--store-text-gold, #e5c07b);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

.btn-danger:hover {
    background: #ef4444;
    color: #ffffff;
}

/* Filter Bar & Tabs */
.admin-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: var(--store-surface-1, #121215);
    border: 1px solid var(--store-border-subtle);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.admin-tabs-bar {
    display: inline-flex;
    background: var(--store-surface-inset, #0d0d10);
    border: 1px solid var(--store-border-subtle);
    border-radius: 6px;
    padding: 3px;
    gap: 2px;
    max-width: 100%;
    overflow-x: auto;
}

.admin-tab-btn {
    background: transparent;
    border: none;
    color: var(--store-text-secondary, #a1a1aa);
    padding: 8px 14px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    min-height: 40px;
    white-space: nowrap;
}

.admin-tab-btn.is-active {
    background: var(--store-surface-1, #121215);
    color: var(--store-text-gold, #e5c07b);
    font-weight: 700;
}

/* Forms & Accessible Dialogs */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--store-text-secondary, #a1a1aa);
}

.form-input, .form-select, .form-textarea {
    background: var(--store-surface-inset, #0d0d10);
    border: 1px solid var(--store-border-medium);
    border-radius: 6px;
    color: var(--store-text-primary, #f4f4f5);
    font-size: 13px;
    padding: 10px 12px;
    min-height: 44px;
    box-sizing: border-box;
    width: 100%;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--store-accent-primary, #c5a059);
    box-shadow: 0 0 0 2px var(--store-accent-glow);
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

dialog.cmc-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    padding: 0;
    background: var(--store-surface-2, #18181b);
    color: var(--store-text-primary, #f4f4f5);
    border: 1px solid var(--store-border-medium);
    border-radius: 12px;
    box-shadow: var(--store-shadow-modal);
    width: 90%;
    max-width: 560px;
    z-index: 1100;
    box-sizing: border-box;
}

dialog.cmc-dialog::backdrop {
    background: rgba(9, 9, 11, 0.82);
    backdrop-filter: blur(4px);
}

.cmc-dialog-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 85vh;
    overflow-y: auto;
}

.cmc-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--store-border-subtle);
    padding-bottom: 12px;
}

.cmc-dialog-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.cmc-dialog-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.cmc-dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--store-border-subtle);
}

.mono {
    font-family: var(--store-font-mono);
}

.store-empty-state {
    text-align: center;
    padding: 40px 24px;
    background: var(--store-surface-1, #121215);
    border: 1px solid var(--store-border-subtle);
    border-radius: 10px;
}

/* Responsive Breakpoints (360px, 768px, 1280px, 1920px) */
.col-mobile-hide {
    display: table-cell;
}

@media (max-width: 767px) {
    .col-mobile-hide {
        display: none !important;
    }
    .studio-header {
        padding: 10px 16px;
    }
    .studio-main {
        padding: 16px 14px 48px;
    }
    .form-row-2 {
        grid-template-columns: 1fr;
    }
    .telemetry-status-pill .status-label {
        display: none;
    }
}
