/* ========================================
   VARIÁVEIS CSS E CONFIGURAÇÕES GLOBAIS
   ======================================== */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #576574;
    --warning-color: #f39c12;
    --danger-color: #c0392b;
    --accent-color: #2980b9;
    --background-color: #f5f6fa;
    --surface-color: #ffffff;
    --text-color: #2c3e50;
    --text-secondary: #576574;
    --border-color: #dcdde1;
    --shadow: 0 2px 10px rgba(0,0,0,0.05);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.08);
    --border-radius: 8px;
    --spacing: 20px;
    --bottom-nav-height: 70px;
}

/* ========================================
   RESET E CONFIGURAÇÕES BASE
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    padding-bottom: var(--bottom-nav-height);
    margin: 0;
    overflow-x: hidden;
}

/* ========================================
   ANIMAÇÕES
   ======================================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes loading {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* ========================================
   HEADER
   ======================================== */
header {
    background: var(--primary-color);
    color: white;
    padding: var(--spacing);
    text-align: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-icon {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-icon.active {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(45deg);
}

.header-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Logo */
.logo {
    height: 40px;
    width: auto;
    transition: transform 0.3s ease;
}

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

/* ========================================
   MAIN CONTENT
   ======================================== */
main {
    padding: var(--spacing);
    max-width: 800px;
    margin: 0 auto;
}

.section {
    display: none;
    animation: slideInUp 0.6s ease-out;
}

.section.active {
    display: block;
}

/* ========================================
   CARDS
   ======================================== */
.card {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: var(--spacing);
    margin-bottom: var(--spacing);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

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

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

/* ========================================
   FORMS
   ======================================== */
.form-section {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-of-type {
    border-bottom: none;
}

.section-subtitle {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr; /* Coluna única por padrão no mobile */
    gap: 15px;
}

@media (min-width: 550px) {
    .form-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: flex;
    align-items: center;
    justify-content: space-between; /* Melhora distribuição no mobile */
    gap: 10px;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.95rem;
}

.label-text {
    flex: 1;
    display: block;
}

.info-icon {
    font-size: 0.9rem;
    color: var(--text-secondary);
    opacity: 0.7;
    cursor: help;
    padding: 2px;
}

.info-icon:hover {
    opacity: 1;
    color: var(--primary-color);
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
select,
textarea {
    font-size: 16px !important; /* Força 16px para evitar zoom no mobile */
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease; /* Transição específica para evitar tremores */
    background-color: var(--surface-color);
    color: var(--text-color);
    height: 48px;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent; /* Remove o flash de toque no Android/iOS */
    line-height: normal; /* Estabiliza o alinhamento vertical */
}

/* Remove spinners de inputs numéricos para layout mais limpo */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number] {
    -moz-appearance: textfield;
}

/* Adiciona seta customizada para selects para garantir consistência */
.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%232c3e50' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    padding-right: 40px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
    background-color: var(--surface-color); /* Estabiliza o fundo */
}

.form-group input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn-primary,
.btn-secondary,
.btn-danger {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: var(--spacing);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: var(--shadow-hover);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    filter: brightness(1.1);
    box-shadow: var(--shadow-hover);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    filter: brightness(1.1);
    box-shadow: var(--shadow-hover);
}

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

@media (min-width: 480px) {
    .btn-group {
        flex-direction: row;
    }
}

/* ========================================
   RESULTS
   ======================================== */
.result-container {
    margin-top: var(--spacing);
    padding: var(--spacing);
    background: var(--background-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
}

.result-container h3 {
    color: var(--primary-color);
    margin-bottom: var(--spacing);
}

.result-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: var(--spacing);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.result-logo {
    height: 32px;
    width: auto;
}

.result-header h4 {
    color: var(--primary-color);
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.cost-breakdown {
    display: grid;
    gap: 12px;
    margin: var(--spacing) 0;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--surface-color);
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.cost-item.total {
    font-weight: 600;
    font-size: 1.1rem;
    background: var(--primary-color);
    color: white;
    border: none;
}

.cost-value {
    font-weight: 600;
}

.cost-item:not(.total) .cost-value {
    color: var(--primary-color);
}

.chart-container {
    margin: var(--spacing) 0;
    background: white;
    border-radius: 8px;
    padding: var(--spacing);
    height: 300px;
    position: relative;
}

/* ========================================
   COMPARISON
   ======================================== */
.comparison-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: var(--spacing);
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.comparison-logo {
    height: 35px;
    width: auto;
}

.comparison-summary {
    display: grid;
    gap: 12px;
    margin-bottom: var(--spacing);
}

@media (min-width: 600px) {
    .comparison-summary {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

.comparison-summary .cost-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    padding: 15px;
}

.comparison-summary .cost-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.comparison-summary .cost-value {
    font-size: 1rem;
    word-break: break-word;
}

/* ========================================
   VEHICLES
   ======================================== */
.vehicles-list {
    display: grid;
    gap: 12px;
    margin: var(--spacing) 0;
}

.vehicle-card {
    background: white;
    border-radius: 8px;
    padding: var(--spacing);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    margin-bottom: 15px;
}

.history-item .vehicle-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.vehicle-main-data {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.vehicle-name {
    font-weight: 700;
    color: var(--text-color);
}

.vehicle-cost {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.vehicle-actions {
    display: flex;
    gap: 10px;
}

.btn-detail-toggle,
.delete-vehicle {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-detail-toggle {
    color: var(--primary-color);
}

.btn-detail-toggle:hover {
    background: rgba(41, 128, 185, 0.1);
}

.delete-vehicle {
    color: var(--danger-color);
}

.delete-vehicle:hover {
    background: rgba(192, 57, 43, 0.1);
}

.vehicle-detail-content {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    animation: fadeIn 0.3s ease;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
}

.detail-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-group label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
}

.detail-group span {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-color);
}

/* ========================================
   FAQ
   ======================================== */
.faq-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.faq-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.faq-question {
    width: 100%;
    background: white;
    border: none;
    padding: var(--spacing);
    text-align: left;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.faq-question[aria-expanded="true"] {
    background-color: var(--primary-color);
    color: white;
}

.faq-answer {
    padding: var(--spacing);
    background-color: #f8f9fa;
    border-top: 1px solid var(--border-color);
}

/* ========================================
   CONFIG SECTION
   ======================================== */
#config .card {
    display: flex;
    flex-direction: column;
    gap: var(--spacing);
}

#config .theme-selector,
#config .language-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#config label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

#config select {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--surface-color);
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
    height: 48px;
    appearance: none;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%232c3e50' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Share Section */
.share-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.share-description {
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.share-link-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.share-link-container input {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--background-color);
    font-size: 0.9rem;
    cursor: default;
}

.share-link-container .btn-icon {
    background: var(--primary-color);
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 8px;
}

.share-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.share-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-decoration: none;
}

.share-btn.whatsapp { background: #25D366; }
.share-btn.facebook { background: #1877F2; }
.share-btn.twitter { background: #000000; }
.share-btn.linkedin { background: #0A66C2; }

.share-btn:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    color: white;
}

.share-btn.whatsapp:hover { background: #128C7E; }
.share-btn.facebook:hover { background: #145DBF; }
.share-btn.twitter:hover { background: #333333; }
.share-btn.linkedin:hover { background: #084482; }

/* ========================================
   BOTTOM NAVIGATION
   ======================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    height: var(--bottom-nav-height);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-secondary);
    padding: 8px 4px;
    flex: 1;
    transition: all 0.3s ease;
    max-width: 20%;
}

.nav-item.active {
    color: var(--primary-color);
    border-top: 3px solid var(--primary-color);
    padding-top: 5px;
}

.nav-item i {
    font-size: 1.2rem;
    margin-bottom: 2px;
}

.nav-item span {
    font-size: 0.7rem;
    font-weight: 600;
}

/* ========================================
   FOOTER
   ======================================== */
footer {
    text-align: center;
    padding: var(--spacing);
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: var(--spacing);
    margin-bottom: 20px;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.footer-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.footer-divider {
    color: var(--border-color);
    opacity: 0.5;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

footer a:hover {
    text-decoration: underline;
}

@media (min-width: 480px) {
    .footer-content {
        flex-direction: row;
        gap: 20px;
    }
    
    .footer-links {
        align-items: flex-start;
    }
}

/* ========================================
   ALERTS
   ======================================== */
.alert {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: var(--spacing);
    animation: fadeIn 0.3s ease;
}

.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    header h1 { font-size: 1rem; }
    .logo { height: 32px; }
    :root { --spacing: 15px; }
}

@media (min-width: 768px) {
    header h1 { font-size: 1.5rem; }
    .bottom-nav {
        max-width: 800px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 12px 12px 0 0;
    }
}

/* ========================================
   PRINT
   ======================================== */
@media print {
    header, 
    .bottom-nav, 
    footer, 
    #cost-form, 
    .btn-group, 
    .vehicle-actions,
    .btn-icon,
    #save-vehicle {
        display: none !important;
    }

    body {
        background: white;
        padding: 0;
    }

    main {
        max-width: 100%;
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: none;
        padding: 0;
    }

    .result-container {
        display: block !important;
        border: 2px solid #eee;
        padding: 20px;
    }

    .chart-container {
        page-break-inside: avoid;
    }
}
