/* static/css/style.css - Enhanced Version */
:root {
    --costello-primary: #840B55;
    --costello-secondary: #4A0E4E;
    --costello-accent: #E91E63;
    --costello-light: #F5F5F5;
    --costello-dark: #2C2C2C;
    --costello-gray: #757575;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #FAFAFA 0%, #F0F0F0 100%);
    color: var(--costello-dark);
    line-height: 1.6;
}

/* ========== HEADER ========== */
.siteHeader {
    background: white;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.siteHeader-inner {
    margin: 0 auto;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.siteHeader-logo img {
    height: 28px;
    transition: transform 0.3s ease;
}

.siteHeader-logo img:hover {
    transform: scale(1.05);
}

.user-info {
    color: var(--costello-primary);
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

/* ========== TAB NAVIGATION ========== */
.tab-navigation {
    background: linear-gradient(135deg, var(--costello-primary) 0%, var(--costello-secondary) 100%);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 44px;  /* Below the header (~44px) */
    z-index: 999;  /* Just below header (1000) */
}

.tab-container {
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
}

.tab-button {
    padding: 1rem 2rem;
    background: transparent;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tab-button:hover {
    background: rgba(255,255,255,0.15);
}

.tab-button.active {
    background: rgba(255,255,255,0.2);
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--costello-accent);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { width: 0; }
    to { width: 100%; }
}

/* ========== MAIN CONTAINER ========== */
.main-container {
    margin: 1.5rem auto;
    padding: 0 1rem;
}

/* ========== ENHANCED FILTER BAR ========== */
.filter-bar {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    margin-bottom: 2rem;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1.5rem;
    position: relative;
    overflow: visible;
    align-items: end; /* ← ADD THIS - aligns all grid items to bottom */
}

.filter-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--costello-primary) 0%, var(--costello-accent) 100%);
}

/* ========== ENHANCED FILTER GROUPS ========== */
.filter-group {
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 70px;
}

.filter-group label {
    display: flex;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--costello-primary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-height: 24px;
}

/* ==========  DROPDOWNS ========== */
.filter-group select {
    width: 100%;
    padding: 10px 38px 10px 14px;
    font-size: 0.95rem;
    color: var(--costello-dark);
    background-color: #fff;
    border: 2px solid #E0E0E0;
    border-radius: 8px;
    appearance: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    font-weight: 500;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 14 14'%3E%3Cpath fill='%23840B55' d='M7 10L2 5h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.filter-group select:hover:not(:disabled) {
    border-color: var(--costello-primary);
    box-shadow: 0 4px 12px rgba(132, 11, 85, 0.15);
    transform: translateY(-1px);
}

.filter-group select:focus {
    outline: none;
    border-color: var(--costello-primary);
    box-shadow: 0 0 0 4px rgba(132, 11, 85, 0.1);
    transform: translateY(-1px);
}

.filter-group select:disabled {
    background-color: #F9F9F9;
    color: #BDBDBD;
    cursor: not-allowed;
    opacity: 0.6;
    border-color: #E0E0E0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%23BDBDBD' d='M7 10L2 5h10z'/%3E%3C/svg%3E");
}

.filter-group select option {
    padding: 12px;
    font-size: 1rem;
    color: var(--costello-dark);
}

.filter-group select optgroup {
    font-weight: 700;
    color: var(--costello-primary);
    font-style: normal;
    padding: 8px 0;
}

/* Valid selection styling - only when has-selection class is added */
.filter-group select.has-selection:not(:disabled) {
    border-color: #4CAF50;
    background-color: #F1F8F4;
}

/* ========== ENHANCED BUTTON ========== */
.btn {
    padding: 16px 32px;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--costello-primary) 0%, var(--costello-secondary) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(132, 11, 85, 0.4);
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(132, 11, 85, 0.5);
}

.btn-primary:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(132, 11, 85, 0.4);
}

/* Icon button - minimal style for toolbar actions */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--costello-grey);
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--costello-light);
    color: var(--costello-primary);
}

.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn svg {
    flex-shrink: 0;
}

/* ========== CONTENT CARDS ========== */
.content-card {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    margin-bottom: 2rem;
    transition: box-shadow 0.3s ease;
}

