/* style.css */

/* --- 1. GLOBAL & FONTS --- */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: #f1f5f9;
    color: #0f172a;
    overflow-x: hidden;
    /* Prevent accidental horizontal scroll */
}

.font-display {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-weight: 900;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

/* --- 2. SCREEN MANAGEMENT --- */
.screen {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.screen.hidden {
    display: none !important;
    opacity: 0;
}

/* --- 3. STATUS TAGS & ATTRIBUTES --- */
.status-tag {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 4px;
    line-height: 1.2;
    text-transform: uppercase;
    margin-right: 4px;
}

.status-tag.temporary {
    background-color: #fca5a5;
    color: #7f1d1d;
    border: 1px solid #f87171;
}

.status-tag.permanent {
    background-color: #86efac;
    color: #14532d;
    border: 1px solid #4ade80;
}

.breakthrough {
    color: #16a34a;
    /* Green-600 */
    font-weight: 800;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.4);
}

/* --- 4. DASHBOARD TABS --- */
.tab-button {
    padding: 0.375rem 0.75rem;
    border-radius: 0.25rem;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    color: #475569;
    text-align: left;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    margin-bottom: 0;
    /* Changed for horizontal layout */
    display: flex;
    align-items: center;
    gap: 0.375rem;
    border: 1px solid transparent;
    flex-shrink: 0;
}

.tab-button:hover {
    background-color: #ffffff;
    color: #0f172a;
}

.tab-button.active {
    background-color: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.15);
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.position-filter-button {
    flex: 0 0 auto;
    border-radius: 2px;
    padding: 0.25rem 0.45rem;
    color: #475569;
    font-size: 0.625rem;
    font-weight: 800;
    line-height: 1.1;
}

.position-filter-button:hover {
    background: #f1f5f9;
}

.position-filter-button.is-active {
    background: #0f172a;
    color: #fff;
}

.stats-league-button {
    flex: 0 0 auto;
    border-radius: 2px;
    padding: 0.375rem 0.625rem;
    color: #475569;
    font-size: 0.6875rem;
    font-weight: 700;
}

.stats-league-button:hover {
    background: #f1f5f9;
}

.stats-league-button.is-active {
    background: #0f172a;
    color: #fff;
}

.stats-popover-option {
    width: 100%;
    border-radius: 2px;
    padding: 0.375rem 0.5rem;
    color: #334155;
    font-size: 0.75rem;
    text-align: left;
}

.stats-popover-option:hover,
.stats-popover-option:focus-visible {
    background: #f1f5f9;
    outline: none;
}

/* --- 5. DEPTH CHART VISUAL FIELD --- */
.visual-field-container {
    position: relative;
    width: 100%;
    height: 380px;
    /* Reduced from 480px to save vertical space */
    background-color: #059669;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 19px, rgba(255, 255, 255, 0.1) 20px),
        repeating-linear-gradient(90deg, transparent, transparent 49px, rgba(255, 255, 255, 0.05) 50px);
    border: 4px solid #064e3b;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.4);
    margin-bottom: 0.5rem;
}

.player-slot-visual {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 48px;
    /* Compact width */
    z-index: 8;
    transition: transform 0.12s ease;
    background: transparent;
    padding: 2px 2px;
    border-radius: 6px;
    border: none;
    box-shadow: none;
    cursor: pointer;
    /* Change to pointer to hint click-to-assign modal */
}

.los-marker {
    position: absolute;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: #3b82f6;
    /* Blue-500 */
    box-shadow: 0 0 10px #2563eb;
    z-index: 5;
    pointer-events: none;
}

.slot-overall {
    position: absolute;
    top: -8px;
    right: -6px;
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

/* Specific Slot Labels */
.slot-label {
    color: #9ca3af;
    /* Gray-400 */
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.slot-player-name {
    min-height: 20px;
}

.slot-rating-bar {
    width: 100%;
}

.slot-rating-fill {
    height: 100%;
    transition: width 0.25s ease;
}

/* Styled Select inside the visual slot */
.player-slot-visual select {
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: 1px solid #374151;
    font-size: 0.75rem;
    padding: 4px 6px;
    width: 160px;
    border-radius: 6px;
    outline: none;
    cursor: pointer;
    display: none;
    /* Hidden by default to reduce clutter */
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
}

.player-slot-visual select:focus {
    border-color: #fbbf24;
    display: block;
}

/* Reveal select when hovering the slot (desktop) */
.player-slot-visual:hover select {
    display: block;
}

.slot-badge {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(3px);
}

.badge-pos {
    font-size: 0.65rem;
    font-weight: 800;
    opacity: 0.95;
}

.badge-name {
    font-size: 0.75rem;
    font-weight: 900;
    margin-top: 2px;
}

.slot-player-name {
    font-size: 0.68rem;
    color: #f3f4f6;
    max-width: 64px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    margin-top: 6px;
    text-align: center;
}

.player-slot-visual.drag-over {
    transform: translate(-50%, -50%) scale(1.18);
    z-index: 40;
}

/* Overall bubble positioned top-right of the slot */
.slot-overall-bubble {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.72rem;
    padding: 4px;
    border: 2px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Tooltip styles */
.slot-tooltip {
    position: absolute;
    background: rgba(17, 24, 39, 0.95);
    color: #fff;
    padding: 8px 10px;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.6);
    z-index: 60;
    width: 220px;
    font-size: 0.82rem;
}

.slot-tooltip .tooltip-name {
    margin-bottom: 6px;
    font-weight: 800;
}

.slot-tooltip .skill-row {
    font-size: 0.78rem;
    color: #d1d5db;
    margin-bottom: 4px;
}

.slot-tooltip .skill-key {
    text-transform: capitalize;
    color: #9ca3af;
    margin-right: 6px;
}

/* --- 6. DEPTH ORDER LIST (New Feature) --- */
/* The sortable list view logic */

.depth-sortable-list {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    min-height: 150px;
}

.depth-order-item {
    user-select: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.depth-order-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border-color: #fbbf24;
    /* Amber highlight border */
}

.depth-order-item.dragging {
    opacity: 0.5;
    background-color: #fef3c7;
    /* Amber-100 */
    border: 2px dashed #d97706;
}

/* The "Rank" number on the left of cards */
.rank-number {
    font-family: 'Bangers', cursive, sans-serif;
    color: #9ca3af;
    /* Gray-400 */
    font-size: 1.25rem;
}

.depth-order-item:nth-child(1) .rank-number {
    color: #16a34a;
    /* Green-600 */
}

.depth-order-item:nth-child(2) .rank-number {
    color: #2563eb;
    /* Blue-600 */
}

/* The X button to remove from depth chart */
.remove-depth-item {
    cursor: pointer;
    padding: 0 4px;
}

/* --- 7. LIVE SIM VISUALS --- */

#sim-scoreboard {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    border-bottom: 3px solid #334155;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* Banners for Offense/Defense text */
#sim-banner-offense,
#sim-banner-defense {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Live Stats Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fadeIn {
    animation: fadeIn 0.3s ease-out forwards;
}

/* Canvas Container */
#field-canvas {
    background-color: #1a4d2e;
    /* Fallback turf green matching field_visualizer.js */
    cursor: crosshair;
}

/* Scrollbar for Log */
#sim-play-log::-webkit-scrollbar {
    width: 6px;
}

