/* ============================================================
   Decor Gramas — Gestão Comercial Interna
   Design system do painel administrativo.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --brand:     #0F2A20;
  --brand-2:   #1E5240;
  --brand-3:   #3E8A6C;
  --accent:    #A8C9B5;
  --wa:        #25D366;
  --wa-dark:   #128C7E;
  --ink:       #111827;
  --ink-2:     #374151;
  --ink-3:     #6B7280;
  --line:      #E5E7EB;
  --line-2:    #F3F4F6;
  --bg:        #F8FAFC;
  --white:     #FFFFFF;
  --danger:    #EF4444;
  --warn:      #F59E0B;
  --ok:        #10B981;
  --sidebar-w: 240px;
  --header-h:  60px;
  --radius:    8px;
  --radius-lg: 14px;
  --shadow:    0 1px 4px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: 'Inter', -apple-system, sans-serif; font-size: 14px; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; }
input, textarea, select { font-family: inherit; }
img { max-width: 100%; display: block; }

/* ── Layout principal ── */
.layout { display: flex; height: 100vh; overflow: hidden; }

/* ════════════════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--brand);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 20px 20px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo .logo-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.02em;
}
.sidebar-logo .logo-sub {
  font-size: 11px;
  color: var(--accent);
  margin-top: 2px;
  letter-spacing: 0.04em;
}

.sidebar-nav { padding: 16px 10px; flex: 1; }
.nav-section {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(168,201,181,0.6);
  padding: 0 10px;
  margin: 16px 0 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(247,244,237,0.7);
  cursor: pointer;
  transition: all 0.18s;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.nav-item.active { background: rgba(255,255,255,0.12); color: var(--white); }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--brand-3);
  color: var(--white);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 100px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  text-align: center;
}

/* ════════════════════════════════════════════════════
   CONTEÚDO PRINCIPAL
════════════════════════════════════════════════════ */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  flex-shrink: 0;
}
.topbar-title { font-size: 16px; font-weight: 600; color: var(--ink); flex: 1; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

/* ════════════════════════════════════════════════════
   BOTÕES
════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  border: none; transition: all 0.18s; white-space: nowrap;
  line-height: 1;
}
.btn-sm  { padding: 6px 12px; font-size: 12.5px; }
.btn-lg  { padding: 11px 22px; font-size: 14.5px; }
.btn-icon{ padding: 7px; aspect-ratio: 1; justify-content: center; }

.btn-primary  { background: var(--brand-2); color: var(--white); }
.btn-primary:hover  { background: var(--brand); }
.btn-brand    { background: var(--brand); color: var(--white); }
.btn-brand:hover    { opacity: 0.9; }
.btn-wa       { background: var(--wa); color: var(--white); }
.btn-wa:hover { background: var(--wa-dark); }
.btn-ghost    { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--line-2); }
.btn-danger   { background: #FEE2E2; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--white); }
.btn-ok       { background: #D1FAE5; color: #065F46; }
.btn-ok:hover { background: var(--ok); color: var(--white); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ════════════════════════════════════════════════════
   CARDS / STATS
════════════════════════════════════════════════════ */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.stat-label { font-size: 12px; font-weight: 500; color: var(--ink-3); letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--ink); letter-spacing: -0.03em; line-height: 1; }
.stat-value.green { color: var(--brand-2); }
.stat-sub { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

/* ════════════════════════════════════════════════════
   TABELAS
════════════════════════════════════════════════════ */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  gap: 12px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.card-body { padding: 20px; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 10px 14px; text-align: left;
  font-size: 11.5px; font-weight: 600;
  color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--line-2);
  border-bottom: 1px solid var(--line);
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--ink-2);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--line-2); }
.data-table td.actions { display: flex; gap: 6px; }
.data-table td strong { color: var(--ink); font-weight: 600; }