.content-card:hover {
    box-shadow: 0 6px 25px rgba(0,0,0,0.12);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    border-bottom: 3px solid var(--costello-light);
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--costello-primary);
    letter-spacing: 0.5px;
}

/* ========== SUMMARY CARDS ========== */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-card {
    background: linear-gradient(135deg, #ffffff 0%, #F9F9F9 100%);
    padding: 1.75rem;
    border-radius: 12px;
    border-left: 5px solid var(--costello-primary);
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
}

.summary-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.12);
}

.summary-card h3 {
    font-size: 0.85rem;
    color: var(--costello-gray);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.summary-card .value {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--costello-primary);
    line-height: 1.2;
}

/* ========== DATA SOURCE TABS ========== */
.data-source-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 3px solid var(--costello-light);
}

.source-tab {
    padding: 0.875rem 1.75rem;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 600;
    color: var(--costello-gray);
    transition: all 0.3s ease;
    position: relative;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
}

.source-tab:hover {
    color: var(--costello-primary);
    background: rgba(132, 11, 85, 0.05);
}

.source-tab.active {
    color: var(--costello-primary);
    background: rgba(132, 11, 85, 0.08);
}

.source-tab.active::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--costello-primary);
    animation: slideIn 0.3s ease;
}

/* ========== INFO BOX ========== */
.info-box {
    background: linear-gradient(135deg, #F3E5F5 0%, #FCE4EC 100%);
    padding: 1.25rem;
    border-radius: 10px;
    border-left: 4px solid var(--costello-primary);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    box-shadow: 0 2px 8px rgba(132, 11, 85, 0.1);
}

/* ========== LOADING & ERROR ========== */
.loading {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--costello-gray);
}

.spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 1.5rem;
    border: 4px solid var(--costello-light);
    border-top: 4px solid var(--costello-primary);
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error {
    background: linear-gradient(135deg, #FFEBEE 0%, #FFCDD2 100%);
    color: #C62828;
    padding: 1.25rem;
    border-radius: 10px;
    border-left: 4px solid #C62828;
    font-weight: 500;
}

/* ========== TABLES ========== */
#table-container {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    scrollbar-width: thin;
    scrollbar-color: var(--costello-primary) var(--costello-light);
}

/* Custom scrollbar for WebKit browsers */
#table-container::-webkit-scrollbar {
    height: 8px;
}

#table-container::-webkit-scrollbar-track {
    background: var(--costello-light);
    border-radius: 4px;
}

#table-container::-webkit-scrollbar-thumb {
    background: var(--costello-primary);
    border-radius: 4px;
}

#table-container::-webkit-scrollbar-thumb:hover {
    background: var(--costello-secondary);
}

/* Scroll indicator shadows */
#table-container::before,
#table-container::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 8px;
    width: 20px;
    pointer-events: none;
    z-index: 2;
    transition: opacity 0.3s ease;
}

#table-container::before {
    left: 0;
    background: linear-gradient(to right, white, transparent);
}

#table-container::after {
    right: 0;
    background: linear-gradient(to left, white, transparent);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.9rem;
    border-radius: 8px;
    overflow: hidden;
    min-width: 600px; /* Ensures table doesn't squish too much */
}

th, td {
    padding: 14px 18px;
    border: 1px solid #E0E0E0;
    text-align: left;
    white-space: nowrap;
}

thead th {
    background: linear-gradient(135deg, var(--costello-primary) 0%, var(--costello-secondary) 100%);
    color: white;
    font-weight: 700;
    position: sticky;
    top: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.85rem;
}

.model-fit-table thead th {
    text-transform: none;
}

.summary-table thead th {
    text-transform: none;
}

tbody tr:nth-of-type(even) {
    background-color: #FAFAFA;
}

tbody tr:hover {
    background-color: #F3E5F5;
    transition: background-color 0.2s ease;
}

tbody td {
    color: var(--costello-dark);
    font-weight: 500;
}

/* ========== PLACEHOLDER MESSAGE ========== */
.placeholder-message {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--costello-gray);
    font-size: 1.1rem;
    font-weight: 500;
}



/* ========== RESPONSIVE ========== */

/* Large screens (1440px - 1600px) */
@media (max-width: 1600px) {
    .filter-bar {
        padding: 2rem;
        gap: 1.25rem;
    }
}

