/* ===========================
   Responsive Design
   =========================== */

/* Tablets and Large Phones */
@media (max-width: 1024px) {
    :root {
        --font-size-2xl: 1.75rem;
        --font-size-xl: 1.25rem;
        --spacing-2xl: 2rem;
    }

    .container {
        padding: 0 1rem;
    }

    .header-content {
        gap: 1rem;
    }

    .nav ul {
        gap: 1rem;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .sports-tabs {
        gap: 0.5rem;
    }

    .tab-btn {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .leagues-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .footer-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablets */
@media (max-width: 768px) {
    :root {
        --font-size-xl: 1.125rem;
        --font-size-2xl: 1.5rem;
        --spacing-xl: 1.5rem;
        --spacing-2xl: 1.5rem;
    }

    .header {
        padding: 1rem 0;
    }

    .header-content {
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
    }

    .logo span {
        display: none;
    }

    /* Mobile Toggle Button */
    .mobile-toggle {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 30px;
        height: 21px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        z-index: 1001;
    }

    .mobile-toggle .bar {
        width: 100%;
        height: 3px;
        background-color: var(--text-color);
        border-radius: 10px;
        transition: all 0.3s linear;
    }

    .mobile-toggle.active .bar:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .mobile-toggle.active .bar:nth-child(2) {
        opacity: 0;
    }

    .mobile-toggle.active .bar:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -8px);
    }

    .nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background-color: var(--bg-secondary);
        padding: 80px 2rem 2rem;
        transition: right 0.3s ease-in-out;
        box-shadow: var(--shadow-lg);
        z-index: 1000;
        display: block !important;
    }

    .nav.active {
        right: 0;
    }

    .nav ul {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .nav a {
        font-size: 1.1rem;
        font-weight: 500;
    }

    .user-section {
        margin-left: auto;
        gap: 0.5rem;
    }

    .menu-open {
        overflow: hidden;
    }

    .search-box {
        flex-basis: 100%;
        order: 4;
    }

    .search-input {
        flex: 1;
    }

    .hero {
        padding: 1.5rem 0;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .sports-tabs {
        flex-direction: column;
    }

    .tab-btn {
        width: 100%;
        padding: 0.75rem;
    }

    .leagues-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 1rem 0;
    }

    .footer {
        padding: 1.5rem 0 1rem;
    }

    /* Forms */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Small Phones */
@media (max-width: 480px) {
    :root {
        --font-size-base: 0.95rem;
        --font-size-sm: 0.8rem;
        --font-size-lg: 1rem;
        --font-size-xl: 1.1rem;
        --spacing-md: 0.75rem;
        --spacing-lg: 1rem;
        --spacing-xl: 1.25rem;
    }

    .container {
        padding: 0 0.75rem;
    }

    .header {
        padding: 0.75rem 0;
    }

    .header-content {
        gap: 0.5rem;
    }

    .logo {
        font-size: 1rem;
    }

    .logo img {
        height: 32px;
    }

    .nav {
        display: none;
    }

    .user-section {
        gap: 0.5rem;
        width: 100%;
    }

    .search-box {
        width: 100%;
    }

    .search-input {
        font-size: 16px;
    }

    .language-selector select {
        font-size: 16px;
    }

    .login-btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    .hero {
        padding: 1rem 0;
    }

    .hero h1 {
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
    }

    .hero p {
        font-size: 0.95rem;
    }

    .sports-section h2,
    .games-section h2,
    .featured-leagues h2 {
        font-size: 1.1rem;
    }

    .sports-tabs {
        gap: 0.5rem;
    }

    .tab-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    .tab-btn i {
        margin-right: 0.25rem;
    }

    .leagues-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .league-card {
        padding: 0.75rem;
    }

    .league-card img {
        max-width: 60px;
        margin-bottom: 0.5rem;
    }

    .league-card h3 {
        font-size: 1rem;
        margin-bottom: 0.25rem;
    }

    .footer-content {
        gap: 1rem;
    }

    .footer-section h3,
    .footer-section h4 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }

    .footer-section a {
        font-size: 0.75rem;
    }

    .social-links {
        gap: 0.5rem;
    }

    .social-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.7rem;
    }

    .main-content {
        padding: 0.75rem 0;
    }

    .footer {
        margin-top: 1rem;
        padding: 1rem 0 0.75rem;
    }

    .footer-bottom {
        padding-top: 0.75rem;
        font-size: 0.7rem;
    }

    /* Forms */
    label {
        font-size: 0.95rem;
    }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    textarea,
    select {
        padding: 0.75rem;
        font-size: 16px;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    /* Buttons */
    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
        width: 100%;
    }

    /* Tabs in admin area */
    .nav-tabs {
        flex-direction: column;
    }

    .nav-tabs button {
        width: 100%;
        text-align: left;
    }

    /* Tables */
    table {
        font-size: 0.8rem;
    }

    table th,
    table td {
        padding: 0.5rem !important;
    }

    /* Cards */
    .card {
        margin-bottom: 1rem;
    }
}

/* Extra Small Phones */
@media (max-width: 360px) {
    :root {
        --font-size-base: 0.875rem;
        --font-size-sm: 0.75rem;
        --spacing-md: 0.5rem;
        --spacing-lg: 0.75rem;
    }

    .search-box {
        flex-direction: column;
    }

    .search-input,
    .search-btn {
        width: 100%;
    }

    .language-selector {
        width: 100%;
    }

    .language-selector select {
        width: 100%;
    }

    .theme-toggle {
        margin-left: auto;
    }
}

/* ===========================
   Landscape Mode (Mobile)
   =========================== */

@media (max-height: 600px) {
    .hero {
        padding: 0.5rem 0;
    }

    .hero h1 {
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }

    .hero p {
        display: none;
    }

    .main-content {
        padding: 0.5rem 0;
    }
}

/* ===========================
   High Resolution Devices
   =========================== */

@media (min-width: 1400px) {
    .container {
        max-width: 1300px;
    }

    :root {
        --font-size-2xl: 2.25rem;
        --font-size-xl: 1.75rem;
    }

    .hero h1 {
        font-size: 3rem;
    }

    .leagues-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

/* ===========================
   Print Styles
   =========================== */

@media print {
    .header,
    .footer,
    .nav,
    .search-box,
    .theme-toggle,
    .login-btn {
        display: none !important;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }

    body {
        background-color: white;
        color: black;
    }

    a {
        color: #0066cc;
    }

    .main-content {
        min-height: auto;
    }
}

/* ===========================
   Touch Device Optimizations
   =========================== */

@media (hover: none) and (pointer: coarse) {
    /* Increase touch target sizes */
    .btn,
    .tab-btn,
    .search-btn,
    a {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Remove hover effects on touch devices */
    .btn:hover,
    .tab-btn:hover,
    a:hover {
        transform: none;
    }

    /* Increase padding for buttons */
    .btn {
        padding: 1rem;
    }
}

/* ===========================
   Dark Mode Media Query
   =========================== */

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
    }

    body {
        background-color: var(--bg-primary);
        color: var(--text-color);
    }
}

@media (prefers-color-scheme: light) {
    :root {
        color-scheme: light;
    }

    body {
        background-color: #ffffff;
        color: #2c3e50;
    }
}

/* ===========================
   Reduced Motion
   =========================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===========================
   Accessibility
   =========================== */

@media (prefers-contrast: more) {
    :root {
        --border-color: #666;
    }

    .btn,
    .tab-btn {
        border: 2px solid currentColor;
    }
}

/* Focus-visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
