/* ==========================================================================
   GLS Equity V4 - Calendars Module
   Mobile-first, fully responsive, modular CSS
   ========================================================================== */

/* --- Layout & Containers --- */
.page-container {
    width: 100%;      /* FIX: Forces container to respect screen width */
    min-width: 0;     /* FIX: Prevents flex-blowout from the 900px table */
    padding: 16px;
    max-width: 1400px;
    margin: 0 auto;
}

.panel-card {
    background: #ffffff;
    padding: 0; 
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;    
}
.page-title {
    margin: 0 0 2px 0;
    font-size: 1.5rem;
    color: #0f172a;
}

/* --- Flex Utilities --- */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-wrap { flex-wrap: wrap; }
.gap-16 { gap: 16px; }

/* --- iOS-Style Segmented Controls --- */
.segmented-control {
    display: inline-flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.segmented-control.sm {
    padding: 2px;
    border-radius: 6px;
}

.segment-btn {
    border: none;
    background: transparent;
    padding: 6px 14px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.segmented-control.sm .segment-btn {
    padding: 4px 10px;
    font-size: 0.75rem;
}

.segment-btn:hover {
    color: #2563eb; 
    background: rgba(59, 130, 246, 0.08); 
}

.segment-btn.active {
    background: #2563eb; 
    color: #ffffff; 
    box-shadow: 0 2px 5px rgba(37, 99, 235, 0.25); 
    border-radius: 6px; 
    font-weight: 600;
}

/* --- Toolbar & Filters --- */
.toolbar-section {
    padding: 12px 16px 8px 16px; 
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
}

.toolbar-row {
    margin-bottom: 12px;
}
.toolbar-row:last-child {
    margin-bottom: 0;
}

.filters-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group-multi {
    display: flex;
    gap: 16px;
}

.filter-label {
    font-size: 0.75rem;
    margin-bottom: -2px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-input, .form-select {
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s ease;
}
.form-input:focus, .form-select:focus {
    border-color: #3b82f6;
}

/* --- Utilities & Summary Formatting --- */
.ml-auto { margin-left: auto; }
.w-sm { width: 80px; }

/* --- Date Navigator --- */
.date-navigator {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 4px;
}
.btn-nav {
    border: none;
    background: #0f172a;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
}
.btn-nav:hover { background: #1e293b; }
.date-badge {
    font-size: 0.875rem;
    font-weight: 600;
    color: #0f172a;
    min-width: 130px;
    text-align: center;
}

/* --- Table & Scroll Containers --- */
.table-container-relative {
    position: relative;
}
#calendar-table-container {
    padding: 0; 
}

.table-responsive {
    width: 100%;
    max-height: 65vh; 
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Custom Sleek Scrollbars */
.table-responsive::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.table-responsive::-webkit-scrollbar-track {
    background: transparent; 
}
.table-responsive::-webkit-scrollbar-thumb {
    background: #cbd5e1; 
    border-radius: 10px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #94a3b8; 
}

.data-table {
    width: 100%;
    border-collapse: separate; 
    border-spacing: 0; 
    text-align: left;
    white-space: nowrap;
    min-width: 900px; 
}

/* Table Cell Base */
.data-table th, .data-table td {
    padding: 7px 16px;
    border-bottom: 1px solid #f1f5f9;
}

/* --- STICKY HEADER LOGIC --- */
.data-table thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 10;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 600;
    border: none;
    box-shadow: inset 0 -1px 0 #e2e8f0; 
    background-clip: padding-box; 
}

.data-table tr:hover td { background: #f8fafc; }
.cursor-pointer { cursor: pointer; }

/* --- STICKY FIRST COLUMN LOGIC --- */
.sticky-col {
    position: sticky;
    left: 0;
    background: #ffffff;
    z-index: 12; 
    border: none;
    box-shadow: inset -1px 0 0 #e2e8f0; 
    background-clip: padding-box;
}

/* The Top-Left Corner */
.data-table thead th.sticky-col {
    background: #f8fafc;
    z-index: 20; 
    box-shadow: inset -1px -1px 0 #e2e8f0; 
}

.data-table tbody tr:hover td.sticky-col {
    background: #f8fafc; 
}

/* Table Cell Base */
.data-table th {
    padding: 7px 16px;
    border-bottom: 1px solid #e2e8f0; /* Keeps a thin neat line under the header */
}

.data-table td {
    padding: 7px 16px;
    border-bottom: 2px solid #ffffff; /* 💥 Creates the thick white gap between all rows */
}

.summary-text {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
    align-self: center; 
    margin-bottom: 4px; 
}

/* --- V4 Standards & Utilities --- */
.truncate-text {
    display: inline-block;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.text-success { color: #10b981; font-weight: 700; }
.text-danger { color: #ef4444; font-weight: 700; }
.text-right { text-align: right !important; }
.text-muted { 
    color: #64748b; 
    font-size: 0.8rem;
}
.hidden { display: none !important; }

/* Loading State Overlay */
.loading-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.85);
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 100px;
}
.loading-title { color: #0f172a; margin-bottom: 8px; }
.loading-subtitle { color: #64748b; font-size: 0.875rem; }
.table-faded {
    opacity: 0.3;
    pointer-events: none;
}

/* --- New Layout Utility --- */
.filter-group-row {
    display: flex;
    align-items: center; 
    gap: 8px; 
}
.filter-group-row .filter-label {
    margin-bottom: 0; 
    white-space: nowrap; 
}

/* ==========================================
   ECONOMIC CALENDAR: IMPACT ROW HIGHLIGHTS
   ========================================== */

/* High Impact (Soft Red) */
.data-table tr.row-impact-high td,
.data-table tr.row-impact-high td.sticky-col {
    background-color: #fef2f2 !important;
    transition: background-color 0.15s ease;
}
.data-table tbody tr.row-impact-high:hover td,
.data-table tbody tr.row-impact-high:hover td.sticky-col {
    background-color: #fee2e2 !important;
}

/* Medium Impact (Soft Amber/Yellow) */
.data-table tr.row-impact-med td,
.data-table tr.row-impact-med td.sticky-col {
    background-color: #fffbeb !important;
    transition: background-color 0.15s ease;
}
.data-table tbody tr.row-impact-med:hover td,
.data-table tbody tr.row-impact-med:hover td.sticky-col {
    background-color: #fef3c7 !important;
}

/* Low Impact (Standard Neutral) */
.data-table tr.row-impact-low td,
.data-table tr.row-impact-low td.sticky-col {
    background-color: #f1f8f4;
}
.data-table tbody tr.row-impact-low:hover td,
.data-table tbody tr.row-impact-low:hover td.sticky-col {
    background-color: #f8fafc !important;
}

/* Impact Badge Styling */
.impact-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}
.impact-high {
    color: #b91c1c;
    background: #fee2e2;
    border: 1px solid #fca5a5;
}
.impact-med {
    color: #b45309;
    background: #fef3c7;
    border: 1px solid #fde68a;
}
.impact-low {
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

/* --- Mobile Overrides --- */
@media (max-width: 768px) {
    .page-container { padding: 0; }
    .panel-card { border-radius: 0; border-left: none; border-right: none; }
    
    /* Hide desktop tabs, show mobile dropdown */
    .desktop-tabs { display: none !important; }
    .mobile-tab-dropdown {
        display: block;
        width: 100%;
        padding: 8px 12px;
        font-size: 1rem;
        border: 1px solid #cbd5e1;
        border-radius: 8px;
        background-color: #f1f5f9;
        margin-top: 12px;
        font-weight: 600;
        color: #0f172a;
    }

    /* Stack the filter rows cleanly */
    .filters-grid {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    /* Force liquidity filters to stack on mobile */
    .filter-group-multi { 
        flex-direction: column; 
        width: 100%; 
        gap: 12px; 
    }
    
    .filter-group-row {
        width: 100%;
    }

    /* FIX: Force all labels to the exact same width so inputs align perfectly */
    .filter-group-row .filter-label {
        min-width: 90px; 
    }

    .filter-label-view {
        min-width: 30px; 
        font-size: 0.75rem;
        margin-bottom: -2px;
        font-weight: 600;
        color: #64748b;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }
    
    /* FIX: Make the Search bar fill the row, but leave .w-sm inputs small */
    .filter-group-row .form-input:not(.w-sm),
    .filter-group-row .form-select {
        flex: 1;
    }

    /* Push the summary text back to the left on mobile so it looks natural */
    .ml-auto { margin-left: 0; }
    .summary-text { 
        align-self: flex-start; 
        padding-top: 8px; 
    }
}