/* Smaller laptops (1280px - 1440px) */
@media (max-width: 1440px) {
    .filter-bar {
        padding: 1.5rem;
        gap: 1rem;
    }
}

/* Tablet Landscape (1024px - 1280px) */
@media (max-width: 1280px) {
    .filter-bar {
        grid-template-columns: repeat(3, 1fr);
    }

    .filter-group.button-container {
        grid-column: span 3;
    }
}

/* Tablet Portrait (768px - 1024px) */
@media (max-width: 1024px) {
    .filter-bar {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .filter-group.button-container {
        grid-column: span 2;
    }

    /* Make toast notifications responsive */
    .toast-container {
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }
}

/* Mobile (up to 768px) */
@media (max-width: 768px) {
    .filter-bar {
        grid-template-columns: 1fr;
        padding: 1.5rem;
        gap: 1rem;
    }

    .filter-group.button-container {
        grid-column: 1;
    }

    .main-container {
        padding: 0 1rem;
        margin: 1rem auto;
    }

    .siteHeader-inner {
        padding: 1rem;
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    .user-info {
        font-size: 0.85rem;
    }

    /* Optimize touch targets for mobile */
    .filter-group select {
        padding: 16px 45px 16px 18px;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 48px; /* Touch target minimum */
    }

    .btn {
        padding: 18px 32px;
        font-size: 1rem;
        min-height: 48px;
    }

    .tab-button {
        padding: 1.25rem 1.5rem;
        font-size: 0.95rem;
        min-height: 48px;
    }

    /* Stack tab buttons on very small screens */
    .tab-container {
        flex-direction: row;
        width: 100%;
    }

    .tab-button {
        flex: 1;
    }

    /* Toast notifications on mobile */
    .toast-container {
        top: 60px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: auto;
        padding: 14px 18px;
        font-size: 0.9rem;
    }

    /* Table improvements on mobile */
    table {
        font-size: 0.85rem;
        min-width: 500px;
    }

    th, td {
        padding: 12px 14px;
    }

    thead th {
        font-size: 0.8rem;
    }

    /* Add hint for horizontal scrolling */
    #table-container::after {
        opacity: 0.8;
    }

    .content-card {
        padding: 1rem;
    }

    .card-title {
        font-size: 1.25rem;
    }
}

.filter-group.button-container {
    grid-column: span 6;
    align-self: flex-end;
    display: flex;
    justify-content: center;
}

.filter-group.button-container .btn {
    width: auto;
    min-width: 250px;
    padding: 0.75rem 2.5rem;
}

.sucra-note {
    background-color: #E3F2FD;
    border-left: 4px solid #2196F3;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 14px;
    color: #1565C0;
    border-radius: 4px;
}

.sucra-note strong {
    margin-right: 8px;
}

/* ========== TOAST NOTIFICATIONS ========== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: white;
    color: var(--costello-dark);
    padding: 16px 24px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 320px;
    max-width: 450px;
    pointer-events: auto;
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 4px solid;
    font-size: 0.95rem;
    font-weight: 500;
}

.toast.toast-error {
    border-left-color: #D32F2F;
    background: linear-gradient(135deg, #FFEBEE 0%, white 100%);
}

.toast.toast-warning {
    border-left-color: #F57C00;
    background: linear-gradient(135deg, #FFF3E0 0%, white 100%);
}

.toast.toast-success {
    border-left-color: #388E3C;
    background: linear-gradient(135deg, #E8F5E9 0%, white 100%);
}

.toast.toast-info {
    border-left-color: #1976D2;
    background: linear-gradient(135deg, #E3F2FD 0%, white 100%);
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.toast-error .toast-icon::before { content: '❌'; }
.toast-warning .toast-icon::before { content: '⚠️'; }
.toast-success .toast-icon::before { content: '✅'; }
.toast-info .toast-icon::before { content: 'ℹ️'; }

.toast-message {
    flex: 1;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--costello-gray);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.toast-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--costello-dark);
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast.removing {
    animation: slideOutRight 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ========== CUSTOM MULTISELECT DROPDOWN ========== */
.custom-multiselect {
    position: relative;
    width: 100%;
}

.multiselect-display {
    width: 100%;
    padding: 10px 38px 10px 14px;
    font-size: 0.95rem;
    color: var(--costello-dark);
    background-color: #fff;
    border: 2px solid #E0E0E0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.multiselect-display:hover {
    border-color: var(--costello-primary);
    box-shadow: 0 4px 12px rgba(132, 11, 85, 0.15);
    transform: translateY(-1px);
}

.multiselect-display:focus {
    outline: none;
    border-color: var(--costello-primary);
    box-shadow: 0 0 0 4px rgba(132, 11, 85, 0.1);
}

.multiselect-arrow {
    color: var(--costello-primary);
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.multiselect-display.open .multiselect-arrow {
    transform: rotate(180deg);
}

.multiselect-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #E0E0E0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none;
    animation: dropdownSlide 0.2s ease;
}

.multiselect-dropdown.open {
    display: block;
}

@keyframes dropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.multiselect-controls {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid #E0E0E0;
    background: #FAFAFA;
}

.multiselect-control-btn {
    flex: 1;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--costello-gray);
    background: white;
    border: 1px solid #E0E0E0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.multiselect-control-btn:hover {
    background: #F5F5F5;
    color: var(--costello-dark);
    border-color: #BDBDBD;
}

