/* =========================================
   GLOBAL VARIABLES (Source of Truth)
   ========================================= */
:root {
    --bg-color: #0f172a;       
    --panel-color: #1e293b;    
    --text-main: #f1f5f9;      
    --text-muted: #94a3b8;     
    --brand-blue: #00427A;     
    --brand-blue-hover: #00569e;
    --brand-yellow: #FFCC00;   
    
    --glass-border: rgba(255, 255, 255, 0.08);
    --input-bg: #0f172a;       
    
    --separator: rgba(255, 255, 255, 0.12);
    --row-alt: rgba(255, 255, 255, 0.02);
    
    /* STATUS COLORS */
    --val-bad: #ef4444;   
    --val-warn: #f59e0b;
    --val-good: #4ade80;  
    --val-cold: #60a5fa;
}

body { 
    margin: 0; 
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; 
    background-color: var(--bg-color); color: var(--text-main);
    padding: 20px; overflow-x: hidden;
}

* { box-sizing: border-box; }

/* SCROLLBARS */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* --- SHARED BUTTON STYLES --- */

/* 1. Primary Action Buttons (Unified) */
.action-button, .action-btn, .btn-primary {
    background-color: var(--brand-blue); 
    color: #ffffff; /* Explicit White */
    border: 1px solid rgba(255,255,255,0.1);
    padding: 10px 20px; 
    font-size: 14px; 
    font-weight: 600;
    border-radius: 6px; 
    cursor: pointer; 
    transition: all 0.2s ease;
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    font-family: 'Segoe UI', sans-serif;
    text-decoration: none; /* Safety for <a> tags */
}

/* Hover: Yellow Border, Blue BG, Text stays WHITE */
.action-button:hover, .action-btn:hover, .btn-primary:hover { 
    background-color: var(--brand-blue-hover); 
    border-color: var(--brand-yellow); 
    color: #ffffff !important; /* Force white text */
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
}

.action-button:active, .action-btn:active, .btn-primary:active { 
    transform: translateY(1px); 
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.action-button:disabled, .btn-primary:disabled, .action-btn:disabled { 
    background-color: #334155; 
    color: #64748b !important; 
    border-color: transparent; 
    cursor: not-allowed; 
    box-shadow: none; 
    transform: none; 
}

/* 2. Secondary Button (Ghost) */
.btn-secondary { 
    background-color: transparent; 
    border: 1px solid var(--glass-border); 
    color: var(--text-muted);
    padding: 10px 20px; font-size: 14px; font-weight: 600;
    border-radius: 6px; cursor: pointer; transition: all 0.2s;
    font-family: 'Segoe UI', sans-serif;
}
.btn-secondary:hover { 
    background-color: rgba(255,255,255,0.05); 
    border-color: #fff; color: #fff;
}

/* 3. Danger Button (Red) */
.btn-danger {
    background-color: rgba(239, 68, 68, 0.2); 
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.5);
    padding: 10px 20px; font-size: 14px; font-weight: 600;
    border-radius: 6px; cursor: pointer; transition: all 0.2s;
    font-family: 'Segoe UI', sans-serif;
}
.btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.4);
    color: #fff; border-color: #ef4444;
    transform: translateY(-1px);
}

/* --- UNIVERSAL MODAL FIXES --- */

/* 1. Ensure Modal Content is visible when open */
.modal-backdrop.open .modal-content {
    opacity: 1 !important;
    transform: scale(1) !important;
    filter: blur(0) !important;
}

/* 2. COMPACT MODAL OVERRIDES */
#clear-confirmation-modal .modal-content,
#export-filters-modal .modal-content,
#validation-modal .modal-content {
    width: auto !important;
    max-width: 450px !important;
    height: auto !important;
    min-height: 200px;
}

#clear-confirmation-modal .modal-header,
#export-filters-modal .modal-header,
#validation-modal .modal-header {
    padding: 15px 20px;
}

#clear-confirmation-modal .modal-body,
#export-filters-modal .modal-body,
#validation-modal .modal-body {
    padding: 20px;
    font-size: 1rem;
    color: var(--text-muted);
    overflow: visible;
}

/* Handle BOTH class naming conventions */
.modal-overlay, 
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(5px);
    z-index: 9000;
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Handle BOTH state naming conventions */
.modal-overlay.active,
.modal-overlay.open,
.modal-backdrop.active,
.modal-backdrop.open {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: all;
}

/* Ensure content scales in */
.modal-overlay.active .modal-content,
.modal-overlay.open .modal-content,
.modal-backdrop.active .modal-content,
.modal-backdrop.open .modal-content {
    transform: scale(1) !important;
    opacity: 1 !important;
    filter: blur(0) !important;
}

/* Fix for specific ID specificity issues */
#resources-modal,
#filter-builder-backdrop,
#export-modal-backdrop,
#custom-prob-modal,
#factory-step1-modal {
    z-index: 9999 !important;
}