/**
 * Desenvolvido por B20 Conteúdo Digital
 * https://www.b20.com.br
 * Todos os direitos reservados
 */

/* Mobile First Responsive Design */

/* Base Mobile Styles (320px+) */
body {
    padding-bottom: 70px;
    /* Space for bottom navigation */
}

/* Bottom Navigation - Mobile Only */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background: var(--surface-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom, 0);
    border-top: 1px solid var(--border-color);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    transition: var(--transition);
    min-width: 60px;
    min-height: 48px;
    border-radius: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item i {
    font-size: 22px;
    transition: transform 0.2s ease;
}

.nav-item.active {
    color: var(--primary-color);
    background: var(--primary-light);
}

.nav-item.active i {
    transform: scale(1.1);
}

.nav-item:hover {
    color: var(--primary-color);
    background: var(--primary-light);
}

/* FAB Style for center nav item */
.nav-item-fab {
    width: 56px;
    height: 56px;
    background: var(--primary-color);
    border-radius: 50%;
    transform: translateY(-20px);
    color: white !important;
    box-shadow: 0 4px 12px rgba(255, 153, 0, 0.4);
    flex-direction: row;
    border: 4px solid var(--surface-color);
    /* Creates a cutout effect */
}

.nav-item-fab:hover {
    background: var(--primary-hover) !important;
    color: white !important;
}

.nav-item-fab i {
    font-size: 24px;
}

.nav-item-fab span {
    display: none;
}

/* Mobile Form Adjustments */
.form-grid {
    grid-template-columns: 1fr;
    gap: 16px;
}

.form-control {
    font-size: 16px;
    /* Prevent zoom on iOS */
}

/* Mobile Hero Section */
.hero-content h2 {
    font-size: 2rem;
}

.hero-stats {
    flex-direction: column;
    gap: 20px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
}

.stat-number {
    font-size: 1.8rem;
}

/* Mobile Feature Cards */
.hero-features {
    grid-template-columns: 1fr;
    gap: 16px;
}

.feature-card {
    padding: 24px 20px;
}

/* Mobile Generator Steps */
.progress-bar {
    flex-direction: column;
    gap: 8px;
}

.progress-step {
    flex-direction: row;
    justify-content: flex-start;
    padding: 12px;
    width: 100%;
}

.step-number {
    margin-right: 12px;
}

/* Mobile Step Actions */
.step-actions {
    flex-direction: column;
    gap: 12px;
}

.generation-actions {
    flex-direction: column;
    gap: 12px;
}

/* Mobile Preview Actions */
.preview-actions {
    flex-direction: column;
    width: 100%;
}

.preview-actions .btn {
    width: 100%;
    justify-content: center;
}

/* Mobile Settings Grid */
.settings-grid {
    grid-template-columns: 1fr;
    gap: 16px;
}

/* Mobile FAQ */
.faq-question {
    font-size: 1rem;
    padding: 16px;
}

.faq-answer {
    padding: 0 16px 16px;
}

/* Mobile Toast Positioning */
.toast-container {
    bottom: 90px;
    /* Above bottom nav */
    left: 16px;
    right: 16px;
    transform: none;
}

.toast {
    width: 100%;
    margin-bottom: 8px;
}

/* Mobile Step Content Adjustment */
.step-content {
    padding: 16px;
}

/* Hybrid Generator Mobile Fixes */
.mode-toggle-container .btn-group {
    width: 100%;
}

.mode-toggle-container .btn {
    flex: 1;
}

.add-controls {
    flex-direction: column;
    width: 100%;
    gap: 12px;
}

.add-controls .form-control,
.add-controls .btn {
    width: 100%;
}

.small-input {
    width: 100% !important;
    /* Override fixed width on mobile */
}

.manual-question-item {
    flex-direction: column;
    align-items: flex-start;
}

.manual-question-item .btn {
    width: 100%;
    margin-top: 8px;
}

.composition-summary-bar {
    margin: 0 -16px -16px -16px;
    /* Flush with reduced padding */
    padding: 16px;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    bottom: 0;
    z-index: 100;
    border-radius: 0 0 12px 12px;
}

.summary-actions {
    width: 100%;
    display: flex;
    gap: 12px;
}

.summary-actions .btn {
    flex: 1;
}

