/* ═══════════════════════════════════════════════════════════
   AgriFlow Sidebar — Slim Desktop (64→240px) + Bottom Mobile
   Paleta: #163832 Verde Floresta · #C8A227 Ouro · #10B981 Verde Circuito
   ═══════════════════════════════════════════════════════════ */

:root {
    --sb-w0:          64px;     /* collapsed width      */
    --sb-w1:          240px;    /* expanded width       */
    --sb-bg:          #163832;
    --sb-border:      rgba(255,255,255,0.06);
    --sb-text:        rgba(255,255,255,0.46);
    --sb-hover-bg:    rgba(255,255,255,0.055);
    --sb-hover-text:  #ffffff;
    --sb-active-bg:   rgba(200,162,39,0.11);
    --sb-active-col:  #C8A227;
    --sb-radius:      10px;
    --sb-transition:  .28s cubic-bezier(.4,0,.2,1);
}

/* ── Shell ──────────────────────────────────────────────────── */
.af-shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar container ──────────────────────────────────────── */
.af-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sb-w0);
    background: var(--sb-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 3000;
    transition: width var(--sb-transition), box-shadow var(--sb-transition);
}
.af-sidebar:hover {
    width: var(--sb-w1);
    box-shadow: 6px 0 32px rgba(0,0,0,.22);
}

/* ── Logo area ──────────────────────────────────────────────── */
.af-sidebar-logo {
    position: relative;
    display: flex;
    align-items: center;
    height: 68px;
    padding: 0 14px;
    flex-shrink: 0;
    text-decoration: none;
    overflow: hidden;
    border-bottom: 1px solid var(--sb-border);
}

/* Logo sempre visível em ambos os estados.
   36px encaixa exato nos 64px colapsados (14px padding × 2 = 28px, 64−28 = 36px). */
.af-sidebar-logo-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
}

/* ── Nav items ──────────────────────────────────────────────── */
.af-nav-items {
    flex: 1;
    padding: 10px 8px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
}
.af-nav-items::-webkit-scrollbar { display: none; }

.af-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 12px;
    color: var(--sb-text);
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: var(--sb-radius);
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    box-shadow: inset 3px 0 0 transparent;
    transition: background .18s, color .18s, box-shadow .18s;
    -webkit-tap-highlight-color: transparent;
}
.af-nav-item:hover {
    background: var(--sb-hover-bg);
    color: var(--sb-hover-text);
}
.af-nav-item.active {
    background: var(--sb-active-bg);
    color: var(--sb-active-col);
    box-shadow: inset 3px 0 0 var(--sb-active-col);
}

/* Icon */
.af-nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Label — hidden when collapsed, revealed on sidebar expand */
.af-nav-label {
    opacity: 0;
    overflow: hidden;
    flex-shrink: 0;
    transition: opacity .16s 0s;
}
.af-sidebar:hover .af-nav-label {
    opacity: 1;
    transition-delay: .07s;
}

/* ── Divider & section header ───────────────────────────────── */
.af-nav-divider {
    height: 1px;
    background: var(--sb-border);
    margin: 8px 4px;
}
.af-nav-section {
    padding: 6px 14px 2px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .10em;
    color: rgba(200,162,39,.45);
    white-space: nowrap;
    opacity: 0;
    transition: opacity .16s;
}
.af-sidebar:hover .af-nav-section { opacity: 1; }

/* ── Footer ─────────────────────────────────────────────────── */
.af-sidebar-footer {
    flex-shrink: 0;
    padding: 8px 8px 16px;
    border-top: 1px solid var(--sb-border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Logout */
.af-nav-logout              { color: rgba(248,113,113,.58) !important; }
.af-nav-logout:hover        { background: rgba(248,113,113,.07) !important; color: #f87171 !important; }

/* Notif button */
.af-notif-btn { width: 100%; text-align: left; }

.af-notif-badge {
    display: none;
    margin-left: auto;
    background: #ef4444;
    color: #fff;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 800;
    padding: 1px 6px;
    line-height: 1.6;
    flex-shrink: 0;
}

/* ── Notification dropdown ──────────────────────────────────── */
#notif-dropdown {
    display: none;
    position: fixed;
    bottom: 80px;
    left: calc(var(--sb-w0) + 10px);
    width: 300px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(22,56,50,.22), 0 2px 8px rgba(0,0,0,.08);
    border: 1px solid rgba(200,162,39,.22);
    border-top: 3px solid #C8A227;
    overflow: hidden;
    z-index: 10000;
    color: #1C2B27;
}

/* Header do dropdown */
.nd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: #F4F0E6;
    border-bottom: 1px solid rgba(200,162,39,.18);
}
.nd-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: .04em;
    color: #163832;
    text-transform: uppercase;
}
.nd-clear-btn {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: #163832;
    background: rgba(22,56,50,.08);
    border: 1px solid rgba(22,56,50,.15);
    border-radius: 6px;
    padding: 0 10px;
    height: 28px;
    min-height: 28px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s;
    /* min touch target via padding visual; real 44px via wrapper padding no mobile */
    display: flex;
    align-items: center;
}
.nd-clear-btn:hover {
    background: #163832;
    color: #C8A227;
    border-color: #163832;
}

