/* Comprehensive Responsive Design for Edu-Game */

/* Base responsive breakpoints */
:root {
    --mobile: 480px;
    --tablet: 768px;
    --desktop: 1024px;
    --large: 1280px;
}

/* Mobile-first approach */
* {
    box-sizing: border-box;
}

/* Responsive Typography */
html {
    font-size: 16px;
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }
}

@media (min-width: 1024px) {
    html {
        font-size: 18px;
    }
}

/* Responsive Container */
.container {
    width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 640px) {
    .container {
        max-width: 640px;
        padding: 0 1.5rem;
    }
}

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

@media (min-width: 1024px) {
    .container {
        max-width: 1024px;
        padding: 0 3rem;
    }
}

@media (min-width: 1280px) {
    .container {
        max-width: 1280px;
        padding: 0 4rem;
    }
}

/* Responsive Grid System */
.grid-responsive {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .grid-responsive {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .grid-responsive {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .grid-responsive {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Responsive Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.table-responsive table {
    min-width: 600px;
}

@media (max-width: 768px) {
    .table-responsive table {
        min-width: 100%;
    }

    .table-responsive th,
    .table-responsive td {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
}

/* Responsive Cards */
.card {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    overflow: hidden;
}

@media (max-width: 768px) {
    .card {
        margin: 0.5rem 0;
        border-radius: 0.75rem;
    }
}

/* Responsive Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #374151;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

@media (max-width: 768px) {
    .form-input {
        padding: 1rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Responsive Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    min-height: 44px;
    font-size: 1rem;
}

@media (max-width: 768px) {
    .btn {
        padding: 1rem 1.5rem;
        min-height: 48px;
        font-size: 1rem;
        width: 100%;
        justify-content: center;
    }

    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (min-width: 769px) {
    .btn-group {
        display: flex;
        gap: 0.5rem;
    }
}

/* Responsive Navigation */
.nav-mobile {
    display: block;
}

.nav-desktop {
    display: none;
}

@media (min-width: 768px) {
    .nav-mobile {
        display: none;
    }

    .nav-desktop {
        display: block;
    }
}

/* Responsive Images */
.img-responsive {
    max-width: 100%;
    height: auto;
    display: block;
}

.img-fluid {
    width: 100%;
    height: auto;
}

/* Responsive Videos */
.video-responsive {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
}

.video-responsive iframe,
.video-responsive video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Responsive Spacing */
@media (max-width: 768px) {
    .mobile-p-4 {
        padding: 1rem;
    }

    .mobile-p-6 {
        padding: 1.5rem;
    }

    .mobile-p-8 {
        padding: 2rem;
    }

    .mobile-m-4 {
        margin: 1rem;
    }

    .mobile-m-6 {
        margin: 1.5rem;
    }

    .mobile-m-8 {
        margin: 2rem;
    }
}

/* Responsive Text */
@media (max-width: 768px) {
    .mobile-text-sm {
        font-size: 0.875rem;
    }

    .mobile-text-base {
        font-size: 1rem;
    }

    .mobile-text-lg {
        font-size: 1.125rem;
    }

    .mobile-text-xl {
        font-size: 1.25rem;
    }

    .mobile-text-2xl {
        font-size: 1.5rem;
    }

    .mobile-text-3xl {
        font-size: 1.875rem;
    }
}

/* Responsive Layout */
.layout-mobile {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.layout-desktop {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

@media (max-width: 768px) {
    .layout-desktop {
        display: none;
    }
}

@media (min-width: 769px) {
    .layout-mobile {
        display: none;
    }
}

/* Responsive Sidebar */
.sidebar {
    background: white;
    border-right: 1px solid #e5e7eb;
    padding: 1rem;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }
}

/* Responsive Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

@media (min-width: 768px) {
    .modal-content {
        max-width: 600px;
        padding: 2rem;
    }
}

/* Responsive Game Container */
.game-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

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

/* Responsive Flash Cards */
.flash-card {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    aspect-ratio: 3/4;
    perspective: 1000px;
}

@media (max-width: 768px) {
    .flash-card {
        max-width: 100%;
        aspect-ratio: 4/5;
    }
}

/* Responsive Game Grid */
.game-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

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

@media (min-width: 768px) {
    .game-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 1.5rem;
    }
}

/* Responsive Dashboard */
.dashboard-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1280px) {
    .dashboard-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Responsive Stats Cards */
.stats-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    text-align: center;
}

@media (max-width: 768px) {
    .stats-card {
        padding: 1rem;
    }
}

/* Responsive Charts */
.chart-container {
    width: 100%;
    height: 300px;
    margin: 1rem 0;
}

@media (max-width: 768px) {
    .chart-container {
        height: 250px;
    }
}

/* Responsive Search */
.search-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 2rem;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

@media (max-width: 768px) {
    .search-input {
        padding: 1rem 1.5rem;
        font-size: 16px;
    }
}

/* Responsive Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 2rem 0;
}

.pagination-item {
    padding: 0.5rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    text-decoration: none;
    color: #374151;
    transition: all 0.2s ease;
}

.pagination-item:hover,
.pagination-item.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

@media (max-width: 768px) {
    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .pagination-item {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
}

/* Responsive Alerts */
.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin: 1rem 0;
    border-left: 4px solid;
}

.alert-success {
    background: #f0fdf4;
    border-color: #10b981;
    color: #065f46;
}

.alert-error {
    background: #fef2f2;
    border-color: #ef4444;
    color: #991b1b;
}

.alert-warning {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #92400e;
}

.alert-info {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1e40af;
}

@media (max-width: 768px) {
    .alert {
        padding: 0.75rem;
        margin: 0.5rem 0;
    }
}

/* Responsive Loading States */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Responsive Utilities */
@media (max-width: 768px) {
    .mobile-hidden {
        display: none !important;
    }

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

    .mobile-flex {
        display: flex !important;
    }
}

@media (min-width: 769px) {
    .desktop-hidden {
        display: none !important;
    }

    .desktop-block {
        display: block !important;
    }

    .desktop-flex {
        display: flex !important;
    }
}

/* Print Styles */
@media print {
    .bottom-nav,
    .top-nav,
    .sidebar,
    .footer,
    .btn,
    .search-container {
        display: none !important;
    }

    .container {
        max-width: none;
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #e5e7eb;
    }
}

/* Mobile-specific content spacing */
@media (max-width: 768px) {
    /* Ensure content doesn't overlap with bottom navigation */
    main {
        padding-bottom: 5rem !important;
    }

    /* Better mobile spacing */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Improve table responsiveness */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Card improvements for mobile */
    .card {
        margin: 0.5rem 0;
        border-radius: 0.75rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    /* Mobile-friendly buttons */
    .btn {
        min-height: 48px;
        font-size: 1rem;
    }
}

/* Tablet styles */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* Desktop styles */
@media (min-width: 1025px) {
    .container {
        padding-left: 3rem;
        padding-right: 3rem;
    }
}
