/* ============================================================
   SprayIQ™ — CSS Principal
   Design: dark mode moderno, mobile first
   Paleta: fundo escuro + verde SprayIQ (#00c896)
   ============================================================ */

/* RESET E VARIÁVEIS */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Cores principais */
    --verde:      #00c896;
    --verde-dark: #00a07a;
    --verde-glow: rgba(0, 200, 150, 0.15);
    --azul:       #3b82f6;
    --amarelo:    #f59e0b;
    --laranja:    #f97316;
    --vermelho:   #ef4444;

    /* Fundo */
    --bg-900:  #0a0f1e;
    --bg-800:  #0f1629;
    --bg-700:  #151d35;
    --bg-600:  #1e2a45;
    --bg-500:  #263252;

    /* Texto */
    --text-100: #f0f4ff;
    --text-300: #a8b5cc;
    --text-500: #657389;

    /* Bordas */
    --borda:    rgba(255,255,255,0.07);
    --borda-md: rgba(255,255,255,0.12);

    /* Espaçamentos */
    --gap-xs: 4px;
    --gap-sm: 8px;
    --gap-md: 16px;
    --gap-lg: 24px;
    --gap-xl: 32px;
    --gap-2xl: 48px;

    /* Radius */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 24px;
    --r-full: 9999px;

    /* Fonte */
    --fonte: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --fonte-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Sombras */
    --sombra-sm: 0 2px 8px rgba(0,0,0,0.3);
    --sombra-md: 0 4px 20px rgba(0,0,0,0.4);
    --sombra-verde: 0 0 20px rgba(0,200,150,0.25);
}

/* BASE */
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--fonte);
    background: var(--bg-900);
    color: var(--text-100);
    min-height: 100vh;
    min-height: 100dvh; /* Altura real do mobile */
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* LAYOUT PRINCIPAL (mobile first) */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
}

/* Em telas grandes: layout de painel */
@media (min-width: 768px) {
    .app {
        max-width: 100%;
        flex-direction: row;
    }
    .sidebar  { display: flex; }
    .nav-bottom { display: none; }
}

/* ============================================================
   CABEÇALHO
   ============================================================ */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap-md);
    padding: var(--gap-md) var(--gap-md);
    background: var(--bg-800);
    border-bottom: 1px solid var(--borda);
    position: sticky;
    top: 0;
    z-index: 100;
}
/* Nome do usuário no header — não cola no logo */
#usuario-nome {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--verde);
    letter-spacing: -0.5px;
}

.logo span { color: var(--text-300); font-weight: 400; }

/* ============================================================
   NAVEGAÇÃO INFERIOR (mobile)
   ============================================================ */
.nav-bottom {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: min(480px, 100vw);
    background: var(--bg-800);
    border-top: 1px solid var(--borda);
    display: flex;
    justify-content: space-around;
    padding: var(--gap-sm) 0;
    padding-bottom: calc(var(--gap-sm) + env(safe-area-inset-bottom));
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-500);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 500;
    padding: var(--gap-xs) var(--gap-md);
    border-radius: var(--r-sm);
    transition: color 0.2s;
    letter-spacing: 0.3px;
}

.nav-item svg { width: 22px; height: 22px; }
.nav-item.ativo { color: var(--verde); }
.nav-item:hover { color: var(--text-100); }

/* ============================================================
   CONTEÚDO PRINCIPAL
   ============================================================ */
.main {
    flex: 1;
    padding: var(--gap-md);
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
    overflow-y: auto;
}

@media (min-width: 768px) {
    .main { padding-bottom: var(--gap-xl); }
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-700);
    border: 1px solid var(--borda);
    border-radius: var(--r-lg);
    padding: var(--gap-md);
    margin-bottom: var(--gap-md);
}

.card-titulo {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-500);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: var(--gap-md);
}

/* ============================================================
   SCORE — indicador principal
   ============================================================ */
.score-ring {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--gap-sm);
    padding: var(--gap-lg) 0;
}

.score-numero {
    font-size: 4rem;
    font-weight: 800;
    line-height: 1;
    color: var(--verde);
}

