/**
 * Responsive Styles - Mobile First
 * Desenvolvido por B20 Conteúdo Digital
 * https://www.b20.com.br
 */

/* Mobile First - Base styles (320px+) */
/* Styles already defined in style.css */

/* Mobile Edge-to-Edge Cards (up to 767px) */
@media (max-width: 767px) {
    .correction-card,
    .settings-group.glass-panel,
    .faq-item.glass-panel,
    .seo-article.glass-panel {
        /* Expand to full viewport width */
        width: 100vw;
        margin-left: calc(-50vw + 50%);
        border-radius: 0;
        border-left: none;
        border-right: none;
        padding: calc(var(--spacing-unit) * 3) calc(var(--spacing-unit) * 2.5);
        box-shadow: none;
        transform: none !important; /* Disable isometric tilts on mobile */
        animation: none !important; /* Disable floating animations */
    }
    
    .text-input {
        border-radius: calc(var(--border-radius) / 2);
        padding: calc(var(--spacing-unit) * 1.5);
    }
    
    .btn-correct {
        width: 100%;
        align-self: center;
    }
}

/* Small Mobile (375px+) */
@media (min-width: 375px) {
    .container {
        padding: 0 20px;
    }
    
    .hero-title {
        font-size: 2.25rem;
    }
    
    .stats-section {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Large Mobile (425px+) */
@media (min-width: 425px) {
    .mode-selector {
        gap: calc(var(--spacing-unit) * 2);
    }
    
    .result-actions {
        gap: calc(var(--spacing-unit) * 2);
    }
    
    .history-filters {
        gap: calc(var(--spacing-unit) * 3);
    }
    
    .comparison-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Tablet Portrait (768px+) */
@media (min-width: 768px) {
    .container {
        padding: 0 32px;
        max-width: 720px;
    }
    
    /* Navigation display logic moved to 1024px breakpoint to prevent header squishing */
    
    .hero-section {
        padding: calc(var(--spacing-unit) * 6) 0;
    }
    
    .hero-title {
        font-size: 3rem;
    }
    
    .hero-subtitle {
        font-size: 1.25rem;
    }
    
    .correction-card {
        padding: calc(var(--spacing-unit) * 6);
    }
    
    .mode-selector {
        max-width: 400px;
        margin: 0 auto calc(var(--spacing-unit) * 4);
    }
    
    .text-input {
        min-height: 150px;
        font-size: 1.1rem;
    }
    
    .btn-correct {
        max-width: 300px;
        margin: 0 auto;
    }
    
    .result-header {
        flex-wrap: nowrap;
    }
    
    .stats-section {
        grid-template-columns: repeat(2, 1fr);
        gap: calc(var(--spacing-unit) * 3);
    }
    
    .history-filters {
        flex-wrap: nowrap;
    }
    
    .search-input {
        min-width: 300px;
    }
    
    .history-header {
        flex-wrap: nowrap;
    }
    
    .history-actions {
        flex-wrap: nowrap;
    }
    
    .setting-item {
        flex-wrap: nowrap;
    }
    
    .faq-container {
        margin: 0 auto;
    }
    
    .toast {
        bottom: 30px;
        max-width: 400px;
    }
}

/* Tablet Landscape / Small Desktop (1024px+) */
@media (min-width: 1024px) {
    .container {
        max-width: 960px;
        padding: 0 40px;
    }
    
    .app-header {
        padding: 0 40px;
    }
    
    .header-logo h1 {
        font-size: 1.5rem;
    }
    
    .hero-section {
        padding: calc(var(--spacing-unit) * 8) 0;
    }
    
    .hero-title {
        font-size: 3.5rem;
    }
    
    .correction-card {
        padding: calc(var(--spacing-unit) * 8);
        max-width: 800px;
        margin: 0 auto calc(var(--spacing-unit) * 6);
    }
    
    .text-input {
        min-height: 180px;
    }
    
    .comparison-grid {
        gap: calc(var(--spacing-unit) * 4);
    }
    
    .stats-section {
        grid-template-columns: repeat(2, 1fr);
        max-width: 600px;
        margin: 0 auto calc(var(--spacing-unit) * 4);
    }
    
    .stat-card {
        padding: calc(var(--spacing-unit) * 4);
    }
    
    .history-item {
        padding: calc(var(--spacing-unit) * 4);
    }
    
    .settings-group {
        padding: calc(var(--spacing-unit) * 4);
    }
    
    .section {
        padding: calc(var(--spacing-unit) * 4) 0;
    }
}

/* Large Desktop (1440px+) */
@media (min-width: 1440px) {
    .container {
        max-width: 1200px;
        padding: 0 48px;
    }
    
    .app-header {
        padding: 0 48px;
    }
    
    .hero-title {
        font-size: 4rem;
    }
    
    .hero-subtitle {
        font-size: 1.375rem;
    }
    
    .correction-card {
        max-width: 900px;
        padding: calc(var(--spacing-unit) * 10);
    }
    
    .stats-section {
        grid-template-columns: repeat(2, 1fr);
        max-width: 700px;
    }
    
    .keyboard-shortcuts {
        display: grid;
    }
}

/* Large Desktop Navigation Safe Zone (1150px+) */
@media (min-width: 1150px) {
    body {
        padding-bottom: 0; /* Remove bottom nav space */
    }

    /* Show desktop navigation */
    .desktop-nav {
        display: flex;
        gap: calc(var(--spacing-unit));
    }
    
    /* Hide bottom navigation */
    .bottom-nav {
        display: none !important;
    }
    
    .desktop-nav .nav-link {
        padding: calc(var(--spacing-unit)) calc(var(--spacing-unit) * 1.5);
        font-size: 0.9rem;
    }
}

@media (min-width: 1440px) {
    .history-list {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
        gap: calc(var(--spacing-unit) * 3);
    }
    
    .settings-group {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* Extra Large Desktop (1920px+) */
@media (min-width: 1920px) {
    .container {
        max-width: 1400px;
    }
    
    .correction-card {
        max-width: 1000px;
    }
    
    .hero-title {
        font-size: 4.5rem;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo-img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Landscape Orientation on Mobile */
@media (max-width: 767px) and (orientation: landscape) {
    .app-header {
        height: 60px;
    }
    
    body {
        padding-top: 60px;
        padding-bottom: 60px;
    }
    
    .bottom-nav {
        height: 60px;
    }
    
    .hero-section {
        padding: calc(var(--spacing-unit) * 2) 0;
    }
    
    .hero-title {
        font-size: 1.75rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .correction-card {
        padding: calc(var(--spacing-unit) * 3);
    }
    
    .text-input {
        min-height: 100px;
    }
    
    .toast {
        bottom: 70px;
    }
}

/* Print Styles */
@media print {
    .app-header,
    .bottom-nav,
    .header-actions,
    .result-actions,
    .history-actions,
    .btn,
    .toast,
    .loading-overlay {
        display: none !important;
    }
    
    body {
        padding: 0;
        background: white;
        color: black;
    }
    
    .section {
        display: block !important;
        page-break-inside: avoid;
    }
    
    .correction-card,
    .history-item,
    .settings-group {
        border: 1px solid #ccc;
        box-shadow: none;
        page-break-inside: avoid;
    }
    
    .corrected-text,
    .comparison-text {
        background: #f9f9f9;
        border: 1px solid #ddd;
    }
    
    a {
        color: black;
        text-decoration: underline;
    }
    
    .b20-link::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}

/* 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;
    }
    
    .spinner {
        animation: none;
        border: 4px solid var(--primary-color);
    }
    
    .skeleton {
        animation: none;
        background: #f0f0f0;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-muted: #000000;
        --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
        --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
        --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .text-input:focus {
        border-width: 3px;
    }
    
    .nav-item.active {
        border: 2px solid var(--primary-color);
    }
}

/* Focus Visible for Keyboard Navigation */
@media (any-hover: none) {
    .btn:hover,
    .nav-item:hover,
    .nav-link:hover {
        transform: none;
        box-shadow: none;
    }
}

/* Touch Device Optimizations */
@media (pointer: coarse) {
    .btn,
    .nav-item,
    .nav-link,
    .btn-icon {
        min-height: 48px;
        min-width: 48px;
    }
    
    .text-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .faq-question {
        min-height: 48px;
    }
    
    .mode-btn {
        min-height: 48px;
    }
}

/* Safe Area Insets for iPhone X+ */
@supports (padding: env(safe-area-inset-top)) {
    body {
        padding-top: max(70px, env(safe-area-inset-top));
    }
    
    .app-header {
        padding-top: env(safe-area-inset-top);
        height: calc(70px + env(safe-area-inset-top));
    }
    
    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(70px + env(safe-area-inset-bottom));
    }
    
    @media (max-width: 767px) {
        body {
            padding-bottom: calc(80px + env(safe-area-inset-bottom));
        }
    }
    
    .toast {
        bottom: calc(80px + env(safe-area-inset-bottom));
    }
    
    @media (min-width: 768px) {
        .toast {
            bottom: calc(30px + env(safe-area-inset-bottom));
        }
    }
}

/* Container Queries (Modern Browsers) */
@supports (container-type: inline-size) {
    .correction-card {
        container-type: inline-size;
        container-name: correction;
    }
    
    @container correction (min-width: 500px) {
        .mode-selector {
            max-width: 400px;
            margin-left: auto;
            margin-right: auto;
        }
        
        .btn-correct {
            max-width: 250px;
            margin-left: auto;
            margin-right: auto;
        }
    }
    
    @container correction (min-width: 700px) {
        .result-actions {
            justify-content: flex-end;
        }
        
        .comparison-grid {
            grid-template-columns: 1fr 1fr;
        }
    }
}

/* Dark Mode Specific Responsive Adjustments */
@media (prefers-color-scheme: dark) {
    @media (max-width: 767px) {
        .app-header {
            background: rgba(18, 18, 18, 0.95);
            backdrop-filter: blur(20px);
        }
        
        .bottom-nav {
            background: rgba(18, 18, 18, 0.95);
            backdrop-filter: blur(20px);
        }
    }
}

/* Hover Capability Detection */
@media (hover: hover) and (pointer: fine) {
    .btn:hover {
        transform: translateY(-2px);
    }
    
    .nav-item:hover:not(.active) {
        background: var(--surface-color);
    }
    
    .history-item:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }
    
    .stat-card:hover {
        transform: translateY(-1px);
        box-shadow: var(--shadow-md);
    }
}

/* No Hover Capability (Touch Devices) */
@media (hover: none) {
    .btn:hover,
    .nav-item:hover,
    .history-item:hover,
    .stat-card:hover {
        transform: none;
        box-shadow: initial;
    }
}
