/**
 * Responsive Design - Mobile First
 * Desenvolvido por B20 Conteúdo Digital
 */

/* === TABLET (768px+) === */
@media (min-width: 768px) {
    /* Header Navigation */
    .desktop-nav {
        display: flex;
        gap: 8px;
    }
    
    .desktop-nav .nav-link {
        padding: 8px 16px;
        border-radius: 8px;
        color: var(--text-color);
        text-decoration: none;
        transition: var(--transition);
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 0.9rem;
        position: relative;
    }
    
    .desktop-nav .nav-link:hover,
    .desktop-nav .nav-link.active {
        background: var(--primary-color);
        color: #333;
    }
    
    .desktop-nav .nav-link:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
    
    /* Hide Bottom Navigation */
    .bottom-nav {
        display: none !important;
    }
    
    /* Adjust body padding */
    body {
        padding-bottom: 0;
    }
    
    /* Container */
    .container {
        padding: 24px;
        max-width: 720px;
        margin: 0 auto;
    }
    
    /* FAB positioning */
    .fab {
        bottom: 24px;
    }
    
    /* Form improvements */
    .order-form {
        padding: 32px;
        max-width: 500px;
        margin: 0 auto;
    }
    
    /* Orders grid */
    .orders-list {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 20px;
    }
    
    /* FAQ layout */
    .faq-container {
        max-width: 600px;
        margin: 0 auto;
    }
    
    /* Toast positioning */
    .toast-container {
        bottom: 24px;
    }
    
    /* Better hover states */
    .order-card:hover {
        transform: translateY(-4px);
        box-shadow: var(--shadow-lg);
    }
}

/* === DESKTOP (1024px+) === */
@media (min-width: 1024px) {
    .container {
        max-width: 960px;
        padding: 32px;
    }
    
    /* Header improvements */
    .app-header {
        padding: 0 32px;
    }
    
    .header-logo h1 {
        font-size: 1.4rem;
    }
    
    /* Welcome banner */
    .welcome-banner {
        padding: 32px;
    }
    
    .welcome-banner h2 {
        font-size: 1.8rem;
    }
    
    /* Orders grid - 2 columns */
    .orders-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }
    
    /* Form layout */
    .order-form {
        max-width: 500px;
        margin: 0 auto;
    }
    
    /* Order details layout */
    #order-details-content {
        max-width: 700px;
        margin: 0 auto;
    }
    
    /* Timeline improvements */
    .timeline-item {
        margin-bottom: 24px;
    }
    
    .timeline-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .timeline-item:not(:last-child)::after {
        left: 19px;
    }
    
    /* Help section */
    .help-contact {
        max-width: 500px;
        margin: 0 auto;
    }
    
    /* Better button interactions */
    .btn:hover {
        transform: translateY(-2px) scale(1.02);
    }
    
    /* Improved navigation */
    .desktop-nav .nav-link::after {
        content: '';
        position: absolute;
        bottom: -4px;
        left: 50%;
        width: 0;
        height: 2px;
        background: var(--accent-color);
        transition: all 0.3s ease;
        transform: translateX(-50%);
    }
    
    .desktop-nav .nav-link.active::after,
    .desktop-nav .nav-link:hover::after {
        width: 80%;
    }
}

