/* Reset e configurações básicas */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1e3a8a;
    --secondary-color: #3b82f6;
    --accent-color: #f59e0b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --background: #f8fafc;
    --surface: #ffffff;
    --border: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--background) 0%, #e0e7ff 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Páginas */
.page {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Página Inicial */
.header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

.logo-container {
    margin-bottom: 1.5rem;
}

.logo {
    width: 120px;
    height: 120px;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
    transition: var(--transition);
}

.logo:hover {
    transform: scale(1.05);
}

.logo-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
}

.logo-fallback i {
    font-size: 4rem;
}

.logo-fallback span {
    font-size: 1.5rem;
    font-weight: bold;
}

.main-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.main-content {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 50vh;
}

.selection-card {
    background: var(--surface);
    padding: 3rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    text-align: center;
    border: 1px solid var(--border);
}

.selection-card h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 2rem;
    font-weight: 600;
}

.form-group {
    margin-bottom: 2rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.regional-select {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--border-radius);
    font-size: 1rem;
    background: var(--surface);
    color: var(--text-primary);
    transition: var(--transition);
    cursor: pointer;
}

.regional-select:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.regional-select:hover {
    border-color: var(--secondary-color);
}

.enter-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 auto;
    min-width: 200px;
    justify-content: center;
}

.enter-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.enter-btn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
}

/* Página do Sistema */
.system-header {
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border: 1px solid var(--border);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
}

.logo-small {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.2rem;
}

.logo-small i {
    font-size: 1.5rem;
}

.header-info h1 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.header-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.back-btn {
    background: var(--border);
    color: var(--text-primary);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.back-btn:hover {
    background: var(--text-secondary);
    color: white;
    transform: translateY(-1px);
}

/* Grid de Módulos */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

.module-card {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    position: relative;
    overflow: hidden;
}

.module-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--secondary-color);
    transform: scaleY(0);
    transition: var(--transition);
}

.module-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.module-card:hover::before {
    transform: scaleY(1);
}

.module-icon {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    transition: var(--transition);
}

.module-card:hover .module-icon {
    transform: scale(1.1);
}

.module-content {
    flex: 1;
}

.module-content h3 {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.module-content p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.4;
}

.module-arrow {
    flex-shrink: 0;
    color: var(--text-secondary);
    font-size: 1.2rem;
    transition: var(--transition);
}

.module-card:hover .module-arrow {
    color: var(--secondary-color);
    transform: translateX(4px);
}

/* Responsividade */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .main-title {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .selection-card {
        padding: 2rem 1.5rem;
        margin: 0 10px;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .modules-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .module-card {
        padding: 1.5rem;
        gap: 1rem;
    }

    .module-icon {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .module-content h3 {
        font-size: 1.1rem;
    }

    .module-content p {
        font-size: 0.9rem;
    }

    /* Melhorias para botões no mobile */
    .btn {
        min-height: 44px; /* Tamanho mínimo recomendado para touch */
        padding: 12px 16px;
        font-size: 16px; /* Evita zoom no iOS */
        touch-action: manipulation;
    }

    /* Melhorar área de toque para elementos clicáveis */
    .module-card {
        min-height: 60px;
        touch-action: manipulation;
    }

    /* Garantir que elementos auth sejam clicáveis */
    .auth-required,
    .no-auth {
        min-height: 44px;
        display: flex !important;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
        position: relative;
        z-index: 10;
    }

    /* Melhorar visibilidade dos botões */
    .btn-primary {
        background: var(--primary-color) !important;
        color: white !important;
        border: none !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

    .btn-primary:hover,
    .btn-primary:active {
        background: var(--secondary-color) !important;
        transform: translateY(1px);
    }
}

@media (max-width: 480px) {
    .main-title {
        font-size: 1.8rem;
    }

    .selection-card {
        padding: 1.5rem 1rem;
    }

    .enter-btn {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
        min-width: 180px;
        min-height: 44px;
    }

    .module-card {
        padding: 1.25rem;
        flex-direction: column;
        text-align: center;
        min-height: 80px;
    }

    .module-arrow {
        transform: rotate(90deg);
    }

    .module-card:hover .module-arrow {
        transform: rotate(90deg) translateX(4px);
    }

    /* Garantir que botões sejam sempre clicáveis */
    .btn,
    .auth-required,
    .no-auth {
        pointer-events: auto !important;
        user-select: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
    }

    /* Melhorar contraste e visibilidade */
    .btn-primary {
        background: var(--primary-color) !important;
        color: white !important;
        font-weight: 600;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    }
}

/* Animações adicionais */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.module-card:active {
    transform: translateY(-2px);
}

/* Estados de loading */
.loading {
    animation: pulse 2s infinite;
}

/* Melhorias de acessibilidade */
.module-card:focus {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

.enter-btn:focus,
.back-btn:focus,
.regional-select:focus {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

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

/* Estilos específicos para autenticação */
.auth-required,
.no-auth {
    transition: all 0.3s ease;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.auth-required:hover,
.no-auth:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

/* Garantir que botões sejam sempre clicáveis */
.btn {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

/* Estilos específicos para mobile */
@media (max-width: 768px) {
    .auth-required,
    .no-auth {
        min-height: 44px;
        display: flex !important;
        align-items: center;
        justify-content: center;
        pointer-events: auto !important;
        position: relative;
        z-index: 10;
    }
    
    .btn {
        min-height: 44px;
        font-size: 16px;
        touch-action: manipulation;
        pointer-events: auto !important;
    }
    
    /* Garantir que botões não sejam sobrepostos */
    .module-card {
        position: relative;
        z-index: 1;
    }
    
    .module-card .btn {
        position: relative;
        z-index: 2;
    }
}