/* ============================================================
   VARIANT SYSTEM — SQL Chat Industrial Intelligence
   ============================================================
   Single variant: PcVue — professional SCADA platform branding.
   PcVue navy (#1B2A4A) + red accent (#E31937).
   ============================================================ */

/* ============================================================
   1. BASE TOKENS (PcVue defaults)
   ============================================================ */
:root {
    /* Primary palette — PcVue red */
    --primary: #e31937;
    --primary-hover: #c8152f;
    --primary-light: rgba(227, 25, 55, 0.07);
    --secondary: #1b2a4a;
    --secondary-light: rgba(27, 42, 74, 0.06);

    /* Semantic colors */
    --success: #0d9f6e;
    --success-light: rgba(13, 159, 110, 0.08);
    --warning: #d97706;
    --warning-light: rgba(217, 119, 6, 0.08);
    --danger: #dc2626;
    --danger-light: rgba(220, 38, 38, 0.08);
    --info: #2563eb;
    --info-light: rgba(37, 99, 235, 0.07);

    /* Backgrounds — professional light gray */
    --bg-base: #f5f7fa;
    --bg-elevated: #ffffff;
    --bg-surface: #eef1f5;
    --bg-hover: #e4e8ee;
    --bg-base-alpha: rgba(245, 247, 250, 0.95);
    --bg-inset: #eaecf0;
    --bg-overlay: rgba(27, 42, 74, 0.45);
    --bg-input: #ffffff;

    /* Text — PcVue navy hierarchy */
    --text-primary: #1b2a4a;
    --text-secondary: #4a5a72;
    --text-muted: #8c96a6;
    --text-on-primary: #ffffff;

    /* Borders — subtle corporate */
    --border: #dce0e8;
    --border-hover: #c5cad4;
    --border-focus: #e31937;
    --focus-ring: 0 0 0 3px rgba(227, 25, 55, 0.15);

    /* Shadows — professional depth */
    --shadow-sm: 0 1px 2px rgba(27, 42, 74, 0.06);
    --shadow-md: 0 4px 12px rgba(27, 42, 74, 0.08);
    --shadow-lg: 0 10px 32px rgba(27, 42, 74, 0.1);

    /* Radius — moderate, clean */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    /* Syntax — brand-tinted */
    --syntax-keyword: #e31937;
    --syntax-string: #0d9f6e;

    /* Layout */
    --backdrop-blur: 12px;
    --transition-speed: 0.15s;

    /* Data highlights */
    --highlight-retrieved: rgba(13, 159, 110, 0.1);
    --highlight-border: #0d9f6e;

    /* Select caret */
    --select-caret-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238c96a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* ============================================================
   2. APP SHELL STRUCTURAL CSS
   ============================================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.app-sidebar {
    display: none;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    background: var(--bg-elevated);
    z-index: 50;
    width: 260px;
}

.has-sidebar .app-sidebar {
    display: flex;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

/* --- Sidebar internal structure --- */
.sidebar-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary, var(--primary)) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-on-primary);
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.sidebar-subtitle {
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-weight: 500;
    line-height: 1.3;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    gap: 0.25rem;
}

.sidebar-nav-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-speed), color var(--transition-speed);
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.sidebar-nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar-controls {
    padding: 0.75rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: auto;
}

.sidebar-control-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.sidebar-control-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    background-image: var(--select-caret-svg);
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
    width: 100%;
}

.sidebar-select:hover {
    border-color: var(--border-hover);
}

.sidebar-select:focus {
    border-color: var(--border-focus);
    box-shadow: var(--focus-ring);
    outline: none;
}

