/* ── SELLER APP — MAIN CSS ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #1a56db;
  --primary-dk: #1140a1;
  --success:    #0ea575;
  --danger:     #e02424;
  --warning:    #ff5a1f;
  --info:       #0694a2;
  --bg:         #f3f4f6;
  --bg-card:    #ffffff;
  --text:       #111827;
  --text-light: #6b7280;
  --border:     #e5e7eb;
  --radius:     10px;
  --shadow:     0 1px 6px rgba(0,0,0,.10);
  --nav-h:      60px;
  --header-h:   52px;
}

html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; font-size: 15px; background: var(--bg); color: var(--text); }

/* ── TELA LOGIN ── */
.tela-login { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--primary-dk) 0%, var(--primary) 100%); padding: 16px; }
.login-card { background: white; border-radius: 18px; padding: 36px 28px; width: 100%; max-width: 380px; box-shadow: 0 8px 32px rgba(0,0,0,.25); }
.login-logo { text-align: center; margin-bottom: 28px; }
.logo-icon { width: 64px; height: 64px; background: var(--primary); border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 900; color: white; margin-bottom: 10px; }
.login-logo h1 { font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.login-logo p  { color: var(--text-light); font-size: .85rem; }

/* ── APP SHELL ── */
#app { display: flex; flex-direction: column; height: 100vh; }
.app-header { background: var(--primary); color: white; display: flex; align-items: center; gap: 10px; padding: 0 14px; height: var(--header-h); position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.2); flex-shrink: 0; }
.app-header h2 { flex: 1; font-size: 1rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-user { font-size: .78rem; opacity: .85; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-content { flex: 1; overflow-y: auto; padding: 14px; padding-bottom: calc(var(--nav-h) + 10px); }

/* ── BOTTOM NAV ── */
.bottom-nav { display: flex; background: white; border-top: 1px solid var(--border); height: var(--nav-h); position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; box-shadow: 0 -2px 8px rgba(0,0,0,.08); }
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: none; background: none; cursor: pointer; font-size: .65rem; color: var(--text-light); transition: color .15s; padding: 6px 0; }
.nav-item .nav-icon { font-size: 1.3rem; line-height: 1; }
.nav-item.active { color: var(--primary); font-weight: 700; }
.nav-item:active { background: var(--bg); }

/* ── CAMPOS E FORMULÁRIOS ── */
.campo { margin-bottom: 14px; }
.campo label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-light); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .4px; }
input[type=text], input[type=number], input[type=password], input[type=date], input[type=tel], select, textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .95rem; color: var(--text); background: white; outline: none; transition: border .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { min-height: 70px; resize: vertical; }

