/* ===========================
   Responsive Design
   Mobile-First Approach
   =========================== */

/* ===========================
   Mobile Devices (320px - 767px)
   =========================== */
@media (max-width: 767px) {

    /* Header */
    .header-content {
        padding: var(--spacing-sm);
        flex-direction: column;
        gap: var(--spacing-sm);
    }

    .logo-section {
        flex-direction: column;
        text-align: center;
        gap: var(--spacing-sm);
    }

    .app-logo {
        width: 50px;
        height: 50px;
    }

    .header-text h1 {
        font-size: var(--font-size-xl);
    }

    .header-text p {
        font-size: var(--font-size-xs);
    }

    .user-section {
        width: 100%;
        justify-content: center;
    }

    .btn-icon {
        flex: 1;
        justify-content: center;
    }

    /* Main Content */
    .main-content {
        padding: var(--spacing-md) var(--spacing-sm);
    }

    /* Welcome Section */
    .welcome-card {
        padding: var(--spacing-md);
    }

    .welcome-card h2 {
        font-size: var(--font-size-xl);
    }

    .welcome-card p {
        font-size: var(--font-size-base);
    }

    /* Filter Section */
    .search-input {
        padding: var(--spacing-sm) var(--spacing-md) var(--spacing-sm) 45px;
        font-size: var(--font-size-base);
    }

    .search-icon {
        left: var(--spacing-sm);
        font-size: var(--font-size-lg);
    }

    .filter-buttons {
        justify-content: center;
    }

    .filter-btn {
        flex: 1 1 45%;
        min-width: 120px;
        font-size: var(--font-size-sm);
        padding: var(--spacing-xs) var(--spacing-sm);
    }

    /* Units Grid */
    .modules-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    .module-card {
        padding: var(--spacing-md);
    }

    .module-icon {
        font-size: 2.5rem;
    }

    .module-content h3 {
        font-size: var(--font-size-lg);
    }

    .module-content p {
        font-size: var(--font-size-sm);
    }

    /* Modal */
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .modal-header {
        padding: var(--spacing-md);
    }

    .modal-header h2 {
        font-size: var(--font-size-xl);
    }

    .modal-body {
        padding: var(--spacing-md);
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }

    .stat-card {
        padding: var(--spacing-md);
    }

    .stat-icon {
        font-size: var(--font-size-2xl);
    }

    .stat-value {
        font-size: var(--font-size-2xl);
    }

    .stat-label {
        font-size: var(--font-size-xs);
    }

    /* Touch Targets */
    .module-card,
    .filter-btn,
    .btn-icon {
        min-height: 44px;
    }
}

/* ===========================
   Tablet Devices (768px - 1023px)
   =========================== */
@media (min-width: 768px) and (max-width: 1023px) {

    /* Header */
    .header-content {
        padding: var(--spacing-md);
    }

    .header-text h1 {
        font-size: var(--font-size-2xl);
    }

    /* Main Content */
    .main-content {
        padding: var(--spacing-lg) var(--spacing-md);
    }

    /* Units Grid */
    .modules-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-md);
    }

    /* Modal */
    .modal-content {
        width: 90%;
    }

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

/* ===========================
   Desktop (1024px and above)
   =========================== */
@media (min-width: 1024px) {

    /* Units Grid */
    .modules-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Modal Stats */
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===========================
   Large Desktop (1400px and above)
   =========================== */
@media (min-width: 1400px) {
    .modules-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===========================
   Landscape Mobile
   =========================== */
@media (max-height: 500px) and (orientation: landscape) {
    .header-content {
        padding: var(--spacing-xs) var(--spacing-md);
    }

    .logo-section {
        flex-direction: row;
        gap: var(--spacing-sm);
    }

    .header-text h1 {
        font-size: var(--font-size-lg);
    }

    .header-text p {
        display: none;
    }

    .app-logo {
        width: 40px;
        height: 40px;
    }

    .welcome-section {
        margin-bottom: var(--spacing-md);
    }

    .welcome-card {
        padding: var(--spacing-md);
    }

    .welcome-card h2 {
        font-size: var(--font-size-xl);
    }
}

/* ===========================
   Print Styles
   =========================== */
@media print {

    .app-header,
    .filter-section,
    .modal {
        display: none !important;
    }

    .modules-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }

    .module-card {
        box-shadow: none;
        border: 1px solid var(--color-border);
        page-break-inside: avoid;
    }

    body {
        background: white;
    }
}

/* ===========================
   Reduced Motion
   =========================== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===========================
   High Contrast Mode
   =========================== */
@media (prefers-contrast: high) {
    :root {
        --color-text-dark: #000000;
        --color-bg-white: #FFFFFF;
        --color-border: #000000;
    }

    .module-card {
        border: 2px solid var(--color-text-dark);
    }

    .filter-btn {
        border-width: 2px;
    }
}

/* ===========================
   Dark Mode (Future Enhancement)
   =========================== */
@media (prefers-color-scheme: dark) {
    /* Placeholder for dark mode - can be implemented later */
    /* body {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    } */
}