/* =========================================
   Feature 21: Live Tracker (Single Main Scrollbar Fix)
   ========================================= */

/* GLOBAL VARIABLES */
:root {
    --bg-color: #0f172a;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --brand-yellow: #FFCC00;
    --brand-yellow-glow: rgba(255, 204, 0, 0.4);
    --accent-blue: #38bdf8;
    --accent-green: #4ade80;
    --accent-red: #ef4444;
}

/* 1. PAGE LAYOUT - ALLOW MAIN SCROLL */
.live-tracker-page {
    display: flex;
    width: 100%;
    min-height: 100vh;
    /* Allow growth */
    height: auto;
    /* Remove fixed cap */
    position: relative;
    z-index: 1;
    overflow-y: auto;
    /* Enable main window scroll */
    overflow-x: hidden;
    /* Prevent horizontal page scroll */

    /* FORCE NORMAL FONT */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
    font-feature-settings: "zero" 0 !important;
    font-variant-numeric: tabular-nums !important;

    background-color: var(--bg-color);
    background-image:
        radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
}

.live-tracker-page * {
    box-sizing: border-box;
    outline: none;
}

/* 2. LEFT COLUMN: MASTER PANEL */
.live-tracker-master-panel {
    flex: 0 0 540px;
    padding: 15px !important;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 0 !important;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.3);
    z-index: 10;
    height: auto;
    /* Let it grow with page */
    min-height: 100vh;
    /* Ensure it covers full height */
}

/* HEADER AREA */
.live-tracker-master-panel .panel-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0 !important;
    padding-bottom: 12px !important;
    border: none !important;
    min-height: 0 !important;
}

.live-tracker-master-panel .panel-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 !important;
}

.live-tracker-master-panel .panel-title i {
    color: var(--brand-yellow);
    font-size: 20px;
    filter: drop-shadow(0 0 5px rgba(255, 204, 0, 0.3));
}

/* LIST HEADER */
.live-tracker-master-panel .master-list-header {
    display: grid;
    grid-template-columns: 1.8fr 110px 0.7fr;
    gap: 12px;
    padding: 0 10px 6px 10px !important;
    border-bottom: 1px solid var(--glass-border) !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    flex-shrink: 0;
}

.live-tracker-master-panel .col-header {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    padding: 0 !important;
    border: none !important;
}

.col-header.center {
    text-align: center;
}

.col-header.right {
    text-align: center;
}

/* 3. LIST CONTAINER - REMOVE INTERNAL SCROLL */
.master-input-list {
    flex: 1 1 auto;
    /* Allow expansion */
    overflow-y: visible;
    /* No internal scrollbar */
    display: flex;
    flex-direction: column;
    gap: 2px !important;
    padding-top: 8px !important;
    margin-bottom: 15px !important;
    padding-right: 5px;
    min-height: 0;
}

/* MATCH ROW */
.master-match-row {
    display: grid;
    grid-template-columns: 1.8fr 110px 0.7fr;
    align-items: center;
    gap: 12px;
    padding: 5px 10px !important;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: 6px;
    transition: all 0.2s ease;
    min-height: 0 !important;
}

.master-match-row:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
}

.match-info {
    font-size: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    white-space: nowrap;
}

.match-name {
    font-weight: 600;
    color: #fff;
    text-overflow: ellipsis;
    overflow: hidden;
}

.match-num {
    color: var(--brand-yellow);
    font-family: monospace;
    margin-right: 8px;
    opacity: 1;
    font-weight: 700;
}

.match-selection-buttons {
    display: flex;
    gap: 4px;
}

.match-button {
    flex: 1;
    height: 28px !important;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    cursor: pointer;
    font-weight: 700;
    color: var(--text-muted);
    font-size: 11px;
    transition: all 0.2s;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.match-button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.match-button.selected {
    background: var(--brand-yellow) !important;
    color: #000 !important;
    border-color: var(--brand-yellow) !important;
    box-shadow: 0 0 10px var(--brand-yellow-glow);
}

.suggestion-dot {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--brand-yellow);
    border: 1px solid var(--bg-color);
    box-shadow: 0 0 5px var(--brand-yellow);
    z-index: 10;
}