/* Item de notificação */
.nd-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border-bottom: 1px solid rgba(0,0,0,.05);
    text-decoration: none;
    color: inherit;
    transition: background .16s;
    min-height: 44px;
}
.nd-item:last-child { border-bottom: none; }
.nd-item:hover { background: rgba(200,162,39,.06); }

.nd-item-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(200,162,39,.10);
    border-radius: 7px;
    margin-top: 1px;
}
.nd-item-body {
    flex: 1;
    min-width: 0;
}
.nd-item-msg {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.45;
    color: #1C2B27;
}
.nd-item-time {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    color: #9CA3AF;
    margin-top: 3px;
}
.nd-item-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #C8A227;
    flex-shrink: 0;
    margin-top: 6px;
}

/* Estado vazio */
.nd-empty {
    padding: 28px 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.nd-empty-icon {
    width: 44px;
    height: 44px;
    background: rgba(200,162,39,.12);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 4px;
}

/* ── Main offset ────────────────────────────────────────────── */
.af-main {
    flex: 1;
    margin-left: var(--sb-w0);
    min-width: 0;
}

/* ═══════════════════════════════════════════════════════════
   MOBILE: Bottom Tab Bar — Floating card (WhatsApp style)
   Flutua acima da safe area do iOS, com cantos arredondados
   ═══════════════════════════════════════════════════════════ */
.af-bottom-nav {
    display: none;
    position: fixed;
    left: 16px !important;
    right: 16px !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 20px) !important;
    height: 60px;
    background: var(--sb-bg);
    border-radius: 22px;
    z-index: 3000;
    align-items: center;
    justify-content: space-around;
    padding: 0 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,.32), 0 2px 8px rgba(0,0,0,.16);
}

.af-tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    max-width: 72px;
    padding: 8px 4px;
    text-decoration: none;
    color: rgba(255,255,255,.34);
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
    transition: color .18s;
}
.af-tab-item.active { color: var(--sb-active-col); }

.af-tab-item svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}
.af-tab-item span {
    font-family: 'Inter', sans-serif;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    line-height: 1;
}

/* ── Responsive breakpoint ──────────────────────────────────── */
@media (max-width: 1023px) {
    .af-sidebar    { display: none; }
    .af-bottom-nav { display: flex; }
    .af-main {
        margin-left: 0;
        /* 60px tab bar + 10px bottom offset + 10px gap acima do bar + safe-area */
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
    }
}

/* Tela estreita: cinco rótulos de 9px em 360px de largura sobram ~62px por
   aba, e "DASHBOARD" já ocupa ~53px. O respiro lateral e o entreletras
   cedem antes de o texto quebrar em duas linhas.
   Nada de `bottom`, `height` ou `z-index` aqui: essa geometria tem dono
   único no bloco base, e o smoke-ui-fab-e-espacamento deriva o FAB dela. */
@media (max-width: 380px) {
    .af-bottom-nav {
        left: 10px !important;
        right: 10px !important;
        padding: 0 4px;
    }
    .af-tab-item {
        max-width: none;
        padding: 8px 2px;
    }
    .af-tab-item span { letter-spacing: .01em; }
}

/* ── Print ──────────────────────────────────────────────────── */
@media print {
    .af-sidebar, .af-bottom-nav { display: none !important; }
    .af-main { margin-left: 0 !important; }
}

/* ── User avatar — sidebar trigger ─────────────────────────── */
.af-user-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #C8A227;
    color: #163832;
    font-size: 11px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    line-height: 1;
}

/* ── User avatar — modal large ──────────────────────────────── */
.af-user-avatar-lg {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #C8A227;
    color: #163832;
    font-size: 24px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    border: 3px solid rgba(200,162,39,.3);
}
.af-user-avatar-lg input[type=file] { display: none; }
.af-user-avatar-lg .av-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .2s;
    border-radius: 50%;
    color: #fff;
}
.af-user-avatar-lg:hover .av-overlay { opacity: 1; }

