/* Estilos Globais e Modo Escuro - Otimizado para Android */
:root {
    --background-color: #f8f9fa;
    --text-color: #212529;
    --card-background: #ffffff;
    --primary-color: #007bff;
    --primary-text: #ffffff;
    --border-color: #dee2e6;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    
    /* Variáveis específicas para Android */
    --touch-target-size: 48px;
    --border-radius-mobile: 12px;
    --spacing-mobile: 16px;
    --font-size-mobile: 16px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #121212;
        --text-color: #e0e0e0;
        --card-background: #1e1e1e;
        --primary-color: #0d6efd;
        --border-color: #333;
        --shadow-color: rgba(0, 0, 0, 0.4);
    }
}

/* Reset e configurações base para Android */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
    font-size: var(--font-size-mobile);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container principal otimizado para mobile */
.container {
    max-width: 100%;
    margin: 0;
    padding: var(--spacing-mobile);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header otimizado para Android */
header {
    text-align: center;
    margin-bottom: var(--spacing-mobile);
    padding: var(--spacing-mobile) 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--info-color) 100%);
    color: white;
    border-radius: var(--border-radius-mobile);
    box-shadow: 0 4px 12px var(--shadow-color);
    margin: 0 -var(--spacing-mobile) var(--spacing-mobile) -var(--spacing-mobile);
    padding-left: var(--spacing-mobile);
    padding-right: var(--spacing-mobile);
}

header h1 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

header p {
    margin: 8px 0 0 0;
    opacity: 0.9;
    font-size: 0.95rem;
}

/* Mapa otimizado para Android */
#map {
    height: 250px;
    width: 100%;
    border-radius: var(--border-radius-mobile);
    margin-bottom: var(--spacing-mobile);
    box-shadow: 0 4px 12px var(--shadow-color);
    border: 1px solid var(--border-color);
    touch-action: manipulation;
    flex-shrink: 0;
}

/* Formulário otimizado para Android */
.form-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-mobile);
    margin-bottom: var(--spacing-mobile);
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Selects otimizados para Android */
select {
    width: 100%;
    min-height: var(--touch-target-size);
    padding: 12px 16px;
    font-size: var(--font-size-mobile);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-mobile);
    background-color: var(--card-background);
    color: var(--text-color);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22/%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: right 16px top 50%;
    background-size: 12px auto;
    transition: all 0.3s ease;
    cursor: pointer;
    touch-action: manipulation;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
    transform: translateY(-1px);
}

select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: var(--border-color);
}

select:active {
    transform: translateY(0);
}

/* Resultado otimizado para Android */
.resultado-container {
    background-color: var(--card-background);
    padding: var(--spacing-mobile);
    border-radius: var(--border-radius-mobile);
    text-align: center;
    box-shadow: 0 4px 12px var(--shadow-color);
    border: 1px solid var(--border-color);
    display: none;
    animation: slideInUp 0.5s ease-out;
    margin-top: auto;
}

.resultado-container.show {
    display: block;
}

.origem-destino {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 1.1rem;
    flex-wrap: wrap;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-indicator.success {
    background-color: var(--success-color);
    box-shadow: 0 0 8px rgba(40, 167, 69, 0.4);
}

.status-indicator.error {
    background-color: var(--danger-color);
    box-shadow: 0 0 8px rgba(220, 53, 69, 0.4);
}

.resultado-container p {
    margin: 8px 0;
    font-size: 1rem;
}

.resultado-container .valor {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 16px 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Botão WhatsApp otimizado para Android */
.whatsapp-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    padding: 14px 24px;
    min-height: var(--touch-target-size);
    background: linear-gradient(135deg, #25D366 0%, #1DAE52 100%);
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 600;
    font-size: var(--font-size-mobile);
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    touch-action: manipulation;
    cursor: pointer;
}

.whatsapp-button:hover,
.whatsapp-button:focus {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.4);
    text-decoration: none;
    color: white;
}

.whatsapp-button:active {
    transform: translateY(0);
}

.whatsapp-button::before {
    content: "📱";
    font-size: 1.2em;
}

/* Animações otimizadas para Android */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes bounce {
    0%, 20%, 60%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-8px);
    }
    80% {
        transform: translateY(-4px);
    }
}

/* Botão de instalação PWA otimizado para Android */
#botao-instalar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--success-color) 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 123, 255, 0.3);
    z-index: 1000;
    transition: all 0.3s ease;
    font-size: 14px;
    min-height: var(--touch-target-size);
    min-width: var(--touch-target-size);
    touch-action: manipulation;
}

#botao-instalar:hover,
#botao-instalar:focus {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 123, 255, 0.4);
}

#botao-instalar:active {
    transform: translateY(0);
}

/* Melhorias para acessibilidade em Android */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Otimizações para telas pequenas (Android) */
@media (max-width: 480px) {
    :root {
        --spacing-mobile: 12px;
        --font-size-mobile: 15px;
    }
    
    header h1 {
        font-size: 1.6rem;
    }
    
    #map {
        height: 220px;
    }
    
    .resultado-container .valor {
        font-size: 2rem;
    }
    
    .whatsapp-button {
        padding: 12px 20px;
        font-size: 15px;
    }
}

/* Otimizações para telas médias (tablets Android) */
@media (min-width: 481px) and (max-width: 768px) {
    .container {
        max-width: 600px;
        margin: 0 auto;
        padding: 20px;
    }
    
    #map {
        height: 300px;
    }
    
    .form-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
}

/* Otimizações para telas grandes (modo desktop) */
@media (min-width: 769px) {
    .container {
        max-width: 800px;
        margin: 0 auto;
        padding: 24px;
    }
    
    #map {
        height: 350px;
    }
    
    .form-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 24px;
        align-items: end;
    }
    
    header {
        margin: 0 0 24px 0;
        padding: 24px;
    }
}

/* Melhorias específicas para Android WebView */
@supports (-webkit-touch-callout: none) {
    select {
        font-size: 16px; /* Previne zoom no iOS */
    }
}

/* Loading spinner para IA */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Estilos para informações da IA */
#ia-info {
    margin: 15px 0;
    padding: 12px;
    background: rgba(0,123,255,0.1);
    border-radius: var(--border-radius-mobile);
    font-size: 0.9rem;
    border-left: 4px solid var(--primary-color);
    text-align: left;
}

/* Melhorias para controles do mapa no Android */
.leaflet-control-container {
    font-size: 14px;
}

.leaflet-control-zoom a {
    width: 36px;
    height: 36px;
    line-height: 36px;
    font-size: 18px;
}

.leaflet-control-attribution {
    font-size: 11px;
    background: rgba(255, 255, 255, 0.8);
}

/* Estilos para popups do mapa */
.leaflet-popup-content-wrapper {
    border-radius: var(--border-radius-mobile);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.leaflet-popup-content {
    margin: 12px 16px;
    font-family: inherit;
    font-size: 14px;
}

/* Otimizações para performance em Android */
.marcador-customizado {
    will-change: transform;
    backface-visibility: hidden;
}

/* Estilos para modo paisagem em Android */
@media (orientation: landscape) and (max-height: 500px) {
    #map {
        height: 180px;
    }
    
    header {
        padding: 12px var(--spacing-mobile);
    }
    
    header h1 {
        font-size: 1.4rem;
    }
    
    .container {
        padding: 12px;
    }
}