/* ── BOTÕES ── */
.btn { padding: 10px 18px; border-radius: 8px; border: none; cursor: pointer; font-size: .9rem; font-weight: 600; transition: opacity .15s, background .15s; display: inline-flex; align-items: center; gap: 6px; }
.btn:active { opacity: .85; }
.btn-primary  { background: var(--primary); color: white; }
.btn-success  { background: var(--success); color: white; }
.btn-danger   { background: var(--danger);  color: white; }
.btn-warning  { background: var(--warning); color: white; }
.btn-outline  { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-sm       { padding: 6px 12px; font-size: .82rem; }
.btn-block    { width: 100%; justify-content: center; }
.btn-icon     { background: none; border: none; cursor: pointer; font-size: 1.1rem; padding: 6px; color: inherit; }

/* ── CARDS ── */
.card { background: var(--bg-card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-header h3 { font-size: .95rem; font-weight: 700; }

/* ── KPI CARDS ── */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.kpi-card { background: white; border-radius: var(--radius); padding: 14px 12px; box-shadow: var(--shadow); text-align: center; }
.kpi-card .kpi-label { font-size: .72rem; color: var(--text-light); text-transform: uppercase; font-weight: 600; margin-bottom: 4px; }
.kpi-card .kpi-val { font-size: 1.35rem; font-weight: 800; color: var(--primary); }
.kpi-card .kpi-val.danger { color: var(--danger); }
.kpi-card .kpi-val.success { color: var(--success); }

/* ── TABELAS ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
thead th { background: var(--bg); color: var(--text-light); padding: 8px 10px; text-align: left; font-size: .75rem; text-transform: uppercase; }
tbody tr:hover { background: var(--bg); }
tbody td { padding: 9px 10px; border-bottom: 1px solid var(--border); }

/* ── LISTA ITEMS ── */
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.list-item-img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--bg); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: var(--text-light); }
.list-item-body { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub   { font-size: .78rem; color: var(--text-light); }
.list-item-right { text-align: right; flex-shrink: 0; }

/* ── BADGES ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-promo   { background: #fde68a; color: #78350f; }

/* ── MODAL ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 300; display: flex; align-items: flex-end; }
.modal-box { background: white; border-radius: 18px 18px 0 0; padding: 20px 18px 30px; width: 100%; max-height: 90vh; overflow-y: auto; animation: slideUp .25s ease; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-header h3 { font-size: 1rem; font-weight: 700; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ── TOAST ── */
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: #111827; color: white; padding: 10px 20px; border-radius: 24px; font-size: .85rem; font-weight: 600; z-index: 500; opacity: 0; transition: opacity .25s; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; }

/* ── SEARCH BAR ── */
.search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-bar input { flex: 1; }

/* ── CHIP TABS (grupos) ── */
.chip-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; scrollbar-width: none; }
.chip-tabs::-webkit-scrollbar { display: none; }
.chip { padding: 6px 14px; border-radius: 20px; border: 1.5px solid var(--border); background: white; font-size: .82rem; font-weight: 600; cursor: pointer; white-space: nowrap; flex-shrink: 0; color: var(--text-light); transition: all .15s; }
.chip.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ── PRODUTO GRID ── */
.produto-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.produto-card { background: white; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); cursor: pointer; transition: transform .1s; position: relative; }
.produto-card:active { transform: scale(.97); }
.produto-card img, .produto-card .prod-placeholder { width: 100%; height: 100px; object-fit: cover; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.produto-card .prod-info { padding: 8px 10px; }
.produto-card .prod-nome { font-weight: 700; font-size: .85rem; line-height: 1.2; margin-bottom: 4px; }
.produto-card .prod-valor { color: var(--primary); font-weight: 800; font-size: .95rem; }
.produto-card .prod-promo { color: var(--warning); }
.prod-badge-promo { position: absolute; top: 6px; right: 6px; background: var(--warning); color: white; font-size: .65rem; font-weight: 800; padding: 2px 7px; border-radius: 20px; text-transform: uppercase; }
.prod-saldo { font-size: .72rem; color: var(--text-light); }

/* ── FAB ── */
.fab { position: fixed; bottom: calc(var(--nav-h) + 16px); right: 16px; width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: white; font-size: 1.5rem; border: none; cursor: pointer; box-shadow: 0 4px 14px rgba(26,86,219,.4); display: flex; align-items: center; justify-content: center; z-index: 150; transition: transform .1s; }
.fab:active { transform: scale(.93); }

/* ── VENDA CARRINHO ── */
.carrinho-bar { background: var(--primary); color: white; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-radius: 10px; margin-bottom: 12px; cursor: pointer; }
.carrinho-bar .car-qtd { font-size: .82rem; opacity: .85; }
.carrinho-bar .car-total { font-size: 1.1rem; font-weight: 800; }

/* ── CHART CONTAINER ── */
.chart-wrap { position: relative; height: 200px; }

/* ── ALERT SEM ESTOQUE ── */
.alert-sem-estoque { background: #fee2e2; border-left: 4px solid var(--danger); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; font-size: .85rem; }
.alert-sem-estoque strong { color: var(--danger); }

/* ── LOADING ── */
.loading { text-align: center; padding: 40px; color: var(--text-light); font-size: .9rem; }
.loading::before { content: '⏳ '; }

/* ── ERRO MSG ── */
.erro-msg { color: var(--danger); font-size: .85rem; margin-top: 8px; font-weight: 600; }

/* ── DIVISOR ── */
.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* ── SEÇÃO ── */
.secao-titulo { font-size: .78rem; text-transform: uppercase; color: var(--text-light); font-weight: 700; letter-spacing: .5px; margin-bottom: 8px; margin-top: 16px; }
.secao-titulo:first-child { margin-top: 0; }

/* ── FILTRO TABS ── */
.filtro-tabs { display: flex; background: var(--bg); border-radius: 8px; padding: 3px; margin-bottom: 14px; }
.filtro-tab { flex: 1; padding: 7px; text-align: center; border-radius: 6px; cursor: pointer; font-size: .82rem; font-weight: 600; color: var(--text-light); border: none; background: none; transition: all .15s; }
.filtro-tab.active { background: white; color: var(--primary); box-shadow: var(--shadow); }

/* ── RESPONSIVE ── */
@media (min-width: 600px) {
  .produto-grid { grid-template-columns: repeat(3, 1fr); }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .app-content { max-width: 700px; margin: 0 auto; }
}

/* ── VERSÃO NO HEADER ── */
.header-user-block { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.header-user { font-size: .78rem; opacity: .9; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-version { font-size: .62rem; opacity: .55; letter-spacing: .03em; font-weight: 500; }

/* ── SELETOR DE TEMA ── */
.tema-options { display: flex; gap: 12px; }
.tema-card {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
  background: var(--bg);
}
.tema-card:active { opacity: .85; }
.tema-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.15); }
.tema-card .ti { font-size: 1.6rem; margin-bottom: 6px; }
.tema-card .tn { font-size: .82rem; font-weight: 600; color: var(--text-light); }
.tema-card.selected .tn { color: var(--primary); }

/* ── DARK THEME ── */
[data-theme="dark"] {
  --bg:         #0f172a;
  --bg-card:    #1e293b;
  --text:       #f1f5f9;
  --text-light: #94a3b8;
  --border:     #334155;
}

[data-theme="dark"] body { background: var(--bg); color: var(--text); }

[data-theme="dark"] .login-card { background: var(--bg-card); }
[data-theme="dark"] .login-logo h1 { color: #93c5fd; }
[data-theme="dark"] .login-logo p  { color: var(--text-light); }

[data-theme="dark"] .bottom-nav { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .nav-item:active { background: #263349; }

[data-theme="dark"] .kpi-card { background: var(--bg-card); }
[data-theme="dark"] .produto-card { background: var(--bg-card); }
[data-theme="dark"] .produto-card .prod-nome { color: var(--text); }
[data-theme="dark"] .produto-card .prod-saldo { color: var(--text-light); }

[data-theme="dark"] .modal-box { background: var(--bg-card); }
[data-theme="dark"] .modal-header h3 { color: var(--text); }

[data-theme="dark"] .chip { background: var(--bg-card); border-color: var(--border); color: var(--text-light); }
[data-theme="dark"] .chip.active { background: var(--primary); color: white; border-color: var(--primary); }

[data-theme="dark"] .filtro-tabs { background: #0a1020; }
[data-theme="dark"] .filtro-tab.active { background: var(--bg-card); }

[data-theme="dark"] input[type=text],
[data-theme="dark"] input[type=number],
[data-theme="dark"] input[type=password],
[data-theme="dark"] input[type=date],
[data-theme="dark"] input[type=tel],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #0a1020;
  border-color: #475569;
  color: var(--text);
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: #475569; }

[data-theme="dark"] thead th { background: #0a1020; color: #64748b; }
[data-theme="dark"] tbody td { border-color: var(--border); }
[data-theme="dark"] tbody tr:hover { background: #263349; }

[data-theme="dark"] .badge-success { background: #052e16; color: #4ade80; }
[data-theme="dark"] .badge-danger  { background: #2d0a0a; color: #f87171; }
[data-theme="dark"] .badge-warning { background: #1c1000; color: #fbbf24; }
[data-theme="dark"] .badge-info    { background: #0c2340; color: #60a5fa; }
[data-theme="dark"] .badge-promo   { background: #2d1a00; color: #fbbf24; }

[data-theme="dark"] .alert-sem-estoque { background: #2d0a0a; }

[data-theme="dark"] .carrinho-bar { background: var(--primary-dk); }

[data-theme="dark"] .tema-card { background: #0a1020; }

[data-theme="dark"] .parcela-btn { background: var(--bg-card); color: var(--text); border-color: var(--border); }
