/* =========================================================
   Data Lounge Page (data-lounge.html) Styles
   ========================================================= */

.page-header {
    text-align: center;
    padding: 60px 20px;
    background-color: var(--content-bg);
    border-radius: 12px;
    margin-bottom: 50px;
}

.page-header h1 {
    font-size: 3em;
    margin-bottom: 10px;
}

.page-header p {
    font-size: 1.2em;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto;
}

/* Main two-column layout for the lounge */
.lounge-layout-grid {
    display: grid;
    grid-template-columns: 380px 1fr; /* Increased sidebar width from 320px to 380px */
    gap: 40px;
    align-items: flex-start; 
}

/* New Reusable Panel Style */
.lounge-panel {
    background-color: var(--content-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    /* Ensure panel doesn't overflow on mobile */
    max-width: 100%;
    box-sizing: border-box;
}

/* Sidebar is now a layout container for panels */
.lounge-sidebar {
    display: flex;
    flex-direction: column;
    gap: 25px; /* This creates space between the panels */
    position: sticky;
    top: 100px; 
}

.lounge-game-selectors {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.lounge-sidebar .custom-select-wrapper {
    max-width: 100%;
}

#game1-wrapper .custom-select {
    border: 2px solid var(--tgm-green);
}

#game2-wrapper .custom-select {
    border: 2px solid #f1c40f; /* Match chart yellow */
}

.control-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-secondary);
    font-size: 0.9em;
}

.custom-select-wrapper {
    position: relative;
    user-select: none;
    width: 100%;
}

.custom-select {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: #333;
    border: 1px solid #555;
    border-radius: 8px;
    color: #f5f5f5;
    cursor: pointer;
}

.custom-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #333;
    border: 1px solid #555;
    border-top: none;
    border-radius: 0 0 8px 8px;
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.custom-select-options.active {
    display: block;
}

.custom-select-option {
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.custom-select-option:hover {
    background-color: #555;
}

.custom-select .arrow {
    font-size: 1.2em;
    transition: transform 0.2s ease;
}

.custom-select.open .arrow {
    transform: rotate(180deg);
}

.data-lounge-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
}

/* Main content area for tabs and charts */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
    /* Default to visible for desktop to allow tooltips */
    overflow: visible;
    white-space: nowrap;
}

