/**
 * ============================================
 * DOCSEN  - Responsive CSS
 * Media queries and responsive adjustments
 * ============================================
 */

/* ============================================
   SMALL DEVICES (Landscape phones, 576px+)
   ============================================ */
@media (min-width: 576px) {
    /* Typography */
    h1 {
        font-size: var(--font-size-3xl);
    }

    h2 {
        font-size: var(--font-size-2xl);
    }

    /* Hero */
    .hero__title {
        font-size: var(--font-size-3xl);
    }

    .hero__description {
        font-size: var(--font-size-lg);
    }

    .hero__actions {
        flex-direction: row;
        max-width: none;
    }

    /* OTP Input */
    .otp-input__digit {
        width: 56px;
        height: 64px;
        font-size: var(--font-size-2xl);
    }

    /* Time Slots Grid - responsive with auto-fill */
    .time-slots__grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    }

    /* Modal (center on larger screens) */
    .overlay {
        align-items: center;
        padding: var(--space-4);
    }

    .modal {
        border-radius: var(--radius-xl);
        max-height: 85vh;
    }
}

/* ============================================
   MEDIUM DEVICES (Tablets, 768px+)
   ============================================ */
@media (min-width: 768px) {
    /* Container */
    .container {
        padding-left: var(--space-6);
        padding-right: var(--space-6);
    }

    /* Header */
    .header {
        padding: var(--space-4) 0;
    }

    .header__logo-icon {
        width: 40px;
        height: 40px;
    }

    .header__logo-text {
        font-size: var(--font-size-xl);
    }

    /* Footer */
    .footer__container {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .footer__links {
        flex-direction: row;
        gap: var(--space-6);
    }

    .footer__bottom {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
    }

    /* Sections */
    .section {
        padding: var(--space-12) 0;
    }

    .section--lg {
        padding: var(--space-16) 0;
    }

    .section--hero {
        padding: var(--space-10) 0 var(--space-12);
    }

    .section__title {
        font-size: var(--font-size-2xl);
    }

    /* Hero */
    .hero {
        gap: var(--space-8);
    }

    .hero__title {
        font-size: var(--font-size-4xl);
    }

    .hero__illustration {
        max-width: 400px;
    }

    /* Grid */
    .grid--3-cols {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Search Layout */
    .search-layout {
        flex-direction: row;
        align-items: flex-start;
    }

    .search-layout__filters {
        width: 280px;
        flex-shrink: 0;
        position: sticky;
        top: calc(60px + var(--space-4));
    }

    .search-layout__results {
        flex: 1;
    }

    /* Hospital Layout */
    .hospital-layout {
        flex-direction: row;
        align-items: flex-start;
    }

    .hospital-layout__info {
        flex: 1;
    }

    .hospital-layout__calendar {
        width: 360px;
        flex-shrink: 0;
        position: sticky;
        top: calc(60px + var(--space-4));
    }

    /* Provider Card */
    .provider-card__avatar {
        width: 80px;
        height: 80px;
    }

    .provider-card__avatar svg {
        width: 40px;
        height: 40px;
    }

    /* Map Preview */
    .map-preview {
        height: 200px;
    }

    /* Auth Layout */
    .auth-layout__card {
        padding: var(--space-8);
    }

    /* Time Slots - in constrained calendar sidebar */
    .time-slots__grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }
}

/* ============================================
   LARGE DEVICES (Desktops, 1024px+)
   ============================================ */
@media (min-width: 1024px) {
    /* Grid */
    .grid--3-cols {
        grid-template-columns: repeat(3, 1fr);
    }

    .grid--4-cols {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Search Layout */
    .search-layout__filters {
        width: 320px;
    }

    /* Hospital Layout */
    .hospital-layout__calendar {
        width: 400px;
    }

    /* Hero */
    .hero {
        flex-direction: row;
        text-align: left;
        justify-content: space-between;
    }

    .hero__content {
        max-width: 500px;
    }

    .hero__actions {
        justify-content: flex-start;
        margin-left: 0;
        margin-right: 0;
    }

    .hero__illustration {
        max-width: 480px;
        margin-top: 0;
    }

    /* Time Slots - auto-fill ensures no overflow */
    .time-slots__grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }
}

/* ============================================
   EXTRA LARGE DEVICES (Large desktops, 1200px+)
   ============================================ */
@media (min-width: 1200px) {
    /* Typography */
    :root {
        --font-size-4xl: 3.5rem;
    }

    /* Hero */
    .hero__illustration {
        max-width: 520px;
    }
}

/* ============================================
   REDUCED MOTION
   Respect user preference for 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;
    }
}

/* ============================================
   DARK MODE (Optional - Future Enhancement)
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* 
     * Dark mode styles can be added here in the future
     * For now, we keep the light theme for clarity and accessibility
     * in low-literacy contexts
     */
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */
@media (prefers-contrast: high) {
    :root {
        --color-primary: #1b10b9;
        --color-gray-400: #666666;
        --color-gray-500: #555555;
    }

    .btn--primary {
        border: 2px solid var(--color-black);
    }

    .form-input {
        border-width: 3px;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .header,
    .footer,
    .btn,
    .toast-container {
        display: none !important;
    }

    .page {
        min-height: auto;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--color-gray-300);
    }

    a {
        text-decoration: underline;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: var(--font-size-sm);
    }
}

/* ============================================
   SMALL SCREENS (max 480px)
   ============================================ */
@media (max-width: 480px) {
    .header__auth-btns {
        gap: var(--space-1);
    }

    .header__auth-btn {
        padding: var(--space-1) var(--space-2);
        font-size: var(--font-size-xs);
    }

    /* Full-width buttons on mobile */
    .btn--block-mobile {
        width: 100%;
    }

    /* Hide help button text on very small screens */
    .header__help-btn span {
        display: none;
    }

    .header__help-btn {
        padding: var(--space-2);
    }
}

/* ============================================
   MOBILE FIRST - Base improvements
   ============================================ */

/* Buttons full-width on mobile by default */
.hero__actions .btn {
    width: 100%;
}

@media (min-width: 576px) {
    .hero__actions .btn {
        width: auto;
    }
}

/* Single column grid on mobile */
.grid--mobile-1 {
    grid-template-columns: 1fr;
}

@media (min-width: 576px) {
    .grid--mobile-1 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   TOUCH DEVICE OPTIMIZATIONS
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    .btn {
        min-height: 52px;
    }

    .form-input {
        min-height: 52px;
    }

    /* Disable hover effects */
    .btn--primary:hover:not(:disabled) {
        transform: none;
    }

    .card--clickable:hover {
        transform: none;
    }

    .provider-card:hover {
        transform: none;
    }
}

/* ============================================
   LANDSCAPE ORIENTATION (Mobile)
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .section--hero {
        padding: var(--space-6) 0;
    }

    .hero {
        flex-direction: row;
        gap: var(--space-4);
    }

    .hero__illustration {
        max-width: 200px;
    }

    .auth-layout {
        min-height: auto;
        padding: var(--space-4);
    }
}

/* ============================================
   SAFE AREA INSETS (For notched devices)
   ============================================ */
@supports (padding: max(0px)) {
    .header {
        padding-top: max(var(--space-3), env(safe-area-inset-top));
    }

    .footer {
        padding-bottom: max(var(--space-6), env(safe-area-inset-bottom));
    }

    .modal {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .container {
        padding-left: max(var(--space-4), env(safe-area-inset-left));
        padding-right: max(var(--space-4), env(safe-area-inset-right));
    }
}

/* ============================================
   MOBILE - Hide hero illustration
   ============================================ */
@media (max-width: 767px) {
    .hero__illustration {
        display: none !important;
    }
    
    /* Optimisations pour la section de recherche sur mobile */
    .search-options-section-v2 {
        padding: 3rem 0;
    }
    
    .section__header-v2 {
        margin-bottom: 2rem;
        padding: 0 0.5rem;
    }
    
    .section__badge {
        font-size: 0.75rem;
        padding: 8px 16px;
        gap: 6px;
    }
    
    .section__badge svg {
        width: 14px;
        height: 14px;
    }
    
    .feature-card-v2 {
        padding: 1.5rem 1.25rem;
    }
    
    .feature-card-v2__icon {
        width: 72px;
        height: 72px;
        margin-bottom: 1rem;
    }
    
    .feature-card-v2__icon svg {
        width: 34px;
        height: 34px;
    }
    
    .feature-card-v2__title {
        font-size: 0.9375rem;
    }
    
    .feature-card-v2__description {
        font-size: 0.8125rem;
    }
}

/* Optimisations supplémentaires pour très petits écrans */
@media (max-width: 380px) {
    .search-options-section-v2 {
        padding: 2.5rem 0;
    }
    
    .feature-card-v2 {
        padding: 1.25rem 1rem;
    }
    
    .feature-card-v2__icon {
        width: 64px;
        height: 64px;
    }
    
    .feature-card-v2__icon svg {
        width: 30px;
        height: 30px;
    }
}

/* ============================================
   HOSPITALS & SPECIALTIES CAROUSEL RESPONSIVE
   ============================================ */

/* Indicateurs */
.carousel-indicators {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: var(--space-4);
}

/* Petits écrans - simplifier */
@media (max-width: 480px) {
    .carousel-wrapper {
        padding: 0 32px;
    }
    
    .carousel-btn {
        width: 28px;
        height: 28px;
    }
    
    .carousel-btn svg {
        width: 14px;
        height: 14px;
    }
    
    .specialties-scroll-v2 .specialty-card-v2 {
        flex: 0 0 90px;
        min-width: 90px;
    }
    
    .hospital-card-v2 {
        flex: 0 0 200px;
        min-width: 200px;
    }
    
    .carousel-indicators {
        gap: 4px;
    }
    
    .carousel-indicator {
        width: 6px;
        height: 6px;
    }
    
    .carousel-indicator--active {
        width: 18px;
    }
}

/* Écrans très petits */
@media (max-width: 360px) {
    .carousel-wrapper {
        padding: 0 28px;
    }
    
    .carousel-btn {
        width: 24px;
        height: 24px;
    }
    
    .specialties-scroll-v2 .specialty-card-v2 {
        flex: 0 0 80px;
        min-width: 80px;
    }
    
    .hospital-card-v2 {
        flex: 0 0 180px;
        min-width: 180px;
}
}