/* Tablet Styles (768px+) */
@media (min-width: 768px) {

    /* Show desktop navigation */
    .desktop-nav {
        display: flex;
        gap: 8px;
    }

    /* Hide text on tablet to prevent crowding */
    .nav-text {
        display: none;
    }

    .desktop-nav .nav-link {
        padding: 8px 12px;
        justify-content: center;
    }

    .desktop-nav .nav-link i {
        font-size: 1.2rem;
        margin: 0;
    }

    /* Hide bottom navigation */
    .bottom-nav {
        display: none !important;
    }

    /* Remove bottom padding */
    body {
        padding-bottom: 0;
    }

    /* Container adjustments */
    .container {
        padding: 0 24px;
        max-width: 720px;
        margin: 0 auto;
    }

    /* Restore Step Content Padding */
    .step-content {
        padding: 32px;
    }

    /* Adjust Summary Bar for Tablet */
    .composition-summary-bar {
        margin: 0 -32px -32px -32px;
        padding: 20px 32px;
        flex-direction: row;
        border-radius: 0 0 12px 12px;
    }

    .summary-actions {
        width: auto;
    }

    .mode-toggle-container .btn-group {
        width: auto;
    }

    .add-controls {
        flex-direction: row;
        width: auto;
    }

    .add-controls .form-control {
        width: auto;
    }

    .add-controls .btn {
        width: auto;
    }

    .small-input {
        width: 80px !important;
    }

    .manual-question-item {
        flex-direction: row;
        align-items: center;
    }

    .manual-question-item .btn {
        width: auto;
        margin-top: 0;
    }

    /* Form grid - 2 columns */
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    /* Hero stats - horizontal */
    .hero-stats {
        flex-direction: row;
        justify-content: center;
        gap: 40px;
    }

    .stat-item {
        flex-direction: column;
        text-align: center;
        background: transparent;
        box-shadow: none;
        border: none;
        padding: 0;
    }

    /* Feature cards - 2 columns */
    .hero-features {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }

    /* Progress bar - horizontal */
    .progress-bar {
        flex-direction: row;
        justify-content: center;
        gap: 24px;
    }

    .progress-step {
        flex-direction: column;
        align-items: center;
        width: auto;
        min-width: 120px;
    }

    .step-number {
        margin-right: 0;
        margin-bottom: 8px;
    }

    /* Step actions - horizontal */
    .step-actions {
        flex-direction: row;
        justify-content: space-between;
    }

    .generation-actions {
        flex-direction: row;
        justify-content: space-between;
    }

    /* Preview actions - horizontal */
    .preview-actions {
        flex-direction: row;
        width: auto;
    }

    .preview-actions .btn {
        width: auto;
    }

    /* Settings grid - 2 columns */
    .settings-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }

    /* Toast positioning */
    .toast-container {
        bottom: 20px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }

    .toast {
        width: auto;
        min-width: 300px;
    }
}

/* Desktop Styles (1024px+) */
@media (min-width: 1024px) {

    /* Container adjustments */
    .container {
        max-width: 960px;
        padding: 0 32px;
    }

    /* Show nav text on desktop */
    .nav-text {
        display: inline;
    }

    .desktop-nav {
        gap: 16px;
    }

    .desktop-nav .nav-link {
        padding: 8px 16px;
        justify-content: flex-start;
    }

    .desktop-nav .nav-link i {
        margin-right: 6px;
    }

    /* Hero content */
    .hero-content h2 {
        font-size: 3rem;
    }

    .hero-subtitle {
        font-size: 1.3rem;
    }

    /* Form grid - 3 columns for some sections */
    .generator-step .form-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Feature cards - 3 columns */
    .hero-features {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Settings grid - 3 columns */
    .settings-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Larger feature cards */
    .feature-card {
        padding: 40px 32px;
    }

    .feature-icon {
        font-size: 3rem;
    }
}

/* Large Desktop (1440px+) */
@media (min-width: 1440px) {
    .container {
        max-width: 1200px;
    }

    .hero-content h2 {
        font-size: 3.5rem;
    }

    .hero-subtitle {
        font-size: 1.4rem;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

    /* Optimize for retina displays */
    .feature-icon,
    .nav-item i {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Landscape Mobile */
@media (max-width: 767px) and (orientation: landscape) {
    .hero-content h2 {
        font-size: 1.8rem;
    }

    .hero-stats {
        flex-direction: row;
        gap: 16px;
    }

    .stat-item {
        flex-direction: column;
        padding: 12px;
    }

    .stat-number {
        font-size: 1.5rem;
    }
}

/* Print Styles */
@media print {

    .app-header,
    .bottom-nav,
    .preview-actions,
    .btn,
    .toast-container,
    .loading-overlay {
        display: none !important;
    }

    body {
        padding-top: 0;
        padding-bottom: 0;
        font-size: 12pt;
        line-height: 1.4;
    }

    .container {
        max-width: none;
        padding: 0;
    }

    .section {
        display: block !important;
        page-break-inside: avoid;
    }

    .exercise-list {
        font-family: 'Times New Roman', serif;
    }

    .question-item {
        page-break-inside: avoid;
        margin-bottom: 20px;
    }

    .answer-key {
        page-break-before: always;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .spinner {
        animation: none;
        border: 4px solid var(--border-color);
        border-top: 4px solid var(--primary-color);
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-secondary: #000000;
        --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.5);
        --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.6);
    }

    .btn {
        border: 2px solid currentColor;
    }

    .form-control {
        border-width: 2px;
    }
}

/* Focus Visible for Keyboard Navigation */
.btn:focus-visible,
.form-control:focus-visible,
.nav-item:focus-visible,
.faq-question:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Safe Area Insets for iPhone X+ */
@supports (padding: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(65px + env(safe-area-inset-bottom));
    }

    body {
        padding-top: max(60px, env(safe-area-inset-top));
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }

    @media (min-width: 768px) {
        body {
            padding-top: max(60px, env(safe-area-inset-top));
            padding-bottom: env(safe-area-inset-bottom);
        }
    }
}

/* Touch Targets - Ensure minimum 44x44px */
.btn,
.nav-item,
.form-control,
.faq-question,
.modal-close {
    min-height: 44px;
    min-width: 44px;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* Loading States for Slow Connections */
@media (max-width: 767px) {
    .skeleton {
        min-height: 20px;
        margin-bottom: 8px;
    }

    .skeleton.skeleton-text {
        height: 16px;
        border-radius: 4px;
    }

    .skeleton.skeleton-title {
        height: 24px;
        width: 60%;
        margin-bottom: 16px;
    }

    .skeleton.skeleton-card {
        height: 120px;
        margin-bottom: 16px;
    }
}