/* ===== RESPONSIVE DESIGN FOR ALL DEVICES ===== */

/* Extra Large Devices (1400px and up) */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
    
    .hero h1 {
        font-size: 4rem;
    }
    
    .feature-card {
        padding: 3rem;
    }
    
    .course-card {
        min-height: 400px;
    }
    
    .stats-item h3 {
        font-size: 3.5rem;
    }
}

/* Large Devices (1200px and up) */
@media (min-width: 1200px) and (max-width: 1399px) {
    .container {
        max-width: 1140px;
    }
    
    .hero h1 {
        font-size: 3.5rem;
    }
    
    .features-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
    }
    
    .courses-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Medium Devices (992px and up) */
@media (min-width: 992px) and (max-width: 1199px) {
    .container {
        max-width: 960px;
    }
    
    .hero h1 {
        font-size: 3rem;
    }
    
    .hero p {
        font-size: 1.1rem;
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .courses-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
    
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
}

/* Small Devices (768px and up) */
@media (min-width: 768px) and (max-width: 991px) {
    .container {
        max-width: 720px;
        padding: 0 1rem;
    }
    
    /* Header adjustments */
    .header {
        padding: 1rem 0;
    }
    
    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--white);
        box-shadow: var(--shadow-lg);
        flex-direction: column;
        padding: 1rem;
        z-index: 1000;
    }
    
    .nav-menu.active {
        display: flex;
    }
    
    .nav-menu li {
        margin: 0.5rem 0;
    }
    
    .mobile-menu-btn {
        display: block;
        background: none;
        border: none;
        font-size: 1.5rem;
        color: var(--primary-color);
        cursor: pointer;
    }
    
    /* Hero section */
    .hero {
        padding: 4rem 0;
        text-align: center;
    }
    
    .hero h1 {
        font-size: 2.5rem;
        margin-bottom: 1rem;
    }
    
    .hero p {
        font-size: 1rem;
        margin-bottom: 2rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }
    
    .hero-buttons .btn {
        width: 100%;
        max-width: 300px;
    }
    
    /* Features section */
    .features-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .feature-card {
        padding: 2rem;
        text-align: center;
    }
    
    /* Courses section */
    .courses-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    /* Stats section */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .stats-item {
        padding: 1.5rem;
    }
    
    .stats-item h3 {
        font-size: 2.5rem;
    }
    
    /* Footer */
    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }
    
    /* Tables */
    .table-container {
        overflow-x: auto;
    }
    
    .data-table {
        min-width: 600px;
    }
    
    /* Forms */
    .form-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .form-group {
        width: 100%;
    }
    
    /* Modals */
    .modal-content {
        width: 90%;
        max-width: 500px;
        margin: 2rem auto;
    }
}