.score-numero.ruim     { color: var(--vermelho); }
.score-numero.atencao  { color: var(--laranja);  }
.score-numero.ideal    { color: var(--verde);    }
.score-numero.excesso  { color: var(--amarelo);  }

.score-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-300);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ============================================================
   MÉTRICAS — grade
   ============================================================ */
.metricas-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--gap-sm);
}

.metrica {
    background: var(--bg-600);
    border-radius: var(--r-md);
    padding: var(--gap-md);
    border: 1px solid var(--borda);
}

.metrica-valor {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-100);
    font-family: var(--fonte-mono);
}

.metrica-unidade {
    font-size: 0.7rem;
    color: var(--text-500);
    font-family: var(--fonte-mono);
}

.metrica-nome {
    font-size: 0.7rem;
    color: var(--text-300);
    margin-top: 4px;
    font-weight: 500;
}

/* ============================================================
   STATUS DE CLIMA
   ============================================================ */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--gap-xs);
    padding: 4px var(--gap-sm);
    border-radius: var(--r-full);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.status-badge.verde    { background: rgba(0,200,150,0.15); color: var(--verde); }
.status-badge.amarelo  { background: rgba(245,158,11,0.15); color: var(--amarelo); }
.status-badge.laranja  { background: rgba(249,115,22,0.15); color: var(--laranja); }
.status-badge.vermelho { background: rgba(239,68,68,0.15);  color: var(--vermelho); }

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulsar 2s infinite;
}

@keyframes pulsar {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* ============================================================
   BOTÕES
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--gap-sm);
    padding: var(--gap-md) var(--gap-lg);
    border-radius: var(--r-md);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    letter-spacing: 0.2px;
    width: 100%;
}

.btn-primario {
    background: var(--verde);
    color: #000;
    box-shadow: var(--sombra-verde);
}

.btn-primario:hover  { background: var(--verde-dark); transform: translateY(-1px); }
.btn-primario:active { transform: translateY(0); }

.btn-secundario {
    background: var(--bg-600);
    color: var(--text-100);
    border: 1px solid var(--borda-md);
}

.btn-secundario:hover { background: var(--bg-500); }

.btn-perigo {
    background: rgba(239,68,68,0.15);
    color: var(--vermelho);
    border: 1px solid rgba(239,68,68,0.3);
}

.btn-lg { padding: var(--gap-lg) var(--gap-xl); font-size: 1rem; border-radius: var(--r-lg); }
.btn-sm { padding: var(--gap-xs) var(--gap-md); font-size: 0.8rem; width: auto; }

/* ============================================================
   CÂMERA
   ============================================================ */
.camera-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: var(--r-lg);
    overflow: hidden;
    border: 2px solid var(--borda-md);
}

#video-camera {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-guia {
    width: 75%;
    aspect-ratio: 1;
    border: 2px solid var(--verde);
    border-radius: var(--r-md);
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.4);
}