.tab-button {
    padding: 15px 25px;
    cursor: pointer;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1em;
    font-family: var(--font-heading);
    border-bottom: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.tab-button:hover {
    color: var(--text-primary);
}

.tab-button.active {
    color: var(--accent-purple);
    border-bottom-color: var(--accent-purple);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.chart-container {
    background-color: var(--content-bg);
    padding: 30px;
    padding-top: 50px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    width: 100%;
    box-sizing: border-box;
    /* overflow: hidden;  REMOVED to allow tooltips to show */
}

.dropdown-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    color: var(--tgm-dark);
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.9em;
    margin-left: 8px;
}

.dropdown-flag-red { background-color: #e74c3c; }
.dropdown-flag-orange { background-color: #e67e22; }
.dropdown-flag-yellow { background-color: #f1c40f; }

/* =========================================================
   Comparison Card Styles (Revised)
   ========================================================= */

#comparison-card-container.lounge-panel {
    padding: 0; /* Remove padding to allow card to fill the panel */
}

.comparison-card {
    background-color: var(--content-bg-darker);
    border-radius: 12px;
    overflow: hidden; /* Ensures the child corners are rounded */
}

.comp-card-header {
    padding: 8px;
    background-color: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
}

.comp-card-header .tgm-icon {
    width: 50px;
    height: 50px;
    background-image: url('../SVG/icon (4)_TranspTrim3.svg'); /* CORRECTED PATH */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.comp-card-art-section {
    padding: 12px 10px 6px 10px;
}

.comp-card-columns {
    display: flex;
    gap: 10px;
}

.comp-card-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.comp-card-col .game-label {
    width: 100%;
    text-align: center;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.comp-card-col .comp-ranks {
    display: flex;
    justify-content: space-between;
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 3px;
    margin-bottom: 8px;
    box-sizing: border-box;
    align-items: center;
}

.comp-card-col .comp-ranks .hero-rank-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 0;
    padding: 0 2px;
}

.comp-card-col .comp-ranks .hero-rank-item:not(:last-child) {
    border-right: 1px solid var(--border-color-translucent);
}

.comp-card-col .comp-ranks .rank-label {
    font-size: 0.58em;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
    white-space: nowrap;
}

.comp-card-col .comp-ranks .rank-value {
    font-family: var(--font-heading);
    font-size: 1.05em;
    color: var(--tgm-green, #01F5BB);
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
}

.comp-card-col.game2-col .comp-ranks .rank-value {
    color: #f1c40f; /* Match Game 2 yellow theme */
}

.comp-card-col .comp-card-game-art {
    width: 100%;
    height: 185px;
    background-size: cover;
    background-position: top center;
    border-radius: 6px;
}

.comp-card-scores {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    padding: 12px 8px;
    gap: 4px;
    background-color: rgba(0, 0, 0, 0.1);
    align-items: center;
}

.comp-score-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: center;
}

.comp-score-col.labels {
    text-align: center;
    font-weight: 700;
    color: #d1d1d1;
    justify-content: space-around;
    font-size: 0.82em;
    white-space: nowrap;
    padding: 0 4px;
}

.comp-score-col.labels .score-label {
    line-height: 1.2;
}

.comp-score-col .score-value {
    font-size: 1.05em;
    font-weight: 700;
    font-family: var(--font-heading);
    white-space: nowrap;
    line-height: 1.2;
}

.comp-score-col.game1-scores {
    text-align: left;
    align-items: flex-start;
    padding-left: 6px;
}

.comp-score-col.game1-scores .score-value {
    color: var(--tgm-green);
}

.comp-score-col.game2-scores {
    text-align: right;
    align-items: flex-end;
    padding-right: 6px;
}

.comp-score-col.game2-scores .score-value {
    color: #f1c40f; /* Match chart yellow */
}

.comp-score-col .score-value.pending {
    color: var(--text-secondary) !important;
    font-style: italic;
    font-size: 0.85em;
    font-weight: 500;
    font-family: var(--font-body);
}

/* =========================================================
   Mobile Responsiveness
   ========================================================= */
@media (max-width: 992px) {
    .lounge-layout-grid {
        display: block; /* KILL the grid on mobile */
    }

    .lounge-sidebar {
        position: static; /* Remove sticky positioning */
        width: 100%;
        margin-bottom: 30px; /* Create space between stacked elements */
    }

    .lounge-panel {
        width: 100%;
        box-sizing: border-box;
    }

    .page-header {
        padding: 40px 20px;
    }

    .page-header h1 {
        font-size: 2.2em;
    }

    /* Ensure charts don't break layout */
    .chart-container {
        padding: 15px;
        padding-top: 40px; /* Keep extra top padding for tooltips */
    }

    /* Re-enable scrolling for tabs on smaller screens */
    .tabs {
        overflow-x: auto;
    }
}

/* =========================================================
   Phone Specific Fixes (Add this to the bottom)
   ========================================================= */
@media (max-width: 768px) {

    /* 1. Force the layout containers to fit the viewport */
    .lounge-sidebar,
    .lounge-main-content,
    .lounge-panel,
    .chart-container {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0; /* Prevents flex items from forcing overflow */
        margin-left: 0;
        margin-right: 0;
    }

    /* 2. CRITICAL: Override the inline HTML height of 550px */
    .chart-container {
        height: 300px !important;
        padding: 10px; /* Reduce padding to save space */
        padding-top: 30px; /* Keep some top padding for tooltips */
    }

    /* 3. Ensure the canvas inside doesn't overflow */
    canvas {
        max-width: 100% !important;
        height: auto !important;
    }

    /* 4. Fix the drop-down menus to prevent them from pushing width */
    .lounge-game-selectors {
        width: 100%;
    }

    .custom-select-wrapper {
        width: 100%;
    }
}