/* ═══════════════════════════════════════════════════════════
   APPBAR — Header verde elegante (idêntico em desktop e mobile)
   ═══════════════════════════════════════════════════════════ */

.af-appbar {
    display: flex;
    align-items: center;
    height: 64px;
    min-height: 64px;
    padding: 0 24px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 200;
    background: #163832;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    box-shadow: 0 2px 20px rgba(0,0,0,0.20);
    flex-shrink: 0;
}

/* Título: ocupa o vão entre o logo (esquerda, 40px fixos) e as ações
   (direita). `min-width:0` é o que impede um vizinho grande de empurrar
   o título para fora do cabeçalho — item flex não encolhe abaixo do
   conteúdo sem isso. */
.af-appbar-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    font-size: 20px;
    letter-spacing: 0.07em;
    color: #ffffff;
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Hamburger — oculto no desktop (sidebar sempre visível) */
.af-appbar-hamburger {
    display: none;
    width: 40px;
    min-width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.08);
    border: none;
    cursor: pointer;
    border-radius: 10px;
    color: #ffffff;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: background .16s;
}
.af-appbar-hamburger:active { background: rgba(255,255,255,0.16); }

/* Hamburger → X animation */
.af-appbar-hamburger svg line {
    transition: transform .22s ease, opacity .18s ease;
    transform-box: fill-box;
    transform-origin: center;
}
.af-appbar-hamburger.is-open svg line:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.af-appbar-hamburger.is-open svg line:nth-child(2) { opacity: 0; transform: scaleX(0); }
.af-appbar-hamburger.is-open svg line:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Slot de ações à direita do appbar. A ordem da linha é fixa: ponto de
   sync (o offline-sync.js entra com `prepend`), filtros, e o perfil por
   último — no canto, onde o polegar alcança e onde todo app nativo põe a
   identidade. Nenhum item aqui encolhe; quem cede espaço é o título. */
.af-appbar-end {
    width: auto;
    min-width: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* ── Gatilho de perfil no cabeçalho ─────────────────────────────
   Era a quinta aba da tab bar ("Conta"). Saiu de lá porque a barra é a
   ÚNICA navegação do celular — abaixo de 1024px não há sidebar nem
   hambúrguer — e um quinto dela estava indo para algo que não é destino
   de conteúdo. O lugar liberado devolveu o Funil à barra (ADR 0023). */
.af-appbar-profile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    min-width: 38px;
    height: 38px;
    padding: 0;
    flex-shrink: 0;
    box-sizing: border-box;
    border: 1.5px solid rgba(255,255,255,0.28);
    border-radius: 50%;
    background: rgba(255,255,255,0.10);
    color: #ffffff;
    cursor: pointer;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: background .16s, border-color .16s, color .16s;
}
.af-appbar-profile svg { width: 20px; height: 20px; display: block; }
.af-appbar-profile:hover { background: rgba(255,255,255,0.18); }
.af-appbar-profile:focus-visible { outline: 2px solid #C8A227; outline-offset: 2px; }

/* Tela de perfil: sem aba na barra para marcar, o próprio gatilho diz
   onde o vendedor está. */
.af-appbar-profile.active {
    background: #C8A227;
    border-color: #C8A227;
    color: #1C2B27;
}

@media (max-width: 1023px) {
    /* Mobile: header limpo sobre fundo branco — sem barra colorida */
    .af-appbar {
        background: #ffffff;
        border-bottom: 1px solid rgba(22,56,50,0.09);
        box-shadow: 0 1px 6px rgba(0,0,0,0.05);
        height: 56px;
        min-height: 56px;
        padding: 0 20px;
    }
    .af-appbar-title {
        color: #163832;
        font-size: 18px;
        text-align: left;
    }
    /* Hamburger removido no mobile — navegação pela bottom tab bar */
    .af-appbar-hamburger { display: none; }
    .af-appbar-spacer    { display: none; }

    /* Fundo branco: o gatilho inverte, como o botão de filtro faz */
    .af-appbar-profile {
        border-color: rgba(22,56,50,0.20);
        background: rgba(22,56,50,0.06);
        color: #163832;
    }
    .af-appbar-profile:hover { background: rgba(22,56,50,0.12); }
}

/* ── Tela estreita (360px e abaixo) ─────────────────────────────
   Nesta largura o cabeçalho carrega quatro coisas de uma vez: título,
   ponto de sync, filtro e perfil. Com os 20px de respiro de cada lado
   sobram ~130px para o título quando a fila de sync está cheia — e o
   perfil começa a ser empurrado para fora da tela. Aqui o padding e os
   gaps cedem primeiro; o título só trunca depois disso. */
@media (max-width: 400px) {
    .af-appbar {
        padding: 0 12px;
        gap: 8px;
    }
    .af-appbar-end { gap: 6px; }
    .af-appbar-profile {
        width: 34px;
        min-width: 34px;
        height: 34px;
    }
    .af-appbar-profile svg { width: 18px; height: 18px; }
}

/* ── Mobile Sidebar Drawer ──────────────────────────────────── */
.af-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.52);
    z-index: 3999;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.af-sidebar-overlay.active { display: block; }