.multiselect-options {
    max-height: 250px;
    overflow-y: auto;
    padding: 0;
}

.multiselect-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid #F5F5F5;
}

.multiselect-option:last-child {
    border-bottom: none;
}

.multiselect-option:hover {
    background: transparent;
}

.multiselect-option label {
    flex: 1;
    cursor: pointer;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 1rem;
    font-weight: normal;
    color: var(--costello-dark);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    text-transform: none; /* Override .filter-group label uppercase */
}

.multiselect-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-left: 10px;
    cursor: pointer;
    accent-color: var(--costello-primary);
    flex-shrink: 0;
}
/* ========== SIDEBAR LAYOUT ========== */
.sidebar-layout {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.filter-sidebar {
    width: 240px;
    min-width: 240px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 1rem 1rem 1.5rem 1rem;
    position: sticky;
    top: 90px;
    z-index: 100;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    overflow-x: visible;
}

.sidebar-header {
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--costello-primary);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--costello-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-sidebar .filter-group {
    margin-bottom: 0.5rem;
    min-height: auto;
}

.filter-sidebar .filter-group label {
    font-size: 0.65rem;
    margin-bottom: 0.1rem;
    display: block;
    min-height: auto;
}

.filter-sidebar .filter-select,
.filter-sidebar select {
    width: 100%;
    padding: 0.3rem 0.4rem;
    font-size: 0.75rem;
}

.filter-sidebar .btn-primary {
    width: 100%;
    padding: 0.5rem;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.main-content {
    flex: 1;
    min-width: 0;
}

.sidebar-layout .content-card {
    /* Let content card size naturally based on contents */
}

/* Reference filter compact styling in sidebar */
.filter-sidebar .custom-multiselect .multiselect-display {
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
}

.filter-sidebar .multiselect-dropdown {
    max-height: none;
}

.filter-sidebar .multiselect-options {
    max-height: 300px;
}

.filter-sidebar .multiselect-option {
    padding: 8px 10px;
}

.filter-sidebar .multiselect-option label {
    font-size: 0.85rem;
}

/* Responsive - stack on smaller screens */
@media (max-width: 1024px) {
    .sidebar-layout {
        flex-direction: column;
    }
    .filter-sidebar {
        width: 100%;
        position: static;
        max-height: none;
    }
    .sidebar-layout .content-card {
        min-height: auto;
    }
}

/* Sidebar multiselect controls - stack buttons vertically */
.filter-sidebar .multiselect-controls {
    flex-direction: column;
    gap: 0.25rem;
}

.filter-sidebar .multiselect-control-btn {
    width: 100%;
    font-size: 0.7rem;
    padding: 0.3rem;
}

.filter-sidebar .custom-multiselect {
    position: relative;
}

.filter-sidebar .multiselect-dropdown {
    position: absolute;
    z-index: 1000;
    background: white;
    width: 100%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ========== SUMMARY RESULTS TABLE ========== */
.summary-table-container {
    overflow: auto;
    max-width: 100%;
    max-height: 85vh;
    margin-top: 1rem;
}

.summary-legend {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    padding: 1rem;
    background: #f9f9f9;
    border-radius: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.legend-color {
    width: 18px;
    height: 18px;
    border: 1px solid #ccc;
    border-radius: 3px;
}

.summary-table {
    border-collapse: collapse;
    font-size: 0.75rem;
    table-layout: fixed;
    width: max-content;
    min-width: 100%;
}

.summary-table th,
.summary-table td {
    border: 1px solid #ddd;
    padding: 6px 10px;
    text-align: center;
    white-space: nowrap;
}

.summary-table th {
    background: var(--costello-primary);
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.summary-table .header-row-2 th {
    background: #a61c6b;
    font-size: 0.7rem;
    top: 40px;  /* Position below first header row */
}

.summary-table .estimand-header {
    background: #2c3e50 !important;
    color: white;
    font-weight: bold;
    text-align: left;
    padding: 8px 12px;
}

.summary-table .outcome-cell {
    text-align: left;
    font-weight: normal;
    background: #f9f9f9;
    min-width: 200px;
}

.summary-table .effect-measure-cell {
    background: #f0f0f0;
    font-weight: bold;
    min-width: 50px;
}

/* Color coding for statistical significance */
.summary-table .sig-favorable {
    background: #1a7f37;
    color: black;
}

.summary-table .nonsig-favorable {
    background: #a3d9a5;
    color: #1a5f2a;
}

.summary-table .nonsig-unfavorable {
    background: #f5c6cb;
    color: #721c24;
}

.summary-table .sig-unfavorable {
    background: #dc3545;
    color: black;
}

.summary-table .no-data {
    background: #e9ecef;
    color: #6c757d;
}

/* Hover effect for data cells */
.summary-table td:not(.outcome-cell):not(.effect-measure-cell):not(.estimand-header):hover {
    outline: 2px solid var(--costello-primary);
    outline-offset: -2px;
    cursor: pointer;
}

/* Tooltip for full CI on hover */
.summary-table td[title] {
    cursor: help;
}

/* ===== FREEZE PANES: Sticky columns (first 4 columns) ===== */
.summary-table .sticky-col {
    position: sticky;
    z-index: 5;
}

/* Column left positions (cumulative based on min-widths) */
.summary-table .sticky-col-1 {
    left: 0;
    min-width: 100px;
    max-width: 100px;
}

.summary-table .sticky-col-2 {
    left: 100px;
    min-width: 250px;
    max-width: 250px;
}

.summary-table .sticky-col-3 {
    left: 350px;
    min-width: 120px;
    max-width: 120px;
}

.summary-table .sticky-col-4 {
    left: 470px;
    min-width: 60px;
    max-width: 60px;
}

/* Header cells need higher z-index (sticky in both directions) */
.summary-table th.sticky-col {
    z-index: 15;
}

/* Ensure solid backgrounds for sticky cells (prevent see-through) */
.summary-table td.sticky-col-1,
.summary-table td.sticky-col-3 {
    background: #f9f9f9;
}

.summary-table td.sticky-col-2 {
    background: #f9f9f9;
}

.summary-table td.sticky-col-4 {
    background: #f0f0f0;
}

/* Right border shadow on last sticky column for visual separation */
.summary-table .sticky-col-4 {
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

/* Estimand header row - sticky left only, spans all columns */
.summary-table .estimand-header {
    position: sticky;
    left: 0;
    z-index: 5;
}

/* Loading state */
.summary-loading {
    text-align: center;
    padding: 3rem;
    color: var(--costello-gray);
}

.summary-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--costello-primary);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error message */
.summary-error {
    text-align: center;
    padding: 2rem;
    color: #dc3545;
    background: #fff5f5;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
}

/* No data message */
.summary-no-data {
    text-align: center;
    padding: 2rem;
    color: var(--costello-gray);
}

/* ========== TABULATOR OVERRIDES FOR SUMMARY TABLE ========== */

/* Make summary table use full available width */
#summary-panel .content-card {
    padding: 1rem 0.5rem;
}

#summary-results-container {
    width: 100%;
}

/* Container styling */
#summary-tabulator {
    width: 100%;
    font-family: 'Tahoma', sans-serif;
    font-size: 0.75rem;
}

/* Header styling - Costello purple */
#summary-tabulator .tabulator-header {
    background: var(--costello-primary);
    color: white;
    border-bottom: 2px solid #6a0d45;
}

#summary-tabulator .tabulator-col {
    background: var(--costello-primary);
    border-right: 1px solid #a61c6b;
}

