/* =================================================================== */
/* CONFIGURAÇÕES GERAIS                           */
/* =================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
:root {
    /* Modo Dia (Azul) */
    --bg-primary: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #60a5fa 100%);
    --bg-secondary: rgba(255, 255, 255, 0.95);
    --bg-card: rgba(255, 255, 255, 0.9);
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-white: #ffffff;
    --border-color: rgba(59, 130, 246, 0.2);
    --shadow: rgba(30, 58, 138, 0.1);
    --accent: #3b82f6;
    --success: #10b981;
    --readonly-bg: rgba(243, 244, 246, 0.8);
    --tooltip-bg: #2d3748;
    --tooltip-text: #f7fafc;
    --attention-bg: #2563eb;
    --attention-text: #ffffff;
    --error-color: #ef4444;
    --highlight: #fbbf24;
    --warning-bg: #f59e0b;
    --warning-text: #ffffff;
}
[data-theme="dark"] {
    /* Modo Noite (Azul Marinho) */
    --bg-primary: linear-gradient(135deg, #0A192F 0%, #173A5E 100%);
    --bg-secondary: rgba(23, 42, 69, 0.95);
    --bg-card: rgba(30, 58, 96, 0.9);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-white: #ffffff;
    --border-color: rgba(148, 163, 184, 0.2);
    --shadow: rgba(0, 0, 0, 0.3);
    --accent: #60a5fa;
    --success: #34d399;
    --readonly-bg: rgba(51, 65, 85, 0.8);
    --tooltip-bg: #e2e8f0;
    --tooltip-text: #1a202c;
    --attention-bg: #3b82f6;
    --attention-text: #ffffff;
    --error-color: #f87171;
    --highlight: #fbbf24;
    --warning-bg: #f59e0b;
    --warning-text: #ffffff;
}
body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
    transition: all 0.3s ease;
    line-height: 1.6;
}
/* =================================================================== */
/* COMPONENTES DA INTERFACE                       */
/* =================================================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease;
}
.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    padding: 12px 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px var(--shadow);
    transition: all 0.3s ease;
    z-index: 1000;
    user-select: none;
}
.theme-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow);
}
.theme-icon {
    font-size: 16px;
    transition: transform 0.3s ease;
}
.theme-toggle:hover .theme-icon {
    transform: rotate(20deg);
}
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding-top: 20px;
}
.header {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-bottom: 40px;
    background: var(--bg-secondary);
    padding: 25px 35px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px var(--shadow);
    position: relative;
    overflow: hidden;
}
.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), var(--success));
}
.logo {
    width: 100px;
    height: auto;
    margin-right: 20px;
    transition: transform 0.3s ease;
}
.logo:hover {
    transform: scale(1.05);
}
.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    text-shadow: 0 2px 4px var(--shadow);
}
.header h1 br {
    display: none;
}
.header-icon {
    margin-left: 10px;
    color: var(--accent);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}
/* =================================================================== */
/* FORMULÁRIO                               */
/* =================================================================== */
.form-container, .calculator-form {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px var(--shadow);
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
    transition: all 0.3s ease;
}
.form-section {
    margin-bottom: 35px;
    animation: slideInUp 0.6s ease-out;
}
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.form-section h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 25px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
    position: relative;
}
.form-section h2::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background: var(--accent);
}
.section-icon {
    font-size: 1.5rem;
    color: var(--accent);
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}
.form-group {
    display: flex;
    flex-direction: column;
    position: relative;
    transition: all 0.3s ease;
}
.form-group.hidden {
    display: none !important;
}
.form-group.highlight {
    transform: scale(1.02);
    z-index: 2;
}
.form-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.3s ease;
}
.form-group:focus-within label {
    color: var(--accent);
}
.form-group input,
.form-group select {
    padding: 14px 18px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}