#sim-play-log::-webkit-scrollbar-track {
    background: #0f172a;
}

#sim-play-log::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}

#sim-play-log::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* --- 8. MODAL Z-INDEX --- */
#modal {
    z-index: 9999;
    /* Always on top */
    backdrop-filter: blur(2px);
    background-color: rgba(0, 0, 0, 0.6);
}

/* --- 9. DRAG & DROP UTILS --- */
.drag-over {
    /* Visual cue when hovering over a drop target */
    outline: 2px dashed #fbbf24;
    outline-offset: 2px;
}

/* --- 10. ROSTER TABLE --- */
/* Sticky headers for large tables */
.sticky {
    position: sticky;
}

.top-0 {
    top: 0;
}

.left-0 {
    left: 0;
}

.z-10 {
    z-index: 10;
}

.z-20 {
    z-index: 20;
}

/* Corner header stays on top */

/* Zero-specificity zebra striping so Tailwind row highlights (bg-amber-50, etc.) win */
:where(tbody tr:nth-child(odd)) {
    background-color: rgba(248, 250, 252, 0.6);
}

:where(tbody tr:hover) {
    background-color: #f1f5f9;
}

/* --- 11. DEPTH CHART BENCH TABLES --- */
/* Enable horizontal scrolling for bench tables with many columns */
#offense-bench-table,
#defense-bench-table {
    overflow-x: auto;
    display: block;
}

#offense-bench-table table,
#defense-bench-table table {
    width: 100%;
}

#offense-bench-table th,
#offense-bench-table td,
#defense-bench-table th,
#defense-bench-table td {
    white-space: nowrap;
    /* Prevent text wrapping */
    padding: 0.5rem 0.75rem;
}
/* --- 12. DRAFT SCREEN SCROLLING --- */

/* Keep nested desktop panels inside the available height. */
#draft-screen,
#draft-main-layout,
#draft-main-layout > div,
#draft-tab-pool,
#draft-tab-history,
#draft-tab-teams {
    min-height: 0;
}

#draft-main-layout > div:first-child {
    overflow: hidden;
}

#draft-tab-pool > .overflow-auto {
    min-height: 0;
}

/* On narrow screens, stack the panels and allow page-level scrolling. */
@media (max-width: 1023px) {
    body:has(#draft-screen:not(.hidden)) {
        height: auto;
        min-height: 100vh;
        overflow-x: hidden;
        overflow-y: auto;
    }

    body:has(#draft-screen:not(.hidden)) #app-shell {
        flex: 0 0 auto;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    body:has(#draft-screen:not(.hidden)) #draft-screen {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    body:has(#draft-screen:not(.hidden)) #draft-main-layout {
        display: flex;
        flex: 0 0 auto;
        flex-direction: column;
        gap: 0.75rem;
        overflow: visible;
    }

    /* Keep the prospect board at a usable height with its own scrolling table. */
    body:has(#draft-screen:not(.hidden))
    #draft-main-layout > div:first-child {
        flex: 0 0 auto;
        height: 70vh;
        min-height: 400px;
    }

    /* Make the dossier and roster accessible below the board. */
    body:has(#draft-screen:not(.hidden))
    #draft-main-layout > div:last-child {
        flex: 0 0 auto;
        min-height: 85vh;
    }
}