#summary-tabulator .tabulator-col-title {
    color: white;
    font-weight: 600;
    white-space: normal;
    text-overflow: clip;
}

/* Column group headers (Reference treatment names) */
#summary-tabulator .tabulator-col-group .tabulator-col-group-cols {
    background: #a61c6b;
}

#summary-tabulator .tabulator-col-group-cols .tabulator-col {
    background: #a61c6b;
}

/* Frozen columns styling */
#summary-tabulator .tabulator-frozen {
    background: #f9f9f9;
    border-right: 1px solid #ddd;
}

#summary-tabulator .tabulator-frozen.tabulator-col {
    background: var(--costello-primary);
}

/* Last frozen column shadow */
#summary-tabulator .tabulator-cell.frozen-col-last,
#summary-tabulator .tabulator-col.frozen-col-last {
    box-shadow: 3px 0 6px rgba(0,0,0,0.15);
}

/* Category column visual merge - hide duplicate values */
#summary-tabulator .tabulator-cell.merged-cell {
    border-top: none !important;
    background: #f9f9f9;
}

#summary-tabulator .tabulator-cell.merged-cell-first {
    vertical-align: top;
    font-weight: 600;
    border-top: 2px solid #840B55 !important;
}

/* Row styling */
#summary-tabulator .tabulator-row {
    border-bottom: 1px solid #eee;
}