.camera-status {
    position: absolute;
    bottom: var(--gap-md);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: var(--verde);
    padding: 6px 14px;
    border-radius: var(--r-full);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ============================================================
   INPUTS E SELECTS
   ============================================================ */
.input, .select, .textarea {
    width: 100%;
    background: var(--bg-600);
    border: 1px solid var(--borda-md);
    color: var(--text-100);
    border-radius: var(--r-md);
    padding: var(--gap-md);
    font-size: 0.9rem;
    font-family: var(--fonte);
    outline: none;
    transition: border-color 0.2s;
}

.input:focus, .select:focus, .textarea:focus {
    border-color: var(--verde);
    box-shadow: 0 0 0 3px var(--verde-glow);
}

.label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-300);
    margin-bottom: var(--gap-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.campo-grupo { margin-bottom: var(--gap-md); }

/* ============================================================
   HEATMAP
   ============================================================ */
.mapa-container {
    width: 100%;
    height: 300px;
    border-radius: var(--r-lg);
    overflow: hidden;
    border: 1px solid var(--borda);
}

@media (min-width: 768px) {
    .mapa-container { height: 500px; }
}

/* ============================================================
   LISTAS DE ANÁLISES
   ============================================================ */
.analise-item {
    display: flex;
    align-items: center;
    gap: var(--gap-md);
    padding: var(--gap-md);
    background: var(--bg-600);
    border-radius: var(--r-md);
    border: 1px solid var(--borda);
    margin-bottom: var(--gap-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.analise-item:hover { background: var(--bg-500); }

.analise-score {
    width: 48px;
    height: 48px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 800;
    flex-shrink: 0;
}

.analise-score.ideal    { background: rgba(0,200,150,0.2);  color: var(--verde); }
.analise-score.aceitavel{ background: rgba(245,158,11,0.2); color: var(--amarelo); }
.analise-score.ruim     { background: rgba(239,68,68,0.2);  color: var(--vermelho); }

.analise-info { flex: 1; min-width: 0; }
.analise-talhao { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.analise-meta { font-size: 0.75rem; color: var(--text-500); margin-top: 2px; }

/* ============================================================
   LOADING
   ============================================================ */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--borda-md);
    border-top-color: var(--verde);
    border-radius: 50%;
    animation: girar 0.8s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,15,30,0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--gap-md);
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.loading-texto { color: var(--text-300); font-size: 0.875rem; }

/* ============================================================
   TOAST / NOTIFICAÇÕES
   ============================================================ */
.toast-container {
    position: fixed;
    top: var(--gap-md);
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--gap-sm);
    width: calc(100% - var(--gap-xl));
    max-width: 400px;
}

.toast {
    padding: var(--gap-md);
    border-radius: var(--r-md);
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    animation: slideDown 0.3s ease;
    box-shadow: var(--sombra-md);
}

.toast.sucesso  { background: rgba(0,200,150,0.95); color: #000; }
.toast.erro     { background: rgba(239,68,68,0.95);  color: #fff; }
.toast.aviso    { background: rgba(245,158,11,0.95); color: #000; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   OFFLINE INDICATOR
   ============================================================ */
.offline-bar {
    background: var(--amarelo);
    color: #000;
    text-align: center;
    padding: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    display: none;
}

.offline-bar.visivel { display: block; }

/* ============================================================
   RESPONSIVO DESKTOP
   ============================================================ */
@media (min-width: 768px) {
    .metricas-grid { grid-template-columns: repeat(3, 1fr); }
    .main          { max-width: 900px; }
    .card          { padding: var(--gap-lg); }
}

@media (min-width: 1024px) {
    .sidebar {
        width: 240px;
        min-height: 100vh;
        background: var(--bg-800);
        border-right: 1px solid var(--borda);
        display: flex;
        flex-direction: column;
        padding: var(--gap-lg);
        flex-shrink: 0;
    }
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-container {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--gap-lg);
    background: var(--bg-900);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-800);
    border: 1px solid var(--borda);
    border-radius: var(--r-xl);
    padding: var(--gap-2xl) var(--gap-xl);
}

.login-logo {
    text-align: center;
    font-size: 2rem;
    font-weight: 800;
    color: var(--verde);
    margin-bottom: var(--gap-xs);
    letter-spacing: -1px;
}

.login-subtitulo {
    text-align: center;
    color: var(--text-500);
    font-size: 0.875rem;
    margin-bottom: var(--gap-2xl);
}

/* ============================================================
   UTILITÁRIOS
   ============================================================ */
.mt-sm  { margin-top: var(--gap-sm); }
.mt-md  { margin-top: var(--gap-md); }
.mt-lg  { margin-top: var(--gap-lg); }
.mb-md  { margin-bottom: var(--gap-md); }
.mb-lg  { margin-bottom: var(--gap-lg); }
.flex   { display: flex; }
.flex-centro { display: flex; align-items: center; justify-content: center; }
.gap-sm { gap: var(--gap-sm); }
.gap-md { gap: var(--gap-md); }
.texto-centro { text-align: center; }
.texto-verde  { color: var(--verde); }
.texto-muted  { color: var(--text-500); font-size: 0.85rem; }
.negrito      { font-weight: 700; }
.w-full       { width: 100%; }
.oculto       { display: none !important; }
