/* ============================================
   MOBILE RESPONSIVENESS - LBL FANTASY
   Comprehensive mobile-first CSS improvements
   ============================================ */

/* GLOBAL OVERFLOW FIX */
html,
body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

/* Ensure containers don't overflow */
.container,
.nav-container,
.hero,
.section {
    max-width: 100vw;
    overflow-x: hidden;
}

/* Fix mobile menu overflow */
.nav-menu {
    overflow-y: auto;
    overflow-x: hidden;
}

/* ============================================
   MOBILE NAVIGATION (HAMBURGER MENU)
   ============================================ */

/* Mobile menu toggle button */
.nav-mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
}

@media (max-width: 768px) {

    /* Fix Navbar Layout Order */
    .nav-container {
        position: relative;
        justify-content: space-between;
        padding-right: 0.5rem;
        /* Space for burger */
    }

    /* Logo - Left */
    .nav-logo {
        order: 1;
        margin-right: auto;
    }

    /* Actions (Sign In) - Right, before burger */
    .nav-actions {
        order: 2;
        margin-right: 0.5rem;
    }

    .nav-actions .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        min-width: auto;
    }

    /* Burger Menu - Far Right */
    .nav-mobile-toggle {
        display: block;
        order: 3;
        padding: 0.5rem;
        margin-left: 0;
    }

    /* Menu Container - Fixed off-screen */
    .nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        background: rgba(18, 18, 18, 0.98);
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding: 80px 2rem 2rem;
        gap: 1.5rem;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
        z-index: 1000;
        overflow-y: auto;
        border-left: 1px solid rgba(255, 255, 255, 0.1);
    }

    .nav-menu.active {
        right: 0;
        display: flex !important;
    }

    .nav-link {
        font-size: 1.1rem;
        padding: 0.75rem 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .nav-cta {
        margin-top: 1rem;
        text-align: center;
    }

    /* Mobile menu overlay */
    .nav-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .nav-overlay.active {
        display: block;
    }

    .navbar {
        padding: 0.5rem 1rem;
    }

    .logo-text {
        font-size: 1rem;
    }

    .logo-icon {
        width: 28px;
        height: 28px;
    }
}

/* ============================================
   HERO SECTION MOBILE
   ============================================ */

