/* Mobile Responsive Styles for Scout Hub */

/* Hide mobile menu toggle on desktop by default */
.mobile-menu-toggle {
    display: none;
}

/* Mobile breakpoints */
@media (max-width: 768px) {
    
    /* Global mobile fixes */
    * {
        max-width: 100%;
        box-sizing: border-box;
    }
    
    body, html {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }
    
    
    /* Header adjustments */
    header {
        padding: 0;
        position: relative;
        width: 100%;
        overflow: visible;
        z-index: 1010;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding: 10px 15px;
        width: 100%;
        box-sizing: border-box;
        max-width: 100%;
    }
    
    .logo-section {
        width: 100%;
        justify-content: space-between;
        box-sizing: border-box;
        flex-wrap: wrap;
    }
    
    .logo-icon {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
    
    .logo-text h1 {
        font-size: 18px;
    }
    
    .subtitle {
        font-size: 11px;
    }
    
    /* Mobile navigation */
    nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #fafaf9 !important;
        border: 1px solid var(--border-color);
        border-top: none;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        z-index: 1020;
    }
    
    /* Force dark mode nav background */
    [data-theme="dark"] nav {
        background: #1a1a1a !important;
    }
    
    nav.mobile-open {
        display: block !important;
        animation: slideDown 0.3s ease;
    }
    
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    nav ul {
        flex-direction: column;
        margin: 0;
        padding: 0;
    }
    
    nav li {
        width: 100%;
        border-bottom: 1px solid var(--border-color);
    }
    
    nav li:last-child {
        border-bottom: none;
    }
    
    nav a {
        display: flex;
        align-items: center;
        padding: 15px 20px;
        font-size: 16px;
        color: var(--text-secondary, #666);
    }
    
    nav a i {
        margin-right: 12px;
        width: 20px;
        font-size: 18px;
    }
    
    nav a:hover,
    nav a.active {
        background: var(--bg-card);
        color: var(--gold-color);
    }
    
    /* Mobile hamburger menu */
    .mobile-menu-toggle {
        display: block;
        background: none;
        border: none;
        font-size: 24px;
        color: var(--text-primary, #333);
        cursor: pointer;
        padding: 8px;
        margin-left: auto;
        z-index: 1001;
        position: relative;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        min-width: 44px;
        min-height: 44px;
    }
    
    /* User section on mobile */
    .user-section {
        width: 100%;
        justify-content: space-between;
        margin-top: 10px;
    }
    
    .dark-mode-toggle {
        padding: 6px 10px;
        font-size: 13px;
    }
    
    .dark-mode-toggle span {
        display: none;
    }
    
    .user-avatar span {
        display: none;
    }
    
    /* Main content adjustments */
    main {
        padding: 10px;
        margin: 0;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    section {
        padding: 10px;
        margin-bottom: 15px;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    /* Hero sections */
    .hero-section {
        padding: 20px 0;
        text-align: center;
    }
    
    .hero-section h2 {
        font-size: 24px;
        margin-bottom: 8px;
    }
    
    .hero-section p {
        font-size: 14px;
    }
    
    /* Stats container */
    .stats-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .stat-item {
        padding: 20px 15px;
    }
    
    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .stat-content h3 {
        font-size: 22px;
    }
    
    /* Player filters */
    .player-filters {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .filter-group {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .filter-btn {
        padding: 10px 12px;
        font-size: 13px;
        min-height: 44px; /* Touch-friendly */
        flex: 1;
        min-width: calc(50% - 4px);
        text-align: center;
    }
    
    .search-controls {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .search-box {
        width: 100%;
    }
    
    .search-box input,
    .search-input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 40px 12px 12px !important;
        min-height: 44px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .search-icon {
        right: 15px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        font-size: 16px !important;
        z-index: 10;
    }
    
    .add-player-btn,
    .export-all-btn {
        width: 100%;
        padding: 12px;
        font-size: 16px;
        min-height: 44px;
        justify-content: center;
    }
    
    /* Player grid */
    .players-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Player cards */
    .player-card {
        padding: 15px 10px;
        width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }
    
    .player-card-header {
        flex-direction: column;
        align-items: center;
        gap: 15px;
        margin-bottom: 20px;
    }
    
    .player-photo {
        width: 80px;
        height: 80px;
    }
    
    .player-status {
        position: static;
        transform: none;
        margin: 0;
        padding: 6px 12px;
        font-size: 11px;
    }
    
    .player-card-content h3 {
        font-size: 20px;
        text-align: center;
        margin-bottom: 20px;
    }
    
    .player-info-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .info-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px;
        background: var(--bg-secondary, #f8f9fa);
        border-radius: 8px;
    }
    
    .info-label {
        font-weight: 600;
        color: var(--text-secondary, #666);
    }
    
    .info-value {
        font-weight: 500;
        text-align: right;
    }
    
    .player-card-actions {
        flex-direction: column;
        gap: 10px;
        margin-top: 20px;
    }
    
    .player-card-actions button {
        width: 100%;
        padding: 12px;
        font-size: 16px;
        min-height: 44px;
        justify-content: center;
    }
    
    /* Modals on mobile */
    .modal {
        padding: 20px;
        align-items: flex-start;
        /* Ensure touch events work properly */
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    .modal-content {
        width: 100%;
        max-width: none;
        max-height: 90vh;
        overflow-y: auto;
        margin: 0;
        border-radius: 12px;
        /* Explicit pointer events and z-index for mobile */
        pointer-events: auto;
        z-index: 2001;
        touch-action: manipulation;
    }
    
    .modal-header {
        padding: 20px 15px 15px;
    }
    
    .modal-header h2 {
        font-size: 20px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 15px;
    }
    
    /* Explicit mobile form element styling */
    .modal input,
    .modal select,
    .modal textarea,
    .modal button {
        pointer-events: auto !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent;
        min-height: 44px !important;
        font-size: 16px !important; /* Prevent zoom */
        cursor: pointer;
        z-index: 10;
        position: relative;
    }
    
    /* Special handling for select elements on mobile */
    .modal select {
        -webkit-appearance: menulist !important;
        -moz-appearance: menulist !important;
        appearance: menulist !important;
        background-color: var(--bg-card) !important;
    }
    
    /* Checkbox specific styling */
    .modal input[type="checkbox"] {
        min-width: 20px !important;
        min-height: 20px !important;
        transform: scale(1.2); /* Make checkboxes bigger for touch */
    }
    
    .form-group {
        margin-bottom: 20px;
    }
    
    .form-group label {
        font-size: 14px;
        margin-bottom: 8px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
        border-radius: 8px;
    }
    
    .position-checkboxes {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .checkbox-item {
        padding: 12px;
        border: 1px solid var(--border-color, #e0e0e0);
        border-radius: 8px;
        background: var(--bg-secondary, white);
        min-height: 44px;
        align-items: center;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
    }
    
    .form-actions button {
        width: 100%;
        padding: 15px;
        font-size: 16px;
        min-height: 50px;
    }
    
    /* Calendar on mobile */
    .calendar-layout {
        flex-direction: column;
        gap: 20px;
        width: 100%;
        overflow-x: hidden;
    }
    
    .calendar-main {
        order: 2;
        width: 100%;
        overflow-x: hidden;
    }
    
    .calendar-sidebar {
        order: 1;
    }
    
    .calendar-header {
        padding: 15px;
    }
    
    .calendar-header h3 {
        font-size: 18px;
    }
    
    .nav-btn {
        padding: 10px;
        min-height: 44px;
        min-width: 44px;
    }
    
    .calendar-grid {
        font-size: 14px;
        width: 100%;
        overflow-x: auto;
    }
    
    .calendar-container {
        width: 100%;
        overflow-x: auto;
    }
    
    #calendar-container {
        width: 100%;
        overflow-x: auto;
    }
    
    .calendar-day {
        min-height: 60px;
        padding: 8px 4px;
    }
    
    /* Hide quick-add buttons on mobile - too small and interferes with clicking events */
    .quick-add-btn {
        display: none !important;
    }
    
    .calendar-event {
        font-size: 10px;
        padding: 2px 4px;
        margin: 1px 0;
    }
    
    /* Notifications on mobile */
    .notification {
        left: 15px;
        right: 15px;
        width: auto;
        border-radius: 12px;
    }
    
    /* Dashboard cards */
    .dashboard {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .card {
        padding: 20px 15px;
    }
    
    .prospect-item {
        padding: 15px;
        margin-bottom: 10px;
    }
    
    .player-avatar {
        width: 50px;
        height: 50px;
    }
    
    .player-info strong {
        font-size: 16px;
    }
    
    .rating {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    /* Touch improvements */
    button,
    .btn,
    a {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Swipe gestures for player cards */
    .player-card {
        position: relative;
        overflow: hidden;
    }
    
    .player-card.swipe-left {
        transform: translateX(-100px);
        transition: transform 0.3s ease;
    }
    
    .player-card.swipe-right {
        transform: translateX(100px);
        transition: transform 0.3s ease;
    }
    
    /* Loading states on mobile */
    .loading {
        padding: 40px 20px;
        text-align: center;
    }
    
    .loading::after {
        content: "";
        display: inline-block;
        width: 30px;
        height: 30px;
        border: 3px solid var(--border-color, #e0e0e0);
        border-top: 3px solid var(--primary-color, #007bff);
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }
}

/* Very small screens (phones in portrait) */
@media (max-width: 375px) {
    .filter-btn {
        min-width: 100%;
        margin-bottom: 8px;
    }
    
    .stat-content h3 {
        font-size: 20px;
    }
    
    .player-photo {
        width: 70px;
        height: 70px;
    }
    
    .modal {
        padding: 10px;
    }
    
    .modal-content {
        border-radius: 8px;
    }
}

/* Tablet portrait */
@media (min-width: 769px) and (max-width: 1024px) {
    .players-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .filter-group {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 10px;
    }
    
    .filter-btn {
        flex-shrink: 0;
        white-space: nowrap;
    }
    
    .dashboard {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Hide desktop-only elements on mobile */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .desktop-only {
        display: none !important;
    }
}

/* Show mobile-only elements only on mobile */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
}

/* Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Accessibility improvements for touch */
@media (max-width: 768px) {
    /* Larger touch targets */
    button:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 2px solid var(--accent-color, #007bff);
        outline-offset: 2px;
    }
    
    /* Better contrast for touch elements */
    .player-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    button:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
}