:root {
    --bg: #f3f4f6;
    --card: #ffffff;
    --accent: #2563eb;
    --accent-soft: rgba(37,99,235,0.06);
    --text: #111827;
    --muted: #6b7280;
    --danger: #dc2626;
    --border: #e5e7eb;
}

/* RESET / BASE ---------------------------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f3f4f6;
    color: var(--text);
}

a {
    color: #2563eb;
    text-decoration: none;
}

/* TOPO VITRINE (topbar antiga) ------------ */
.page {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.logo {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 20%, #2563eb, #1d4ed8);
    display:flex;
    align-items:center;
    justify-content:center;
    font-weight:700;
    font-size:0.9rem;
    color:#f9fafb;
}

.topbar-title { font-weight: 600; }
.topbar-sub   { font-size: 0.75rem; color: var(--muted); }

.topbar-right {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 0.85rem;
}

/* Botões genéricos ------------------------ */
.btn {
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text);
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.btn-primary {
    border-color: transparent;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #f9fafb;
}

.btn-soft {
    border-color: var(--border);
    background: var(--accent-soft);
    color: #1f2937;
}

.btn-icon { padding-inline: 0.5rem; }

.btn:hover {
    box-shadow: 0 4px 12px rgba(15,23,42,0.15);
    transform: translateY(-1px);
}

.badge-cart {
    border-radius: 999px;
    background: #111827;
    color:#f9fafb;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    cursor:pointer;
}

/* Conteúdo vitrine ------------------------ */
.content {
    flex: 1;
    padding: 0.6rem 1rem 0.75rem;
    overflow-y: auto;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: .5rem;
    font-size: 0.85rem;
}

.toolbar-left span { color: var(--muted); }

.filters-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    margin-bottom: 0.6rem;
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    background: rgba(255,255,255,0.9);
    border: 1px solid var(--border);
}

.filters-form input[type="text"],
.filters-form select {
    padding: 0.25rem 0.45rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text);
    font-size: 0.8rem;
}

.filters-form label span {
    color: var(--muted);
    font-size: 0.75rem;
}

.select-small {
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text);
    font-size: 0.8rem;
}

/* Cards vitrine --------------------------- */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.9rem;
}

.card {
    background: var(--card);
    border-radius: 0.9rem;
    border: 1px solid var(--border);
    padding: 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    box-shadow: 0 6px 18px rgba(15,23,42,0.06);
}

.card-header { display: flex; gap: .75rem; }

.card-img {
    width: 72px;
    height: 72px;
    border-radius: .6rem;
    background: #e5e7eb;
    overflow: hidden;
    flex-shrink: 0;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size: 0.65rem;
    color: var(--muted);
}

.card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.card-title {
    font-size: 0.82rem;
    font-weight: 600;
    color:#111827;
}

.card-sub {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    font-size: 0.68rem;
    border: 1px solid var(--border);
    background: #f9fafb;
}

.pill-est-crit   { border-color: var(--danger); color: var(--danger); background:#fee2e2; }
.pill-est-normal { border-color: #16a34a;   color: #166534; background:#dcfce7; }

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 0.25rem;
}

.preco { font-size: 0.9rem; font-weight: 600; color:#111827; }
.preco span { font-size: 0.7rem; color: var(--muted); display:block; }

.card-actions {
    margin-top: 0.4rem;
    display:flex;
    justify-content:flex-end;
}

/* Paginação genérica ---------------------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    margin-top: 0.9rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
}

.page-link {
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background:#ffffff;
}

.page-link.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #f9fafb;
    font-weight: 600;
}

.page-link.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* Rodapé ---------------------------------- */
footer {
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: #6b7280;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: .4rem 1rem;
    background:#ffffff;
    box-sizing:border-box;
}

/* Modais ---------------------------------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-backdrop.show { display: flex; }

.modal {
    width: 100%;
    max-width: 360px;
    background: #ffffff;
    border-radius: 1rem;
    border: 1px solid var(--border);
    padding: 1.2rem 1rem 1rem;
    box-shadow: 0 24px 55px rgba(15,23,42,0.25);
}

.modal-header {
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-bottom: 0.6rem;
}

.modal-title { font-size: 0.95rem; font-weight: 600; }

.modal-close {
    cursor:pointer;
    border:none;
    background:transparent;
    color: var(--muted);
    font-size: 1rem;
}

.modal-body label {
    display:block;
    font-size:0.75rem;
    margin-top:0.4rem;
    margin-bottom:0.15rem;
}

.modal-body input {
    width: 100%;
    padding: 0.4rem 0.55rem;
    border-radius: 0.4rem;
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text);
    font-size: 0.8rem;
}

.modal-footer {
    margin-top: 0.7rem;
    display:flex;
    justify-content:flex-end;
    gap:0.4rem;
}

.msg-erro {
    margin-top: 0.3rem;
    font-size: 0.75rem;
    color: var(--danger);
}

/* Sessões / alertas ----------------------- */
.session-alert {
    margin: 0 0 1rem 0;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}

/* Auth grid --------------------------------*/
.auth-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
}

.auth-card {
    background: var(--card);
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 10px 25px rgba(15,23,42,0.08);
}

.auth-card h2 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.auth-card label {
    display: block;
    margin-top: 0.6rem;
    font-size: 0.85rem;
}

.auth-card input[type="text"],
.auth-card input[type="email"],
.auth-card input[type="password"] {
    margin-top: 0.25rem;
    width: 100%;
    padding: 0.4rem 0.55rem;
    border-radius: 0.4rem;
    border: 1px solid var(--border);
    font-size: 0.85rem;
}

/* WhatsApp flutuante ---------------------- */
#whatsapp-btn {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 99999;
    transition: transform 0.2s ease-in-out;
}