/* Extra Small Devices (576px and up) */
@media (min-width: 576px) and (max-width: 767px) {
    .container {
        max-width: 540px;
        padding: 0 1rem;
    }
    
    .hero h1 {
        font-size: 2rem;
    }
    
    .hero p {
        font-size: 0.95rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stats-item {
        padding: 1rem;
    }
    
    .stats-item h3 {
        font-size: 2rem;
    }
    
    .feature-card {
        padding: 1.5rem;
    }
    
    .course-card {
        padding: 1.5rem;
    }
    
    /* Navigation improvements */
    .nav-brand {
        font-size: 1.3rem;
    }
    
    /* Button adjustments */
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
    }
    
    .btn-sm {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
}

/* Mobile Devices (up to 575px) */
@media (max-width: 575px) {
    .container {
        padding: 0 0.75rem;
    }
    
    /* Header */
    .header {
        padding: 0.75rem 0;
    }
    
    .nav-brand {
        font-size: 1.2rem;
    }
    
    .nav-menu {
        padding: 0.75rem;
    }
    
    /* Hero section */
    .hero {
        padding: 3rem 0;
    }
    
    .hero h1 {
        font-size: 1.75rem;
        line-height: 1.3;
        margin-bottom: 0.75rem;
    }
    
    .hero p {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }
    
    .hero-buttons .btn {
        width: 100%;
        padding: 0.875rem;
        font-size: 0.95rem;
    }
    
    /* Sections */
    .section {
        padding: 3rem 0;
    }
    
    .section-title {
        font-size: 1.75rem;
        margin-bottom: 1rem;
    }
    
    .section-subtitle {
        font-size: 0.9rem;
        margin-bottom: 2rem;
    }
    
    /* Features */
    .feature-card {
        padding: 1.25rem;
    }
    
    .feature-card i {
        font-size: 2rem;
        margin-bottom: 0.75rem;
    }
    
    .feature-card h3 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    .feature-card p {
        font-size: 0.85rem;
    }
    
    /* Courses */
    .course-card {
        padding: 1.25rem;
    }
    
    .course-card h3 {
        font-size: 1.1rem;
    }
    
    .course-card p {
        font-size: 0.85rem;
    }
    
    /* Stats */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .stats-item {
        padding: 1rem;
    }
    
    .stats-item h3 {
        font-size: 1.75rem;
    }
    
    .stats-item p {
        font-size: 0.85rem;
    }
    
    /* Footer */
    .footer {
        padding: 2rem 0 1rem;
    }
    
    .footer-content {
        gap: 1.5rem;
    }
    
    .footer-section h4 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .footer-section ul li {
        margin-bottom: 0.25rem;
    }
    
    .footer-section ul li a {
        font-size: 0.85rem;
    }
    
    .footer-bottom {
        padding-top: 1rem;
        font-size: 0.8rem;
    }
    
    /* Tables - Mobile First Approach */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table {
        min-width: 500px;
        font-size: 0.8rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem 0.25rem;
        white-space: nowrap;
    }
    
    /* Alternative: Card-based table for mobile */
    .mobile-card-table {
        display: none;
    }
    
    @media (max-width: 480px) {
        .data-table {
            display: none;
        }
        
        .mobile-card-table {
            display: block;
        }
        
        .mobile-card {
            background: var(--white);
            border-radius: var(--border-radius);
            padding: 1rem;
            margin-bottom: 1rem;
            box-shadow: var(--shadow-sm);
            border: 1px solid var(--border-color);
        }
        
        .mobile-card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.75rem;
            padding-bottom: 0.75rem;
            border-bottom: 1px solid var(--border-color);
        }
        
        .mobile-card-title {
            font-weight: 600;
            color: var(--primary-color);
        }
        
        .mobile-card-body {
            display: grid;
            gap: 0.5rem;
        }
        
        .mobile-card-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 0.85rem;
        }
        
        .mobile-card-label {
            font-weight: 500;
            color: var(--text-secondary);
        }
        
        .mobile-card-value {
            color: var(--text-primary);
        }
    }
    
    /* Forms */
    .form-row {
        gap: 0.75rem;
    }
    
    .form-group label {
        font-size: 0.9rem;
        margin-bottom: 0.25rem;
    }
    
    .form-control {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    /* Modals */
    .modal-content {
        width: 95%;
        margin: 1rem auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
        gap: 0.5rem;
    }
    
    .modal-footer .btn {
        flex: 1;
        font-size: 0.85rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }
    
    .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
    
    .btn-lg {
        padding: 1rem 1.5rem;
        font-size: 0.95rem;
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .pagination .page-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        min-width: 2.5rem;
    }
    
    /* Search and filters */
    .search-filters {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .search-box {
        width: 100%;
    }
    
    .filter-group {
        width: 100%;
    }
    
    /* Cards grid */
    .cards-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Authentication pages */
    .auth-container {
        padding: 1rem;
    }
    
    .auth-card {
        padding: 1.5rem;
    }
    
    .auth-form .form-group {
        margin-bottom: 1rem;
    }
    
    .auth-form .btn {
        width: 100%;
        padding: 0.875rem;
    }
    
    /* Language toggle */
    .lang-toggle {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* Ultra Small Devices (up to 360px) */
@media (max-width: 360px) {
    .container {
        padding: 0 0.5rem;
    }
    
    .hero h1 {
        font-size: 1.5rem;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .feature-card,
    .course-card {
        padding: 1rem;
    }
    
    .stats-item {
        padding: 0.75rem;
    }
    
    .stats-item h3 {
        font-size: 1.5rem;
    }
    
    .modal-content {
        width: 98%;
        margin: 0.5rem auto;
    }
    
    .btn {
        padding: 0.625rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .mobile-menu-btn,
    .btn,
    .modal,
    .pagination {
        display: none !important;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    .section {
        padding: 1rem 0;
        break-inside: avoid;
    }
    
    .data-table {
        font-size: 0.8rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.25rem;
        border: 1px solid #000;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: #000;
        background: #fff;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000080;
        --secondary-color: #800080;
        --text-primary: #000000;
        --text-secondary: #333333;
        --border-color: #000000;
        --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.8);
        --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.8);
        --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.8);
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .card,
    .modal-content {
        border: 2px solid var(--border-color);
    }
}

/* 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;
    }
    
    .fade-in,
    .slide-up,
    .scale-in {
        animation: none !important;
        transform: none !important;
        opacity: 1 !important;
    }
}

/* Dark Mode Responsive Adjustments */
[data-theme="dark"] .nav-menu {
    background: var(--dark-bg);
    border-top: 1px solid var(--dark-border);
}

[data-theme="dark"] .mobile-card {
    background: var(--dark-card-bg);
    border-color: var(--dark-border);
}

[data-theme="dark"] .modal-content {
    background: var(--dark-bg);
    border-color: var(--dark-border);
}

/* Landscape Orientation for Mobile */
@media (max-width: 767px) and (orientation: landscape) {
    .hero {
        padding: 2rem 0;
    }
    
    .hero h1 {
        font-size: 1.5rem;
    }
    
    .section {
        padding: 2rem 0;
    }
    
    .modal-content {
        max-height: 80vh;
        overflow-y: auto;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .form-control,
    .page-link {
        min-height: 44px; /* Minimum touch target size */
    }
    
    .data-table th,
    .data-table td {
        min-height: 44px;
        padding: 0.75rem 0.5rem;
    }
    
    /* Larger touch targets for interactive elements */
    .nav-menu a,
    .dropdown-item,
    .tab-button {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 0.75rem 1rem;
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover,
    .card:hover,
    .nav-menu a:hover {
        transform: none;
    }
}

/* Extra Mobile Safety: prevent horizontal overflow and clamp widths */
@media (max-width: 767px) {
    html, body { overflow-x: hidden; }
    .nav-container { max-width: 100%; padding: 0 16px; gap: 1rem; }
    .header, .navbar, .hero, .features, .section, .footer { width: 100%; }
    .hero-content { padding: 0 16px; }
}

@media (max-width: 575px) {
    .nav-container { padding: 0 12px; gap: 0.75rem; }
    .search-box { max-width: 100%; }
    .search-box input, .search-input { width: 100%; }
}