/* =================================================================
   TransferPortl Mobile Styles
   ================================================================= */

/* CSS Variables for consistency */
:root {
    --mobile-breakpoint: 768px;
    --mobile-small-breakpoint: 480px;
    --touch-target-min: 44px;
    --brand-green: #00C100;
    --header-bg: #000000;
}

/* =================================================================
   HAMBURGER MENU
   ================================================================= */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
}

.hamburger {
    display: block;
    width: 24px;
    height: 2px;
    background: #fff;
    position: relative;
    transition: background 0.3s ease;
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 2px;
    background: #fff;
    left: 0;
    transition: transform 0.3s ease;
}

.hamburger::before {
    top: -7px;
}

.hamburger::after {
    top: 7px;
}

/* Hamburger animation when open */
.mobile-menu-btn.active .hamburger {
    background: transparent;
}

.mobile-menu-btn.active .hamburger::before {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-btn.active .hamburger::after {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Mobile Navigation Overlay */
.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-nav-overlay.active {
    display: flex;
    opacity: 1;
}

.mobile-nav-overlay a {
    color: #fff;
    font-size: 24px;
    font-weight: 500;
    padding: 20px 40px;
    text-decoration: none;
    font-family: 'Zing Rust Base', 'Roboto Mono', monospace;
    transition: color 0.2s ease;
}

.mobile-nav-overlay a:hover {
    color: var(--brand-green);
    text-decoration: none;
}

.mobile-nav-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    padding: 10px;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
}

/* =================================================================
   RESPONSIVE TABLE TO CARDS
   ================================================================= */
@media (max-width: 768px) {
    /* Hide table headers on mobile */
    .mobile-cards thead {
        display: none;
    }

    /* Each row becomes a card */
    .mobile-cards tbody tr {
        display: block;
        background: #fff;
        border: 1px solid #ddd;
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 12px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }

    /* Each cell becomes a row within the card */
    .mobile-cards tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px solid #eee;
    }

    .mobile-cards tbody td:last-child {
        border-bottom: none;
    }

    /* Data label before each value */
    .mobile-cards tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 11px;
        text-transform: uppercase;
        color: #666;
        flex: 0 0 40%;
    }

    /* Value styling */
    .mobile-cards tbody td > * {
        flex: 0 0 60%;
        text-align: right;
    }
}

/* =================================================================
   TOUCH TARGETS
   ================================================================= */