.sidebar-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-status {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================================
   3. PcVue STRUCTURAL OVERRIDES
   ============================================================ */

/* No scanline */
[data-variant="pcvue"]::after {
    display: none;
}

/* Body typography */
[data-variant="pcvue"] body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Header — professional, navy-accented */
[data-variant="pcvue"] header {
    height: 60px;
    background: #ffffff;
    border-bottom: 1px solid #dce0e8;
    backdrop-filter: blur(12px);
    padding: 0 1.5rem;
}

[data-variant="pcvue"] .brand-logo-img {
    display: block;
    height: 30px;
    width: auto;
}

[data-variant="pcvue"] .header-logo {
    display: none;
}

[data-variant="pcvue"] .header-title {
    font-weight: 700;
    letter-spacing: -0.01em;
    font-size: 1.0625rem;
    color: #1b2a4a;
}

[data-variant="pcvue"] .header-subtitle {
    font-weight: 500;
    letter-spacing: 0.02em;
    font-size: 0.6875rem;
    color: #8c96a6;
    text-transform: uppercase;
}

[data-variant="pcvue"] .control-label {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    font-size: 0.6875rem;
    color: #4a5a72;
}

/* Selects — clean bordered */
[data-variant="pcvue"] .control-select {
    border: 1px solid #dce0e8;
    background: #ffffff;
    border-radius: 6px;
    font-size: 0.8125rem;
    padding: 0.4375rem 2rem 0.4375rem 0.625rem;
}

[data-variant="pcvue"] .control-select:hover {
    border-color: #c5cad4;
}

[data-variant="pcvue"] .control-select:focus {
    border-color: #e31937;
    box-shadow: 0 0 0 3px rgba(227, 25, 55, 0.1);
}

/* Buttons — PcVue red primary */
[data-variant="pcvue"] .btn-primary,
[data-variant="pcvue"] .send-btn {
    background: #e31937;
    color: #ffffff;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    letter-spacing: 0.01em;
    box-shadow: 0 1px 3px rgba(227, 25, 55, 0.2);
}

[data-variant="pcvue"] .btn-primary:hover,
[data-variant="pcvue"] .send-btn:hover:not(:disabled) {
    background: #c8152f;
    box-shadow: 0 3px 10px rgba(227, 25, 55, 0.25);
}

[data-variant="pcvue"] .btn-ghost {
    border: 1px solid #dce0e8;
    border-radius: 8px;
    font-weight: 500;
    color: #1b2a4a;
}

[data-variant="pcvue"] .btn-ghost:hover {
    background: rgba(227, 25, 55, 0.05);
    border-color: rgba(227, 25, 55, 0.25);
    color: #e31937;
}

/* Messages — clean, professional bubbles */
[data-variant="pcvue"] .message.user .message-bubble {
    background: linear-gradient(135deg, #e31937, #c8152f);
    color: #ffffff;
    border-radius: 14px 14px 4px 14px;
    box-shadow: 0 2px 8px rgba(227, 25, 55, 0.15);
}

[data-variant="pcvue"] .message.assistant .message-bubble {
    background: #ffffff;
    border: 1px solid #dce0e8;
    border-radius: 14px 14px 14px 4px;
    box-shadow: 0 1px 4px rgba(27, 42, 74, 0.05);
}

[data-variant="pcvue"] .message-content {
    font-size: 0.9375rem;
    line-height: 1.6;
}

/* Input — clean bordered */
[data-variant="pcvue"] .input-wrapper input {
    border: 1px solid #dce0e8;
    border-radius: 10px;
    background: #ffffff;
    font-size: 0.9375rem;
    padding: 0.75rem 1rem;
    box-shadow: 0 1px 3px rgba(27, 42, 74, 0.04);
}

[data-variant="pcvue"] .input-wrapper input:focus {
    border-color: #e31937;
    box-shadow: 0 0 0 3px rgba(227, 25, 55, 0.1), 0 1px 3px rgba(27, 42, 74, 0.04);
}

/* Cards — professional, subtle elevation */
[data-variant="pcvue"] .schema-card,
[data-variant="pcvue"] .equipment-card,
[data-variant="pcvue"] .stat-card,
[data-variant="pcvue"] .variable-card {
    border: 1px solid #dce0e8;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(27, 42, 74, 0.05);
    background: #ffffff;
}

[data-variant="pcvue"] .schema-card:hover,
[data-variant="pcvue"] .equipment-card:hover,
[data-variant="pcvue"] .stat-card:hover,
[data-variant="pcvue"] .variable-card:hover {
    border-color: rgba(227, 25, 55, 0.2);
    box-shadow: 0 4px 12px rgba(27, 42, 74, 0.08);
}

[data-variant="pcvue"] .schema-card-header {
    border-radius: 10px 10px 0 0;
}

/* Badges — pill-style, subtle */
[data-variant="pcvue"] .intent-badge,
[data-variant="pcvue"] .entity-tag,
[data-variant="pcvue"] .type-badge {
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.75rem;
}

/* Modal — professional overlay */
[data-variant="pcvue"] .modal {
    border: 1px solid #dce0e8;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(27, 42, 74, 0.12);
}

[data-variant="pcvue"] .modal-header {
    border-bottom-color: #dce0e8;
    padding: 1.125rem 1.5rem;
}

[data-variant="pcvue"] .modal-header h2 {
    font-weight: 600;
    font-size: 1rem;
    color: #1b2a4a;
}

[data-variant="pcvue"] .modal-tab {
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.8125rem;
}

[data-variant="pcvue"] .modal-tab.active {
    background: rgba(227, 25, 55, 0.08);
    color: #e31937;
}

/* Suggested questions — outlined pills */
[data-variant="pcvue"] .suggested-btn {
    border: 1px solid #dce0e8;
    border-radius: 20px;
    padding: 0.4375rem 0.875rem;
    font-size: 0.8125rem;
    color: #4a5a72;
}

[data-variant="pcvue"] .suggested-btn:hover {
    border-color: rgba(227, 25, 55, 0.3);
    color: #e31937;
    background: rgba(227, 25, 55, 0.04);
}

/* Result summary — green left accent */
[data-variant="pcvue"] .result-summary {
    border-left: 3px solid #0d9f6e;
    border-radius: 0 8px 8px 0;
    background: rgba(13, 159, 110, 0.04);
}

/* Detail sections */
[data-variant="pcvue"] .detail-section pre {
    border: 1px solid #dce0e8;
    border-radius: 8px;
    background: #f5f7fa;
}

[data-variant="pcvue"] .detail-section h4 {
    font-weight: 600;
    color: #1b2a4a;
}

/* Scrollbar — neutral */
[data-variant="pcvue"] .messages::-webkit-scrollbar-thumb {
    background: #c5cad4;
    border-radius: 6px;
}

[data-variant="pcvue"] .messages::-webkit-scrollbar-thumb:hover {
    background: #a0a8b6;
}

/* Tables — clean corporate */
[data-variant="pcvue"] .table-browser-wrapper th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #4a5a72;
    border-bottom: 2px solid #dce0e8;
}

[data-variant="pcvue"] .table-browser-wrapper td {
    font-size: 0.8125rem;
}

/* Domain headers */
[data-variant="pcvue"] .domain-header {
    border-radius: 8px;
}

[data-variant="pcvue"] .domain-header:hover {
    background: rgba(227, 25, 55, 0.03);
}

/* Loading dots — red */
[data-variant="pcvue"] .loading-dots span {
    background: #e31937;
}

/* Container width */
[data-variant="pcvue"] .container {
    max-width: 920px;
}

/* ============================================================
   4. SHARED ANIMATIONS
   ============================================================ */
@keyframes messageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes loadingPulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

@keyframes highlightPulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================
   5. UTILITY CLASSES
   ============================================================ */
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }

.caption-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.empty-state {
    color: var(--text-muted);
    padding: 2rem;
    text-align: center;
    font-size: 0.875rem;
}

.empty-state strong {
    color: var(--text-secondary);
}

.error-state {
    color: var(--danger);
    padding: 1rem;
}

/* ============================================================
   6. FOCUS VISIBLE
   ============================================================ */
:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* ============================================================
   7. RESPONSIVE — TABLET (768px)
   ============================================================ */
@media (max-width: 768px) {
    .has-sidebar .app-sidebar {
        display: none;
    }

    [data-variant="pcvue"] header {
        height: auto;
        min-height: 52px;
        padding: 0.5rem 1rem;
    }

    [data-variant="pcvue"] .brand-logo-img {
        height: 26px;
    }

    [data-variant="pcvue"] .container {
        max-width: 100%;
        padding: 0 1rem;
    }
}

/* ============================================================
   8. RESPONSIVE — MOBILE (480px)
   ============================================================ */
@media (max-width: 480px) {
    [data-variant="pcvue"] header {
        padding: 0.375rem 0.75rem;
    }

    [data-variant="pcvue"] .brand-logo-img {
        height: 22px;
    }

    [data-variant="pcvue"] .header-title {
        font-size: 0.8125rem;
    }
}