.form-group input.error,
.form-group select.error {
    border-color: var(--error-color) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
    animation: shake 0.5s ease-in-out;
}
.form-group.error {
    animation: errorPulse 0.6s ease-out;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
@keyframes errorPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}
.unidade-nao-selecionada {
    background: linear-gradient(135deg, var(--attention-bg), #1d4ed8) !important;
    color: var(--attention-text) !important;
    border-color: var(--attention-bg) !important;
    font-weight: 600;
    animation: glow 2s infinite alternate;
}
@keyframes glow {
    from { box-shadow: 0 0 10px rgba(37, 99, 235, 0.3); }
    to { box-shadow: 0 0 20px rgba(37, 99, 235, 0.6); }
}
.unidade-nao-selecionada option {
    background-color: var(--bg-card);
    color: var(--text-primary);
    font-weight: normal;
}
.form-group input::placeholder {
    color: var(--text-secondary);
    font-style: italic;
}
.form-group input[readonly] {
    background: var(--readonly-bg);
    cursor: not-allowed;
    opacity: 0.8;
}
.form-group-collapsible {
    grid-column: span 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.btn-toggle-field {
    background: linear-gradient(135deg, transparent, rgba(59, 130, 246, 0.05));
    border: 2px dashed var(--border-color);
    color: var(--text-secondary);
    padding: 14px 18px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    text-align: left;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    font-family: inherit;
}
.btn-toggle-field:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(59, 130, 246, 0.1));
    transform: translateY(-1px);
}
.btn-toggle-field i {
    margin-right: 10px;
    transition: transform 0.3s ease;
}
.btn-toggle-field:hover i {
    transform: rotate(90deg);
}
#responsavelFieldContent {
    margin-top: 15px;
    animation: fadeInDown 0.4s ease-out;
}
.hidden {
    display: none !important;
}
/* =================================================================== */
/* VALIDAÇÃO E MENSAGENS DE ERRO                    */
/* =================================================================== */
.error-message {
    color: var(--error-color);
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 6px;
    display: none;
    animation: fadeInDown 0.3s ease;
    padding: 4px 0;
    border-left: 3px solid var(--error-color);
    padding-left: 8px;
    background: rgba(239, 68, 68, 0.05);
    border-radius: 0 6px 6px 0;
}
.form-group.error .error-message {
    display: block;
}
/* Novo estilo para aviso da unidade */
.unidade-warning {
    color: var(--warning-text);
    background: var(--warning-bg);
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    text-align: center;
    animation: warningPulse 1s ease-in-out infinite alternate;
    border: 1px solid rgba(245, 158, 11, 0.3);
}
@keyframes warningPulse {
    from {
        background: var(--warning-bg);
        transform: scale(1);
    }
    to {
        background: #d97706;
        transform: scale(1.02);
    }
}
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* =================================================================== */
/* AUTOCOMPLETAR E SUGESTÕES                         */
/* =================================================================== */
.suggestions-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 99999; /* Corrigido: z-index alto para garantir visibilidade */
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3); /* Corrigido: sombra mais forte */
    backdrop-filter: blur(15px);
    margin-top: 2px;
    animation: fadeInDown 0.2s ease-out;
}
.suggestions-list::-webkit-scrollbar {
    width: 6px;
}
.suggestions-list::-webkit-scrollbar-track {
    background: transparent;
}
.suggestions-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 14px;
    font-weight: 500;
}
.suggestion-item:last-child {
    border-bottom: none;
}
.suggestion-item:hover,
.suggestion-item.highlighted {
    background: var(--accent);
    color: var(--text-white);
    transform: translateX(4px);
}
/* =================================================================== */
/* RESULTADOS                              */
/* =================================================================== */
.results-section {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px var(--shadow);
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
    animation: slideInUp 0.6s ease-out;
    position: relative;
    overflow: hidden;
}
.results-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--success), var(--highlight));
}
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    position: relative;
}
.result-card {
    background: var(--bg-card);
    padding: 30px 25px;
    border-radius: 16px;
    text-align: center;
    border: 2px solid var(--border-color);
    transition: all 0.4s ease;
    backdrop-filter: blur(5px);
    position: relative;
    overflow: hidden;
}
.result-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--accent);
}
.result-card.quitacao,
.result-card.success {
    border: none;
    color: var(--text-white);
}
.result-card.quitacao::before,
.result-card.success::before {
    display: none;
}
.result-card.quitacao {
    background: linear-gradient(135deg, #006994, #0284c7);
}
.result-card.success {
    background: linear-gradient(135deg, #3cb043, #22c55e);
    position: relative;
}
.result-card.success::after {
    content: '💰';
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.5rem;
    opacity: 0.7;
}
.result-card.quitacao h3, .result-card.quitacao .value, .result-card.quitacao .subtitle,
.result-card.success h3, .result-card.success .value, .result-card.success .subtitle {
    color: var(--text-white);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}
.result-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 15px 45px var(--shadow);
}
.result-card.success:hover {
    animation: celebrate 0.6s ease-in-out;
}
@keyframes celebrate {
    0%, 100% { transform: translateY(-8px) scale(1.02); }
    25% { transform: translateY(-12px) scale(1.05) rotate(1deg); }
    75% { transform: translateY(-12px) scale(1.05) rotate(-1deg); }
}
.result-card h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.result-card .value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    font-family: 'Inter', monospace;
}
.result-card .subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 8px;
}
.discount-highlight {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--highlight);
    color: #1f2937;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    max-width: 174px;
    text-align: center;
    line-height: 1.2;
    word-wrap: break-word;
    animation: highlightPulse 2s infinite ease-in-out;
}
@keyframes highlightPulse {
    0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(1.05);
        opacity: 0.9;
    }
}
/* =================================================================== */
/* BOTÕES E RODAPÉ                              */
/* =================================================================== */
.whatsapp-buttons {
    display: none;
    gap: 20px;
    margin-top: 30px;
    justify-content: center;
    animation: slideInUp 0.6s ease-out 0.3s both;
}
.whatsapp-btn {
    flex-grow: 0;
    flex-basis: 45%;
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: white;
    padding: 18px 30px;
    border: none;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.3);
    font-family: inherit;
    position: relative;
    overflow: hidden;
}
.whatsapp-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}
.whatsapp-btn:hover::before {
    left: 100%;
}
.whatsapp-btn:hover {
    background: linear-gradient(135deg, #128C7E, #0d7c6f);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(37, 211, 102, 0.4);
}
.whatsapp-btn i {
    font-size: 1.3rem;
    animation: bounce 2s infinite;
}
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-3px); }
    60% { transform: translateY(-1px); }
}
.footer {
    text-align: center;
    padding: 40px 30px;
    color: var(--text-white);
    font-size: 1.1rem;
    font-weight: 500;
    text-shadow: 0 2px 4px var(--shadow);
    background: var(--bg-secondary);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px var(--shadow);
    border: 1px solid var(--border-color);
    margin-top: 20px;
}
/* =================================================================== */
/* COMPONENTES ADICIONAIS                         */
/* =================================================================== */
.tooltip-trigger {
    cursor: pointer;
    color: var(--accent);
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 6px; /* Corrigido: Área de toque aumentada */
    border-radius: 50%;
}
.tooltip-trigger:hover {
    background: rgba(59, 130, 246, 0.1);
    transform: scale(1.2);
}
.tooltip {
    position: fixed; /* Corrigido: position fixed para garantir visibilidade */
    background-color: var(--tooltip-bg);
    color: var(--tooltip-text);
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    max-width: 280px;
    text-align: center;
    z-index: 10000;
    pointer-events: none;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
}
.tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.tooltip::after {
    content: '';
    position: absolute;
    left: 50%;
    border: 8px solid transparent;
    transform: translateX(-50%);
}
.tooltip.arrow-bottom::after {
    top: 100%;
    border-top-color: var(--tooltip-bg);
}
.tooltip.arrow-top::after {
    bottom: 100%;
    border-bottom-color: var(--tooltip-bg);
}
.progress-container {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-secondary);
    padding: 10px 0;
    margin-bottom: 20px;
    border-radius: 0 0 20px 20px;
    backdrop-filter: blur(10px);
}
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--success));
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 3px;
}
.progress-text {
    text-align: center;
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}
/* =================================================================== */
/* RESPONSIVIDADE                             */
/* =================================================================== */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }
    .header {
        flex-direction: row;
        padding: 20px 25px;
    }
    .header h1 {
        font-size: 1.8rem; 
    }
    .header h1 br {
        display: block;
    }
    .form-container, .calculator-form,
    .results-section {
        padding: 25px 20px;
        margin: 0 0 20px;
    }
    .form-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .results-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .whatsapp-buttons {
        flex-direction: column;
        gap: 15px;
    }
    .whatsapp-btn {
        flex-basis: auto;
        padding: 16px 25px;
        font-size: 1rem;
    }
    .theme-toggle {
        top: 15px;
        right: 15px;
        padding: 10px 14px;
        font-size: 13px;
    }
    .tooltip {
        max-width: 250px;
        font-size: 0.85rem;
        padding: 10px 15px;
    }
    .tooltip-trigger {
        font-size: 1.2rem;
        padding: 6px;
    }
    .discount-highlight {
        font-size: 0.65rem;
        padding: 4px 8px;
        max-width: 140px;
    }
    .unidade-warning {
        font-size: 0.8rem;
        padding: 6px 10px;
    }
}
@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    .header h1 {
        font-size: 1.4rem;
    }
    .logo {
        width: 70px;
        margin-right: 15px;
    }
    .form-container, .calculator-form,
    .results-section {
        padding: 20px 15px;
        margin: 0 0 15px;
    }
    .result-card .value {
        font-size: 1.8rem;
    }
    .form-section h2 {
        font-size: 1.2rem;
    }
    .tooltip {
        max-width: 200px;
        font-size: 0.8rem;
    }
    .discount-highlight {
        font-size: 0.6rem;
        padding: 3px 6px;
        max-width: 120px;
    }
    .unidade-warning {
        font-size: 0.75rem;
        padding: 5px 8px;
    }
}
/* =================================================================== */
/* ACESSIBILIDADE                            */
/* =================================================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
/* Focus visible para navegação por teclado */
.form-group input:focus-visible,
.form-group select:focus-visible,
.btn-toggle-field:focus-visible,
.whatsapp-btn:focus-visible,
.theme-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
/* Animação de sucesso */
.success-animation {
    animation: successPulse 0.6s ease-out;
}
@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}