/* ════════════════════════════════════════════════════
   BADGES DE STATUS
════════════════════════════════════════════════════ */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 100px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em;
}
.badge-rascunho { background: #FEF3C7; color: #92400E; }
.badge-enviada  { background: #DBEAFE; color: #1E40AF; }
.badge-aprovada { background: #D1FAE5; color: #065F46; }
.badge-recusada { background: #FEE2E2; color: #991B1B; }
.badge-ativo    { background: #D1FAE5; color: #065F46; }
.badge-inativo  { background: var(--line-2); color: var(--ink-3); }

/* ════════════════════════════════════════════════════
   FORMULÁRIOS
════════════════════════════════════════════════════ */
.form-grid { display: grid; gap: 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--ink);
  background: var(--white);
  transition: border-color 0.18s;
  width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--brand-3);
  box-shadow: 0 0 0 3px rgba(62,138,108,0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.form-group .hint { font-size: 11.5px; color: var(--ink-3); }

/* ── Linha de item de proposta ── */
.item-row {
  display: grid;
  grid-template-columns: 1fr 80px 72px 120px 36px;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}
.item-row:last-child { border-bottom: none; }
.item-row .form-group { margin: 0; }
.btn-rm-item {
  width: 36px; height: 36px; border-radius: var(--radius);
  background: #FEE2E2; color: var(--danger); display: grid; place-items: center; font-size: 18px;
  transition: all 0.18s; flex-shrink: 0; align-self: end;
}
.btn-rm-item:hover { background: var(--danger); color: var(--white); }

/* Total strip */
.total-strip {
  background: var(--line-2);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex; gap: 24px; align-items: center;
  margin-top: 12px; font-size: 13.5px;
}
.total-principal { margin-left: auto; font-size: 18px; font-weight: 700; color: var(--brand-2); }

/* ════════════════════════════════════════════════════
   MODAL
════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 760px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-lg { max-width: 1000px; }
.modal-sm { max-width: 480px; }
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 10px;
  flex-shrink: 0;
}
.btn-close-modal {
  background: none; border: none; font-size: 22px;
  color: var(--ink-3); cursor: pointer; line-height: 1;
  padding: 0 4px; transition: color 0.18s;
}
.btn-close-modal:hover { color: var(--ink); }

/* ════════════════════════════════════════════════════
   BUSCA
════════════════════════════════════════════════════ */
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--line-2); border-radius: var(--radius);
  padding: 6px 12px; border: 1.5px solid transparent;
  transition: border-color 0.18s;
}
.search-box:focus-within { border-color: var(--brand-3); background: var(--white); }
.search-box input { border: none; background: none; font-size: 13.5px; outline: none; width: 220px; }
.search-box .icon { color: var(--ink-3); font-size: 15px; }

/* ════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
════════════════════════════════════════════════════ */
#toasts {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 999;
}
.toast {
  background: var(--ink);
  color: var(--white);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  animation: toastIn 0.25s ease;
  max-width: 360px;
}
.toast.ok      { border-left: 3px solid var(--ok); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--brand-3); }
@keyframes toastIn { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }

/* ════════════════════════════════════════════════════
   EMPTY STATE
════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-3);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h4 { font-size: 16px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.empty-state p { font-size: 13.5px; margin-bottom: 20px; }

/* ════════════════════════════════════════════════════
   AUTOCOMPLETE
════════════════════════════════════════════════════ */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 50; max-height: 220px; overflow-y: auto;
  display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-item {
  padding: 9px 14px; cursor: pointer; font-size: 13.5px;
  border-bottom: 1px solid var(--line-2);
  transition: background 0.12s;
}
.autocomplete-item:hover { background: var(--line-2); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item .sub { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

/* ════════════════════════════════════════════════════
   GALERIA GRID (na proposta)
════════════════════════════════════════════════════ */
.gallery-grid-admin {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.gallery-thumb {
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); position: relative;
  aspect-ratio: 4/3; background: var(--line-2);
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumb .thumb-info {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: var(--white); padding: 8px 10px;
  font-size: 11.5px; font-weight: 500;
}
.gallery-thumb .thumb-actions {
  position: absolute; top: 6px; right: 6px;
  display: flex; gap: 4px; opacity: 0; transition: opacity 0.18s;
}
.gallery-thumb:hover .thumb-actions { opacity: 1; }

/* ════════════════════════════════════════════════════
   RESPONSIVO (mobile básico)
════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr; }
}