@media (max-width: 768px) {
    .hero {
        min-height: 70vh;
        padding-top: 60px;
    }

    .hero-content {
        padding: 1rem;
    }

    .hero-badge {
        font-size: 0.75rem;
        padding: 0.3rem 0.8rem;
        margin-bottom: 1.5rem;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .title-line:first-child {
        font-size: 0.5em;
    }

    .hero-tagline {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }

    .hero-stats {
        gap: 1rem;
        flex-direction: row;
        justify-content: center;
    }

    .stat {
        padding: 0 0.5rem;
    }

    .stat-value {
        font-size: 1.8rem;
    }

    .stat-label {
        font-size: 0.65rem;
        letter-spacing: 1px;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2rem;
    }

    .hero-stats {
        flex-wrap: nowrap;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

/* ============================================
   TEAMS GRID MOBILE
   ============================================ */

@media (max-width: 600px) {
    .teams-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
        padding: 1rem;
    }

    .team-logo {
        width: 55px;
        height: 55px;
        padding: 10px;
    }

    .team-name {
        font-size: 0.7rem;
    }
}

@media (max-width: 400px) {
    .teams-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .team-logo {
        width: 50px;
        height: 50px;
    }
}

/* ============================================
   PUBLIC FANTASY MOBILE
   ============================================ */

@media (max-width: 900px) {
    .my-roster-section {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .reserves-row {
        border-left: none;
        border-top: 2px solid #F37021;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding: 1rem;
        gap: 0.5rem;
    }

    .court-floor {
        min-height: 350px;
    }

    .game-area::after {
        font-size: 2rem;
        left: 50%;
    }
}

@media (max-width: 768px) {
    .fantasy-section {
        padding: 1rem 0.5rem;
    }

    .fantasy-actions {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .text-gradient {
        font-size: 2rem;
    }

    .header-basket-icon {
        width: 40px;
        height: 40px;
    }

    .court-slot {
        width: 80px !important;
        height: 100px !important;
        flex: 0 0 80px;
    }

    .roster-slot .player-img-container {
        width: 40px;
        height: 40px;
    }

    .roster-slot .slot-player {
        font-size: 0.7rem;
    }

    .roster-slot .slot-meta {
        font-size: 0.55rem;
    }

    .court-row {
        gap: 0.5rem;
    }

    .row-bottom {
        gap: 1rem;
    }

    .row-bottom::before {
        width: 350px;
        height: 175px;
        border-radius: 175px 175px 0 0;
    }

    .court-floor::before {
        width: 120px;
        height: 120px;
    }

    .court-floor::after {
        width: 120px;
        height: 120px;
        bottom: 120px;
    }

    .powerups-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .powerup-btn {
        padding: 0.5rem;
    }

    .powerup-icon {
        font-size: 1rem;
    }

    .powerup-name {
        font-size: 0.6rem;
    }
}

@media (max-width: 480px) {
    .court-slot {
        width: 65px !important;
        height: 85px !important;
        flex: 0 0 65px;
    }

    .roster-slot .player-img-container {
        width: 32px;
        height: 32px;
    }

    .roster-slot .slot-player {
        font-size: 0.6rem;
    }

    .court-floor {
        min-height: 280px;
        padding: 5px;
    }

    .row-bottom::before {
        width: 280px;
        height: 140px;
        border-radius: 140px 140px 0 0;
    }

    .court-floor::before {
        width: 100px;
        height: 100px;
    }

    .court-floor::after {
        width: 100px;
        height: 100px;
        bottom: 100px;
    }

    .game-area::after {
        font-size: 1.5rem;
    }

    .action-card {
        padding: 1rem;
    }

    .action-card h3 {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }

    .team-stats .stat-value {
        font-size: 1.2rem;
    }

    .team-buttons {
        flex-direction: column;
    }
}

/* ============================================
   PLAYER LIST/MODAL MOBILE
   ============================================ */

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 1rem auto;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-header h3 {
        font-size: 1.2rem;
    }

    .modal-body {
        padding: 1rem;
        max-height: 60vh;
    }

    .player-list-item {
        padding: 10px;
    }

    .player-name {
        font-size: 0.9rem;
    }

    .player-details {
        font-size: 0.7rem;
    }

    .player-cost {
        font-size: 1rem;
    }

    .modal-tabs {
        overflow-x: auto;
        padding: 0 0.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .modal-tab {
        padding: 10px 12px;
        font-size: 0.8rem;
        white-space: nowrap;
    }
}

/* ============================================
   AVAILABLE PLAYERS PANEL MOBILE
   ============================================ */

@media (max-width: 768px) {
    .available-players-panel {
        margin-top: 1rem;
    }

    .all-players-header {
        padding: 0.75rem;
    }

    .all-players-header h3 {
        font-size: 1rem;
    }

    .search-wrapper {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .search-wrapper input,
    .search-wrapper select {
        padding: 0.6rem;
        font-size: 0.9rem;
    }

    .players-list-container {
        max-height: 300px;
    }
}

/* ============================================
   SCHEDULE/EVENTS MOBILE
   ============================================ */

@media (max-width: 768px) {
    .schedule-container {
        padding: 0.5rem;
    }

    .match-card {
        padding: 0.75rem;
    }

    .team-info {
        flex-direction: column;
        gap: 0.25rem;
    }

    .team-logo-sm {
        width: 30px;
        height: 30px;
    }

    .team-name-text {
        font-size: 0.75rem;
    }

    .match-score {
        font-size: 1.2rem;
    }
}

/* ============================================
   LEADERBOARD MOBILE
   ============================================ */

@media (max-width: 768px) {
    .leaderboard-container {
        padding: 0.5rem;
    }

    .leaderboard-row {
        grid-template-columns: 40px 1fr 70px;
        padding: 0.75rem;
        gap: 0.5rem;
    }

    .rank-badge {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }

    .manager-name {
        font-size: 0.9rem;
    }

    .manager-team {
        font-size: 0.7rem;
    }

    .points-value {
        font-size: 1rem;
    }
}

/* ============================================
   DASHBOARD MOBILE
   ============================================ */

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .dashboard-card {
        padding: 1rem;
    }

    .stats-row {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .stat-box {
        min-width: calc(50% - 0.25rem);
        padding: 0.75rem;
    }
}

/* ============================================
   RULES PAGE MOBILE
   ============================================ */

@media (max-width: 768px) {
    .rules-container {
        padding: 0 1rem;
    }

    .scoring-table {
        font-size: 0.85rem;
    }

    .scoring-table td,
    .scoring-table th {
        padding: 0.5rem;
    }
}

/* ============================================
   DRAFT ROOM MOBILE
   ============================================ */

@media (max-width: 900px) {
    .draft-room-grid {
        grid-template-columns: 1fr;
    }

    .draft-sidebar {
        order: -1;
    }
}

@media (max-width: 768px) {
    .draft-players-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .draft-player-card {
        padding: 0.75rem;
    }

    .draft-timer {
        font-size: 2rem;
    }

    .turn-indicator {
        font-size: 1rem;
    }

    /* Relax grid for small screens */
    .leagues-list {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================
   BUTTONS & FORMS MOBILE
   ============================================ */

@media (max-width: 480px) {
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.85rem;
    }

    input,
    select,
    textarea {
        font-size: 16px;
        /* Prevents iOS zoom on focus */
    }
}

/* ============================================
   GENERAL UTILITIES
   ============================================ */

/* Hide on mobile */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Show only on mobile */
@media (min-width: 769px) {
    .show-mobile-only {
        display: none !important;
    }
}

/* Text truncation for small screens */
@media (max-width: 480px) {
    .truncate-mobile {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Touch-friendly tap targets */
@media (max-width: 768px) {

    button,
    a,
    .clickable {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Safe area insets for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
    .navbar {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .footer {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}
/* ============================================
   MOBILE RESPONSIVENESS FIXES (COURT & LISTS)
   ============================================ */
@media (max-width: 768px) {

    /* --- COURT SCALING --- */
    /* Shrink the court slots to fit side-by-side */
    .court-slot {
        width: 85px !important;
        min-height: 85px !important;
        padding: 2px !important;
    }

    .roster-slot .slot-player {
        font-size: 0.7rem !important;
        white-space: normal !important;
        /* Allow wrapping */
        line-height: 1.1;
        max-height: 2.4em;
        /* Limit to 2 lines */
        overflow: hidden;
    }

    .roster-slot .player-img-container {
        width: 35px;
        height: 35px;
    }

    .court-row {
        gap: 0.5rem !important;
        /* Reduce gaps between players */
        margin-top: -5px !important;
    }

    /* Adjust row specific gaps */
    .row-middle {
        justify-content: center !important;
        gap: 1rem !important;
    }

    .row-bottom {
        gap: 1rem !important;
    }

    /* Adjust HUD (Budget/fantasy score) */
    .court-hud-row {
        margin-bottom: 0.5rem !important;
        padding: 0 0.5rem !important;
    }

    .hud-widget {
        padding: 0.3rem 0.6rem !important;
        min-width: auto !important;
        width: auto !important;
    }

    .hud-value {
        font-size: 1rem !important;
    }

    /* --- PLAYER SELECTION LIST --- */
    /* Fix truncated names in selection modal */
    .modal-players {
        display: grid;
        grid-template-columns: 1fr;
        /* Use full width for list items */
        gap: 0.5rem;
    }

    .player-select-card {
        width: 100% !important;
        max-width: 100% !important;
        display: flex;
        align-items: center;
        padding: 0.8rem;
    }

    /* Allow name to take available space */
    .player-info {
        flex: 1;
        min-width: 0;
        /* Critical for flex items to shrink */
        padding-right: 10px;
    }

    .player-name {
        font-size: 0.9rem !important;
        white-space: normal !important;
        /* Allow wrap */
        overflow: visible !important;
        text-overflow: clip !important;
    }

    .player-meta {
        font-size: 0.75rem !important;
    }

    /* Ensure Add button doesn't get squished */
    .player-add-btn {
        flex-shrink: 0;
        width: auto !important;
        padding: 0.4rem 0.8rem !important;
    }

    /* Adjust container sizing */
    .court-container {
        height: auto !important;
        min-height: auto !important;
        padding-bottom: 1rem !important;
    }

    .court-floor {
        min-height: 480px !important;
        /* Ensure enough height for rows */
    }
}

/* ============================================
   MOBILE FIXES FOR ACTION CARDS & HUD
   ============================================ */
@media (max-width: 768px) {
    /* Stack Action Cards (Build Team / Powerups) vertically */
    .fantasy-actions {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
        margin-bottom: 1rem !important;
    }

    /* Reduce padding on cards to prevent cut-off */
    .action-card {
        padding: 1rem !important;
        margin: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Fix Court HUD Layout - Remove Title to save space */
    .court-title {
        display: none !important;
    }

    .court-hud-row {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        margin-bottom: 8px !important;
        padding: 0 2px !important;
    }

    /* Style HUD Widgets for better fit */
    .hud-widget {
        background: rgba(0, 0, 0, 0.5) !important;
        backdrop-filter: blur(4px);
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-radius: 8px !important;
        padding: 0.5rem !important;
        width: 48% !important; /* Side by side */
        min-width: auto !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 0 !important;
    }

    .hud-label {
        font-size: 0.7rem !important;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 2px;
        opacity: 0.8;
    }

    .hud-value {
        font-size: 1.2rem !important;
        line-height: 1.2;
    }

    /* Adjust container padding to ensure no horizontal scroll on cards */
    .fantasy-section {
        padding: 0.5rem !important;
    }
}