@keyframes sbSlideIn {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
}

@media (max-width: 1023px) {
    .af-sidebar.mobile-open {
        display: flex !important;
        width: 280px;
        z-index: 4000;
        box-shadow: 8px 0 40px rgba(0,0,0,.38);
        animation: sbSlideIn .24s cubic-bezier(.4,0,.2,1);
    }
    .af-sidebar.mobile-open .af-nav-label {
        opacity: 1 !important;
        transition-delay: 0s !important;
    }
    .af-sidebar.mobile-open .af-nav-section {
        opacity: 1 !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   GATILHO DO LOGO NO APPBAR
   O tamanho fica travado AQUI, fora de qualquer media query, de
   propósito: se só parte deste arquivo chegar ao navegador (cache
   antigo, arquivo truncado), o logo ainda assim nunca renderiza no
   tamanho natural nem estoura o alinhamento do cabeçalho.
   ═══════════════════════════════════════════════════════════ */
.af-appbar-logo {
    display: none;              /* mobile: cabeçalho segue sem logo */
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: none;
    cursor: pointer;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    transition: background .16s;
}

/* Trava dura de imagem no appbar — vale para o gatilho e para qualquer
   outra imagem que caia no cabeçalho. */
.af-appbar-logo img,
.af-appbar img {
    display: block;
    max-height: 32px;
    max-width: 32px;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* ═══════════════════════════════════════════════════════════
   DESKTOP (>= 1024px) — sidebar retrátil em drawer flutuante
   1. A sidebar sai do layout (invisível e sem captar clique).
   2. O conteúdo ocupa 100% da largura útil (margin-left: 0).
   3. Ela reaparece SOBRE o conteúdo (position:fixed + z-index),
      nunca empurrando o layout, via classe `.is-open` que o
      assets/js/sidebar-drawer.js liga no hover/clique do logo.
   ═══════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
    /* ── 1. Fora do layout ──────────────────────────────────── */
    .af-sidebar {
        width: var(--sb-w1);
        height: 100vh;
        transform: translateX(-100%);
        visibility: hidden;
        pointer-events: none;
        box-shadow: none;
        /* visibility só volta a hidden depois que a saída termina */
        transition: transform var(--sb-transition),
                    box-shadow var(--sb-transition),
                    visibility 0s linear .28s;
    }
    /* o hover do rail antigo (64→240px) não existe mais no desktop */
    .af-sidebar:hover { width: var(--sb-w1); box-shadow: none; }

    /* ── 2. Conteúdo em 100% da largura ─────────────────────── */
    .af-main { margin-left: 0 !important; }

    /* ── 3. Drawer flutuante aberto ─────────────────────────── */
    .af-sidebar.is-open,
    .af-sidebar.mobile-open,
    .af-sidebar.is-open:hover,
    .af-sidebar.mobile-open:hover {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
        z-index: 4000;
        box-shadow: 8px 0 40px rgba(0,0,0,.32);
        transition: transform var(--sb-transition),
                    box-shadow var(--sb-transition),
                    visibility 0s;
    }

    /* Drawer abre sempre em 240px — sem estado intermediário de rail,
       então os rótulos não dependem mais de :hover pra aparecer. */
    .af-sidebar .af-nav-label,
    .af-sidebar .af-nav-section {
        opacity: 1;
        transition-delay: 0s;
    }

    /* ── 4. Gatilho visível no cabeçalho ────────────────────── */
    .af-appbar-logo { display: flex; }
    .af-appbar-logo:hover,
    .af-appbar-logo:focus-visible { background: rgba(255,255,255,0.10); }

    /* Dropdown de notificações acompanha a largura do drawer aberto */
    #notif-dropdown { left: calc(var(--sb-w1) + 12px); }
}