#summary-tabulator .tabulator-row:hover {
    background: #f5f5f5;
}

#summary-tabulator .tabulator-cell {
    border-right: 1px solid #eee;
    padding: 6px 8px;
}

/* Group header styling (Estimand headers) */
#summary-tabulator .tabulator-group {
    background: #2c3e50;
    color: white;
    font-weight: bold;
    padding: 8px 12px;
    border: none;
}

#summary-tabulator .tabulator-group .tabulator-group-title {
    font-size: 0.85rem;
}

#summary-tabulator .tabulator-group .tabulator-group-count {
    color: #a0a0a0;
    font-weight: normal;
    font-size: 0.75rem;
    margin-left: 8px;
}

#summary-tabulator .tabulator-group:hover {
    background: #34495e;
    cursor: pointer;
}

/* ===== COLOR CODING FOR STATISTICAL SIGNIFICANCE (Tabulator cells) ===== */
#summary-tabulator .tabulator-cell-sig-favorable {
    background: #1a7f37 !important;
    color: black !important;
}

#summary-tabulator .tabulator-cell-nonsig-favorable {
    background: #a3d9a5 !important;
    color: black !important;
}

#summary-tabulator .tabulator-cell-nonsig-unfavorable {
    background: #f5c6cb !important;
    color: black !important;
}

#summary-tabulator .tabulator-cell-sig-unfavorable {
    background: #dc3545 !important;
    color: black !important;
}

#summary-tabulator .tabulator-cell-nodata {
    background: #e9ecef !important;
    color: black !important;
}

/* Vertical divider between reference treatment groups */
/* Applied to data cells via cssClass property */
#summary-tabulator .tabulator-cell.ref-group-first-col {
    border-left: 4px solid #000000 !important;
    box-shadow: -4px 0 0 0 #000000;
}

/* Applied to header cells via JavaScript after tableBuilt */
#summary-tabulator .tabulator-col.ref-group-first-col {
    border-left: 4px solid #000000 !important;
    box-shadow: -4px 0 0 0 #000000;
}

/* Hover effect for data cells */
#summary-tabulator .tabulator-cell:hover {
    outline: 2px solid var(--costello-primary);
    outline-offset: -2px;
}

/* Placeholder styling */
#summary-tabulator .tabulator-placeholder {
    color: var(--costello-gray);
    padding: 2rem;
}

/* =============================================================================
   RESPONSIVE TABLE SCROLLING
   Makes Plotly tables (league tables) horizontally scrollable on small screens
   ============================================================================= */
#plot-area {
    overflow-x: auto;
}