/* === LARGE DESKTOP (1440px+) === */
@media (min-width: 1440px) {
    .container {
        max-width: 1200px;
    }
    
    /* Orders grid - 3 columns */
    .orders-list {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Larger spacing */
    .welcome-banner {
        padding: 40px;
        margin-bottom: 32px;
    }
    
    .section-header {
        margin-bottom: 32px;
    }
    
    /* Enhanced typography */
    .order-name {
        font-size: 1.2rem;
    }
    
    .timeline-title {
        font-size: 1.1rem;
    }
    
    /* Better card layouts */
    .order-card {
        padding: 24px;
    }
    
    .faq-question {
        padding: 24px;
        font-size: 1.1rem;
    }
}

/* === MOBILE LANDSCAPE === */
@media (max-width: 767px) and (orientation: landscape) {
    .welcome-banner {
        padding: 16px;
    }
    
    .welcome-banner h2 {
        font-size: 1.3rem;
    }
    
    .order-form {
        padding: 20px;
    }
    
    /* Adjust header for landscape */
    .app-header {
        height: 50px;
    }
    
    :root {
        --header-height: 50px;
    }
    
    body {
        padding-top: 50px;
    }
    
    /* Compact navigation */
    .bottom-nav {
        height: 55px;
    }
    
    :root {
        --bottom-nav-height: 55px;
    }
    
    body {
        padding-bottom: 55px;
    }
}

/* === SMALL MOBILE (320px-480px) === */
@media (max-width: 480px) {
    .container {
        padding: 12px;
    }
    
    .welcome-banner {
        padding: 20px 12px;
        margin-bottom: 20px;
    }
    
    .order-form {
        padding: 20px;
    }
    
    .form-group input {
        padding: 14px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .btn {
        padding: 14px 20px;
        font-size: 0.95rem;
    }
    
    .order-card {
        padding: 16px;
    }
    
    .order-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .order-value {
        align-self: flex-end;
    }
    
    .faq-question {
        padding: 16px;
        font-size: 0.95rem;
    }
    
    .faq-answer {
        padding: 0 16px 16px;
    }
    
    /* Smaller timeline */
    .timeline-icon {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }
    
    .timeline-item:not(:last-child)::after {
        left: 13px;
    }
    
    /* Compact toast */
    .toast {
        max-width: 280px;
        font-size: 0.85rem;
        padding: 10px 16px;
    }
    
    /* Better touch targets */
    .nav-item {
        min-height: 52px;
        min-width: 52px;
    }
    
    .btn-icon {
        width: 44px;
        height: 44px;
    }
}

/* === EXTRA SMALL MOBILE (< 360px) === */
@media (max-width: 359px) {
    .header-logo h1 {
        font-size: 1rem;
    }
    
    .welcome-banner h2 {
        font-size: 1.2rem;
    }
    
    .order-name {
        font-size: 1rem;
    }
    
    .container {
        padding: 8px;
    }
    
    .order-form {
        padding: 16px;
    }
    
    .order-card {
        padding: 12px;
    }
    
    /* Stack order meta vertically */
    .order-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* === HIGH DPI DISPLAYS === */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .order-card {
        box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    }
    
    .app-header {
        box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    }
    
    .btn {
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .fab {
        box-shadow: 0 4px 16px rgba(255, 165, 0, 0.3);
    }
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .skeleton {
        animation: none;
        background: #f0f0f0;
    }
    
    .timeline-icon.active {
        animation: none;
    }
    
    .empty-state i {
        animation: none;
    }
    
    .section.active {
        animation: none;
    }
}

/* === PRINT STYLES === */
@media print {
    .app-header,
    .bottom-nav,
    .fab,
    .btn,
    .toast-container,
    .header-actions {
        display: none !important;
    }
    
    body {
        padding: 0;
        color: black;
        background: white;
        font-size: 12pt;
        line-height: 1.4;
    }
    
    .order-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
        margin-bottom: 16px;
        page-break-inside: avoid;
    }
    
    .timeline-item::after {
        background: #ccc;
    }
    
    .welcome-banner {
        background: #f0f0f0 !important;
        color: black !important;
    }
    
    .section {
        display: block !important;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    h1, h2, h3 {
        color: black !important;
    }
}

/* === TOUCH DEVICE OPTIMIZATIONS === */
@media (hover: none) and (pointer: coarse) {
    .btn:hover,
    .order-card:hover,
    .nav-item:hover,
    .faq-question:hover {
        transform: none;
        background: initial;
    }
    
    .btn:active {
        transform: scale(0.98);
    }
    
    .order-card:active {
        transform: scale(0.99);
    }
    
    .nav-item:active {
        background: rgba(255, 255, 0, 0.1);
    }
    
    /* Larger touch targets */
    .btn {
        min-height: 52px;
    }
    
    .nav-item {
        min-height: 56px;
        min-width: 56px;
    }
    
    .faq-question {
        min-height: 56px;
    }
}

/* === CONTAINER QUERIES (Modern Browsers) === */
@supports (container-type: inline-size) {
    .orders-container {
        container-type: inline-size;
        container-name: orders;
    }
    
    @container orders (min-width: 600px) {
        .orders-list {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 20px;
        }
    }
    
    @container orders (min-width: 900px) {
        .orders-list {
            grid-template-columns: repeat(3, 1fr);
        }
    }
    
    @container orders (min-width: 1200px) {
        .orders-list {
            grid-template-columns: repeat(4, 1fr);
        }
    }
}

/* === SAFE AREAS (iPhone X+) === */
@supports (padding: env(safe-area-inset-top)) {
    .app-header {
        padding-top: env(safe-area-inset-top);
        height: calc(var(--header-height) + env(safe-area-inset-top));
    }
    
    body {
        padding-top: calc(var(--header-height) + env(safe-area-inset-top));
    }
    
    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    }
    
    @media (max-width: 767px) {
        body {
            padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
        }
        
        .fab {
            bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 16px);
        }
        
        .toast-container {
            bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 16px);
        }
    }
}

/* === DARK MODE RESPONSIVE === */
@media (prefers-color-scheme: dark) {
    @media (min-width: 768px) {
        .desktop-nav .nav-link:hover,
        .desktop-nav .nav-link.active {
            background: var(--primary-color);
            color: #000;
        }
    }
    
    .order-form {
        background: var(--surface-color);
    }
    
    .faq-container {
        background: var(--surface-color);
    }
    
    .help-contact {
        background: var(--surface-color);
    }
    
    .form-group input {
        background: var(--bg-color);
        border-color: #444;
        color: var(--text-color);
    }
    
    .form-group input:focus {
        border-color: var(--primary-color);
    }
}

/* === FORCED COLORS MODE === */
@media (forced-colors: active) {
    .order-card {
        border: 1px solid ButtonText;
    }
    
    .btn-primary {
        border: 1px solid ButtonText;
    }
    
    .status-icon {
        border: 1px solid ButtonText;
    }
    
    .timeline-icon {
        border: 1px solid ButtonText;
    }
}

/* === VIEWPORT OPTIMIZATIONS === */
@media (max-height: 600px) {
    .welcome-banner {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .section-header {
        margin-bottom: 16px;
    }
    
    .order-form {
        padding: 16px;
    }
    
    .form-group {
        margin-bottom: 16px;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .app-header {
        height: 44px;
    }
    
    :root {
        --header-height: 44px;
    }
    
    body {
        padding-top: 44px;
    }
    
    .bottom-nav {
        height: 50px;
    }
    
    :root {
        --bottom-nav-height: 50px;
    }
    
    body {
        padding-bottom: 50px;
    }
    
    .welcome-banner {
        display: none;
    }
}