#whatsapp-btn:hover { transform: scale(1.07); }

#whatsapp-btn img {
    width: 70px;
    height: 70px;
    border-radius: 50%;
}

/* Tabela (admin) -------------------------- */
table {
    width:100%;
    border-collapse:collapse;
    font-size:0.8rem;
    background:#ffffff;
}

th, td {
    border-bottom:1px solid #e5e7eb;
    padding:0.45rem 0.5rem;
}

th {
    text-align:left;
    background:#f9fafb;
    position: sticky;
    top: 0;
    z-index: 30;
    background: linear-gradient(#ffffff, #f8f9fa);
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

tr:hover { background:#f3f4f6; }

/* Botões pequenos ------------------------- */
.btn-sm {
    padding:0.2rem 0.45rem;
    border-radius:999px;
    border:1px solid #d1d5db;
    background:#ffffff;
    font-size:0.75rem;
    cursor:pointer;
}

.btn-sm-primary {
    background:#22c55e;
    border-color:#22c55e;
    color:#f9fafb;
    font-weight:600;
}

/* Paginação admin ------------------------- */
.header-pager {
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:0.5rem;
    flex-wrap:wrap;
    margin-top:0.15rem;
}

.page-link.active {
    background:#2563eb;
    border-color:#2563eb;
    color:#f9fafb;
}

/* Navegação por seções -------------------- */
.nav-link { font-size:0.85rem; }
.nav-link.active { font-weight:600; text-decoration:underline; }

.view-section { display:none; }

.view-section.active {
    display:block;
    opacity:1;
    transform:translateY(0);
}

.view-section.fade-in {
    animation: fadeSlideIn 0.25s ease-out;
}

@keyframes fadeSlideIn {
    from { opacity:0; transform:translateY(6px); }
    to   { opacity:1; transform:translateY(0); }
}

/* Títulos / textos painéis ---------------- */
.page-title {
    font-size:1.05rem;
    font-weight:600;
    margin-bottom:0.2rem;
}

.page-sub {
    font-size:0.8rem;
    color:#6b7280;
    margin-bottom:0.75rem;
}

.cards-grid {
    display:grid;
    grid-template-columns:repeat(auto-fit,minmax(160px,1fr));
    gap:0.75rem;
    margin-bottom:1rem;
}

.dash-grid {
    display:grid;
    grid-template-columns:2fr 1.5fr;
    gap:0.75rem;
}

.dash-panel {
    background:#ffffff;
    border-radius:0.75rem;
    padding:0.75rem 0.85rem;
    box-shadow:0 1px 2px rgba(15,23,42,0.05);
    border:1px solid #e5e7eb;
}

.section-title {
    font-size:0.9rem;
    font-weight:600;
    margin-bottom:0.3rem;
}

.section-sub {
    font-size:0.75rem;
    color:#6b7280;
    margin-bottom:0.5rem;
}

.card-value { font-size:1.15rem; font-weight:600; }

/* Pílulas de status ------------------------ */
.pill-ok,
.pill-warn,
.pill-bad {
    display:inline-block;
    padding:0.1rem 0.45rem;
    border-radius:999px;
    font-size:0.7rem;
    font-weight:500;
}

.pill-ok   { background:#ecfdf3; color:#15803d; }
.pill-warn { background:#fef3c7; color:#92400e; }
.pill-bad  { background:#fee2e2; color:#b91c1c; }

/* HEADER + MAIN FIXOS (admin páginas) ----- */
header, footer { background:#ffffff; }

header {
    position:fixed;
    top:0;
    left:0;
    right:0;
    z-index:100;
    border-bottom:1px solid #e5e7eb;
    padding:0.35rem 0 0.35rem;
    box-sizing:border-box;
}

/* ÁREA SCROLLÁVEL PRINCIPAL --------------- */
.page-main {
    position:fixed;
    left:0;
    right:0;
    top:80px;   /* altura aproximada do header */
    bottom:32px;/* altura do footer */
    padding:0.75rem 1rem;
    overflow-y:auto;
    box-sizing:border-box;
}

/* ===== TOPO ADMIN PRODUTOS =============== */
.admin-header-shell {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.15rem 1.25rem 0.25rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;         /* espaço curto entre título / subtítulo / botões */
}

.admin-header-left {
    display:flex;
    flex-direction:column;
    gap:0.05rem;
}

.admin-header-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.admin-header-sub {
    font-size: 0.85rem;
    color: var(--muted);
}

.admin-header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* BOTÕES TIPO "PÍLULA" DO TOPO ------------ */
.nav-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.38rem 0.95rem;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    color: #111827;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
    white-space: nowrap;
}

.nav-pill:hover {
    background: #e5edff;
    box-shadow: 0 4px 10px rgba(15,23,42,0.12);
    transform: translateY(-1px);
}

.nav-pill:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(15,23,42,0.12);
}

.nav-pill-primary {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

.nav-pill-primary:hover { background: #1d4ed8; }

/* MENU RELATÓRIOS (dropdown) -------------- */
.nav-menu {
    position: relative;
    display: inline-block;
}

.nav-menu-dropdown {
    position: absolute;
    top: 120%;
    right: 0;
    min-width: 220px;
    background: #ffffff;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 14px 40px rgba(15,23,42,0.18);
    padding: 0.4rem 0;
    display: none;
    z-index: 40;
}

.nav-menu.open .nav-menu-dropdown { display:block; }

.nav-menu-item {
    width: 100%;
    padding: 0.45rem 0.9rem;
    text-align: left;
    border: none;
    background: transparent;
    font-size: 0.85rem;
    color: #111827;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.nav-menu-item:hover {
    background: #f3f4f6;
}

/* RESPONSIVO --------------------------------*/
@media (max-width: 900px) {
    .dash-grid { grid-template-columns:1fr; }
}

@media (max-width: 768px) {
    .auth-grid { grid-template-columns: 1fr; }

    .admin-header-shell {
        align-items:flex-start;
    }
}

@media (max-width: 640px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .filters-form {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ===== FILTROS ADMIN – CAMPOS ARREDONDADOS ===== */
.top-filters input[type="text"],
.top-filters select {
    height: 25px;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;           /* cantos totalmente arredondados */
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #111827;
    font-size: 0.6rem;
    outline: none;
    transition: 
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        background 0.15s ease;
}

/* Hover */
.top-filters input[type="text"]:hover,
.top-filters select:hover {
    border-color: #93c5fd;
}

/* Focus */
.top-filters input[type="text"]:focus,
.top-filters select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* Ajuste visual do select (remove aparência pesada mobile) */
.top-filters select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, #6b7280 50%),
        linear-gradient(135deg, #6b7280 50%, transparent 50%);
    background-position:
        calc(100% - 16px) 55%,
        calc(100% - 11px) 55%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 1.6rem;
}

/* Campo de busca um pouco maior */
.top-filters input[type="text"] {
    min-width: 100px;
}

/* Mobile: campos ocupam largura total */
@media (max-width: 640px) {
    .top-filters input[type="text"],
    .top-filters select {
        width: 100%;
    }
}

/* =====================================================
   TOPO PRODUTOS – ALINHAMENTO BOTÕES + FILTROS
   ===================================================== */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* form de filtros */
.top-filters {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

/* =====================================================
   FILTROS ADMIN – CAMPOS PADRONIZADOS (PREMIUM)
   (somente input Buscar + selects Tipo/Marca/Estoque/Limit)
   ===================================================== */
.top-filters input[type="text"],
.top-filters select {
    height: 25px;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;                 /* cantos bem arredondados */
    border: 1px solid #d1d5db;
    background: rgba(255,255,255,0.95);
    color: #111827;
    font-size: 0.6rem;
    outline: none;

    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.9),
        0 1px 2px rgba(15,23,42,0.08);

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        background 0.15s ease,
        transform 0.08s ease;
}

/* Hover */
.top-filters input[type="text"]:hover,
.top-filters select:hover {
    border-color: #93c5fd;
    background: #ffffff;
}

/* Focus */
.top-filters input[type="text"]:focus,
.top-filters select:focus {
    border-color: #2563eb;
    box-shadow:
        0 0 0 2px rgba(37,99,235,0.18),
        0 6px 16px rgba(37,99,235,0.18);
}

/* Campo buscar um pouco maior */
.top-filters input[type="text"] {
    min-width: 100px;
}

/* Select clean (remove estilo pesado do navegador) */
.top-filters select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    background-image:
        linear-gradient(45deg, transparent 50%, #6b7280 50%),
        linear-gradient(135deg, #6b7280 50%, transparent 50%);
    background-position:
        calc(100% - 16px) 55%,
        calc(100% - 11px) 55%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;

    padding-right: 1.8rem;
}

/* =====================================================
   MOBILE
   ===================================================== */
@media (max-width: 640px) {
    .header-actions {
        align-items: stretch;
    }

    .top-filters {
        width: 100%;
    }

    .top-filters input[type="text"],
    .top-filters select {
        width: 100%;
    }
}