/* Ensure Plotly tables don't compress too much on small screens */
#plot-area .js-plotly-plot {
    min-width: 900px;
}

/* =============================================================================
   ABOUT PAGE - ACCORDION STYLES
   ============================================================================= */

.about-container {
    max-width: 900px;
    margin: 0 auto;
}

/* Hero section with branding */
.about-hero {
    background: linear-gradient(135deg, var(--costello-primary) 0%, var(--costello-secondary) 100%);
    color: white;
    padding: 2.5rem 2rem;
    border-radius: 12px 12px 0 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.about-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    pointer-events: none;
}

.about-hero h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    position: relative;
}

.about-hero .tagline {
    font-size: 1rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.5;
}

/* Network diagram SVG container */
.network-diagram-container {
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8f4f6 0%, #f0e8ec 100%);
    border-bottom: 3px solid var(--costello-primary);
}

.network-diagram {
    max-width: 500px;
    margin: 0 auto;
    display: block;
}

/* Accordion styles */
.accordion {
    border: 1px solid #e0e0e0;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

.accordion-item {
    border-bottom: 1px solid #e0e0e0;
}

.accordion-item:last-child {
    border-bottom: none;
}

.accordion-header {
    width: 100%;
    padding: 1.25rem 1.5rem;
    background: white;
    border: none;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--costello-primary);
    transition: all 0.3s ease;
}

.accordion-header:hover {
    background: #fdf5f9;
}

.accordion-header.active {
    background: linear-gradient(135deg, #fdf5f9 0%, #f8f0f4 100%);
    border-left: 4px solid var(--costello-primary);
}

.accordion-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--costello-light);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.accordion-header.active .accordion-icon {
    background: var(--costello-primary);
    color: white;
    transform: rotate(180deg);
}

.accordion-icon::before {
    content: '▼';
    font-size: 0.7rem;
    color: var(--costello-primary);
}

.accordion-header.active .accordion-icon::before {
    color: white;
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.3s ease;
    background: white;
}

.accordion-content.open {
    max-height: 2000px;
}

.accordion-body {
    padding: 0 1.5rem 1.5rem 1.5rem;
}

.accordion-body p {
    color: var(--costello-dark);
    line-height: 1.7;
    margin-bottom: 1rem;
}

.accordion-body ul {
    margin: 1rem 0 1rem 1.5rem;
    padding-left: 0.5rem;
}

.accordion-body li {
    margin-bottom: 0.75rem;
    line-height: 1.6;
    color: var(--costello-dark);
}

.accordion-body li strong {
    color: var(--costello-primary);
}

/* Feature cards within accordion */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.feature-card {
    background: linear-gradient(135deg, #fdf5f9 0%, #fff 100%);
    padding: 1.25rem;
    border-radius: 8px;
    border-left: 3px solid var(--costello-accent);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(132, 11, 85, 0.15);
}

.feature-card h4 {
    color: var(--costello-primary);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.feature-card p {
    font-size: 0.9rem;
    margin: 0;
    color: var(--costello-gray);
}

/* Contact section */
.contact-section {
    background: linear-gradient(135deg, var(--costello-secondary) 0%, var(--costello-primary) 100%);
    color: white;
    padding: 1.5rem;
    text-align: center;
    border-radius: 0 0 12px 12px;
}

.contact-section h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.contact-section p {
    margin-bottom: 1rem;
    opacity: 0.9;
    font-size: 0.95rem;
}

.contact-section a {
    color: white;
    text-decoration: underline;
    font-weight: 600;
    transition: opacity 0.2s ease;
}

.contact-section a:hover {
    opacity: 0.8;
}

/* About footer */
.about-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--costello-gray);
    font-size: 0.85rem;
}

.about-footer img {
    height: 28px;
    opacity: 0.7;
    margin-bottom: 0.5rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .about-hero {
        padding: 2rem 1.5rem;
    }

    .about-hero h1 {
        font-size: 1.5rem;
    }

    .accordion-header {
        padding: 1rem 1.25rem;
        font-size: 1rem;
    }

    .accordion-body {
        padding: 0 1.25rem 1.25rem 1.25rem;
    }

    .feature-grid {
        grid-template-columns: 1fr;
    }
}