@media (max-width: 768px) {
    /* Ensure minimum touch target size */
    .touch-target,
    .nav-links a,
    .breadcrumb a,
    .filter-button,
    .pagination a,
    .tab-button,
    button:not(.mobile-menu-btn) {
        min-height: var(--touch-target-min);
        min-width: var(--touch-target-min);
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Larger tap areas for filter dropdowns */
    select {
        min-height: var(--touch-target-min);
        padding: 10px 12px;
        font-size: 16px; /* Prevents iOS zoom */
    }

    /* Input fields - prevent iOS zoom */
    input[type="text"],
    input[type="search"],
    input[type="email"],
    .search-input {
        font-size: 16px !important;
        /* Prevent iOS styling issues */
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        border-radius: 4px;
    }

    /* Ensure header sits above page content so search dropdown is visible */
    .header {
        position: relative;
        z-index: 200;
        overflow: visible;
    }

    /* Fix search container on iOS */
    .search-container {
        position: relative;
        z-index: 100;
    }

    .search-input {
        /* Ensure touch events work */
        -webkit-user-select: text;
        user-select: text;
        touch-action: manipulation;
    }

    .search-results {
        /* Ensure results show above other content on mobile */
        z-index: 9999;
        max-height: 60vh;
        -webkit-overflow-scrolling: touch;
    }
}

/* =================================================================
   MOBILE LAYOUT (768px and below)
   ================================================================= */
@media (max-width: 768px) {
    /* Show hamburger menu */
    .mobile-menu-btn {
        display: block;
    }

    /* Hide desktop nav */
    .nav-links,
    .main-nav {
        display: none !important;
    }

    /* Header adjustments */
    .header-top {
        flex-wrap: wrap;
        padding: 10px 15px;
    }

    .logo img {
        height: 100px !important;
        margin: -20px 0 !important;
    }

    /* Search container - full width below logo */
    .search-container {
        order: 3;
        width: 100%;
        max-width: none;
        margin: 8px 0 0 0;
    }

    /* Stats bar - single row on mobile, no wrapping */
    .stats-bar {
        flex-direction: row;
        flex-wrap: nowrap;
    }

    .stats-content {
        width: 100%;
        display: flex;
        flex-wrap: nowrap;
        align-items: stretch;
    }

    .stat-item {
        padding: 8px 0;
        flex: 1;
        border-right: 1px solid #333;
        justify-content: center;
    }

    .stat-item:last-child {
        border-right: none;
    }

    .stat-number {
        font-size: 20px;
        line-height: 1;
    }

    .stat-label {
        font-size: 9px;
        white-space: nowrap;
        line-height: 1;
        margin-top: 2px;
        letter-spacing: 0.5px;
    }

    /* Hide ticker on mobile */
    .ticker-wrap {
        display: none;
    }

    /* Main container - single column */
    .main-container {
        grid-template-columns: 1fr !important;
        padding: 10px;
        gap: 10px;
    }

    /* Map smaller on mobile */
    #transfer-map {
        height: 220px;
    }

    /* Card headers */
    .card-header {
        font-size: 12px;
        padding: 8px 12px;
    }

    /* ---------------------------------------------------------------
       TABLE FIXES - Core mobile table readability
       --------------------------------------------------------------- */

    /* Allow text to wrap in table cells on mobile */
    .transfer-table td,
    .transfer-table th,
    table td,
    table th {
        white-space: normal !important;
        word-wrap: break-word;
    }

    /* Tables - allow horizontal scroll */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Cards with overflow-x for scrollable tables */
    .card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Regular transfer tables - allow scroll but don't force huge min-width */
    .transfer-table {
        min-width: 500px;
    }

    /* Compact tables - fit to screen, no scroll needed */
    .transfer-table.compact-table,
    .transfer-table.routes-table-compact {
        min-width: unset;
        width: 100%;
    }

    /* Table cell sizing for mobile */
    .transfer-table th,
    .transfer-table td {
        padding: 8px 6px;
        font-size: 12px;
        line-height: 1.3;
    }

    /* Even more compact for homepage tables */
    .compact-table th,
    .compact-table td,
    .routes-table-compact th,
    .routes-table-compact td {
        padding: 6px 4px;
        font-size: 12px;
    }

    /* Roster and ledger tables - inline style overrides */
    .roster-table td,
    .roster-table th {
        padding: 6px 4px;
        font-size: 11px;
    }

    /* Hide/show elements on mobile */
    .hide-mobile {
        display: none !important;
    }

    .show-mobile {
        display: table-cell !important;
    }

    /* Stacked route view for transfer routes on mobile */
    .route-stacked {
        padding: 8px 4px !important;
    }

    .route-stacked .route-from,
    .route-stacked .route-to {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 12px;
    }

    .route-stacked .route-from img,
    .route-stacked .route-to img {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
    }

    .route-stacked .route-arrow {
        color: #00C100;
        font-weight: 700;
        font-size: 10px;
        padding: 2px 0 2px 22px;
    }

    .route-stacked a {
        color: inherit;
        text-decoration: none;
    }

    /* Departures/Arrivals grid - stack on mobile */
    .departures-arrivals-grid {
        grid-template-columns: 1fr !important;
    }

    /* Smaller team logos in tables */
    .team-cell img {
        width: 18px;
        height: 18px;
    }

    /* Smaller headshots */
    .player-headshot,
    .player-headshot-placeholder {
        width: 28px;
        height: 28px;
    }

    /* ---------------------------------------------------------------
       GRID LAYOUTS - Fix grids that use minmax(280px)
       --------------------------------------------------------------- */

    /* Coaching staff, recruits, player grids */
    .player-list,
    [style*="minmax(280px"] {
        grid-template-columns: 1fr !important;
    }

    /* Pipeline grids - stack on mobile */
    .pipelines-grid,
    [style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* ---------------------------------------------------------------
       TEAM PAGE SPECIFIC
       --------------------------------------------------------------- */

    /* Team header - ensure readable on mobile */
    .team-header {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .team-header img {
        max-width: 80px;
        max-height: 80px;
    }

    /* Team stats grid */
    .team-stats {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }

    /* Coaching staff cards */
    .coach-card {
        padding: 10px;
    }

    /* Tab navigation on team pages */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        gap: 0;
    }

    .tabs .tab {
        white-space: nowrap;
        padding: 10px 14px;
        font-size: 12px;
        flex-shrink: 0;
    }
}

/* =================================================================
   SMALL MOBILE (480px and below)
   ================================================================= */
@media (max-width: 480px) {
    .main-container {
        padding: 6px;
    }

    .logo img {
        height: 80px !important;
        margin: -15px 0 !important;
    }

    .stat-item {
        padding: 6px 0;
    }

    .stat-number {
        font-size: 16px;
    }

    .stat-label {
        font-size: 8px;
    }

    #transfer-map {
        height: 160px;
    }

    /* Player cells - keep horizontal but compact */
    .player-cell {
        gap: 4px;
    }

    /* Team cells */
    .team-cell {
        flex-wrap: wrap;
        gap: 4px;
    }

    /* Sidebar transfers more compact */
    .sidebar-transfer {
        padding: 6px 8px;
    }

    .player-headshot,
    .player-headshot-placeholder {
        width: 22px;
        height: 22px;
    }

    /* Even smaller table cells */
    .transfer-table th,
    .transfer-table td {
        padding: 5px 3px;
        font-size: 10px;
    }

    /* Smaller position badges */
    .pos-badge {
        padding: 2px 4px;
        font-size: 8px;
    }

    /* Team logos even smaller */
    .team-cell img {
        width: 14px;
        height: 14px;
    }

    /* Cards need less padding */
    .card-header {
        padding: 6px 8px;
        font-size: 10px;
    }

    .card-body {
        padding: 0 !important;
    }

    /* Filter dropdowns */
    .filters {
        padding: 6px;
        gap: 6px;
    }

    .filter-select {
        padding: 6px 8px;
        font-size: 12px;
    }

    /* Tabs smaller */
    .tabs .tab {
        padding: 8px 10px;
        font-size: 10px;
    }

    /* Search input slightly smaller */
    .search-container {
        margin: 4px 0 0 0 !important;
    }
}

/* =================================================================
   UTILITY CLASSES
   ================================================================= */
/* Hide on desktop, show on mobile */
.show-mobile {
    display: none;
}

.hide-on-mobile {
    display: block;
}

.show-on-mobile {
    display: none;
}

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

    .show-on-mobile {
        display: block !important;
    }
}

/* Scroll hint removed - was causing blurry/faded table edges */

/* Prevent body scroll when mobile menu is open */
body.menu-open {
    overflow: hidden;
}