.people-dist-text {
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    display: flex;
    justify-content: space-between;
    opacity: 0.9;
}

.pd-val {
    width: 33%;
    text-align: center;
}

/* 4. FOOTER */
.master-footer-section {
    flex-shrink: 0;
    border-top: 1px solid var(--glass-border);
    padding-top: 15px !important;
    margin-top: 0 !important;
}

.financials-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 10px;
}

.financials-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.financial-group {
    display: flex;
    flex-direction: column;
}

.financial-group label {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    overflow: hidden;
    height: 32px;
}

.input-wrapper input {
    background: transparent;
    border: none;
    color: #fff;
    padding: 0 10px;
    width: 100%;
    font-weight: 700;
    font-size: 13px;
    text-align: right;
    padding-right: 30px;
    z-index: 1;
    height: 100%;
    font-family: inherit !important;
}

.input-wrapper .suffix {
    position: absolute;
    right: 10px;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    pointer-events: none;
}

.financial-summary-container {
    display: flex;
    gap: 15px;
    margin-top: 15px !important;
}

.stat-box {
    flex: 1;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    text-align: center;
}

.stat-box.grand-total {
    background: linear-gradient(135deg, rgba(255, 204, 0, 0.1), rgba(15, 23, 42, 0.4));
    border-color: rgba(255, 204, 0, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.stat-box span {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.stat-box strong {
    display: block;
    font-size: 20px;
    color: #fff;
    font-weight: 700;
    font-family: inherit !important;
}

.stat-box.grand-total strong {
    color: var(--brand-yellow);
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.3);
}

/* RIGHT COLUMN CONTAINER - REMOVE INTERNAL SCROLL */
.live-tracker-systems-container {
    flex: 1;
    display: flex;
    gap: 20px;
    padding: 25px;
    overflow-x: auto;
    /* Keep horizontal scroll for systems if needed */
    overflow-y: visible;
    /* REMOVE Vertical Scrollbar - Let Page Handle It */
    align-items: flex-start;
    height: auto;
    /* Expand freely */
}

.button-stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex-shrink: 0;
}

.add-system-button {
    width: 100%;
    min-width: 160px;
    padding: 15px 20px;
    background: rgba(255, 204, 0, 0.1);
    border: 1px solid var(--brand-yellow);
    border-radius: 8px;
    color: var(--brand-yellow);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.add-system-button:hover {
    background: var(--brand-yellow);
    color: #000;
    box-shadow: 0 0 15px var(--brand-yellow-glow);
    transform: translateY(-2px);
}

.add-system-button span {
    font-size: 18px;
    line-height: 1;
}

/* CONFETTI LAYER */
#global-confetti-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--brand-yellow);
    top: -20px;
    opacity: 0;
}

@keyframes globalConfettiFall {
    0% {
        transform: translateY(-10vh) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0;
    }
}

/* MODALS */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(5px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.modal-box {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid var(--glass-border);
    padding: 30px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border-top: 2px solid var(--accent-red);
    max-width: 400px;
}

.modal-box h3 {
    margin-top: 0;
    color: #fff;
    font-size: 20px;
    margin-bottom: 15px;
}

.modal-box p {
    color: var(--text-muted);
    margin: 0 0 25px 0;
}

.modal-btn {
    background: var(--brand-yellow);
    color: #000;
    border: none;
    padding: 10px 25px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}

.modal-btn:hover {
    box-shadow: 0 0 15px var(--brand-yellow-glow);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- THEMED SCROLLBARS --- */
.live-tracker-page ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.live-tracker-page ::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.live-tracker-page ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.live-tracker-page ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Thinner scrollbar for the match list to be subtle if it happens to scroll */
.master-input-list::-webkit-scrollbar {
    width: 4px;
}