/* ==========================================================
   SISTEMA DE ORÇAMENTOS — DOM PEDRO COZINHA DE SABORES
   Estilo Mobile-First, Moderno, Elegante e Intuitivo
   ========================================================== */

:root {
  --primary: #C59B27;
  --primary-hover: #b0871e;
  --primary-light: #eef3e5;
  --primary-dark: #8f6c10;
  --gold-gradient: linear-gradient(135deg, #f2e4bd 0%, #e8d299 100%);
  
  --dark: #18191c;
  --dark-surface: #22252a;
  --dark-card: #2b2e35;
  
  --bg-app: #f6f8f2;
  color-scheme: light;
  --surface: #ffffff;
  --border: #dfe5d8;
  --border-focus: #C59B27;
  
  --text-main: #344332;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --success: #10b981;
  --success-bg: #ecfdf5;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --info: #3b82f6;
  --info-bg: #eff6ff;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 9999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px -2px rgba(0,0,0,0.08), 0 2px 6px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.1), 0 4px 10px -2px rgba(0,0,0,0.04);
  
  --bottom-nav-height: 68px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==========================================================
   TIPOGRAFIA E BOTÕES
   ========================================================== */
h1, h2, h3, h4, h5 {
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.01em;
}

a {
  color: var(--primary-dark);
  text-decoration: none;
  transition: color 0.15s;
}

a:hover {
  color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
  user-select: none;
  min-height: 46px;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--gold-gradient);
  color: #55431c;
  box-shadow: 0 2px 8px rgba(126, 111, 58, 0.12);
  border: none;
}

.btn-primary:hover {
  box-shadow: 0 4px 14px rgba(197, 155, 39, 0.45);
  filter: brightness(1.05);
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--text-main);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}

.btn-danger:hover {
  background-color: #dc2626;
}

.btn-success {
  background-color: var(--success);
  color: #ffffff;
}

.btn-success:hover {
  background-color: #059669;
}

.btn-whatsapp {
  background-color: #25D366;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.btn-whatsapp:hover {
  background-color: #1eb956;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-lg {
  padding: 14px 24px;
  font-size: 16px;
  min-height: 52px;
  border-radius: var(--radius-lg);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  min-height: 34px;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================
   LAYOUT GERAL
   ========================================================== */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Desktop */
.sidebar {
  display: none;
  width: 270px;
  background: var(--surface);
  color: #ffffff;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
  border-right: 1px solid var(--border);
}

.sidebar-brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand img {
  height: 42px;
  width: auto;
  object-fit: contain;
}

.sidebar-menu {
  list-style: none;
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-menu li {
  margin-bottom: 4px;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  color: var(--text-muted);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all 0.2s;
}

.sidebar-menu a:hover {
  color: var(--primary-dark);
  background: var(--primary-light);
}

.sidebar-menu a.active {
  color: var(--primary-dark);
  background: #eaf1df;
  box-shadow: inset 3px 0 var(--primary);
}

.sidebar-menu a svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 600;
  color: var(--text-main);
  font-size: 14px;
}

.user-role {
  font-size: 12px;
  color: var(--primary);
}

/* Área Principal */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-bottom: calc(var(--bottom-nav-height) + 20px);
}

/* Topbar Mobile */
.topbar {
  height: 60px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-brand img {
  height: 36px;
  width: auto;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--dark);
}

.content-area {
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Bottom Bar Mobile (Fixa na tela do celular) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: #ffffff;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 99;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.04);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  flex: 1;
  height: 100%;
  padding: 8px 0;
}

.bottom-nav-item svg {
  width: 22px;
  height: 22px;
}

.bottom-nav-item.active {
  color: var(--primary-dark);
}

.bottom-nav-item.highlight-action {
  position: relative;
  top: -12px;
}

.bottom-nav-item.highlight-action .circle-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--gold-gradient);
  color: #55431c;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(197, 155, 39, 0.45);
}

.bottom-nav-item.highlight-action .circle-btn svg {
  width: 26px;
  height: 26px;
}

/* ==========================================================
   CARDS E COMPONENTES
   ========================================================== */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 16px;
  font-weight: 700;
}

/* Flash Messages */
.alert {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-sucesso {
  background-color: var(--success-bg);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-erro {
  background-color: var(--danger-bg);
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-draft { background: #f1f5f9; color: #475569; }
.badge-info { background: var(--info-bg); color: #1d4ed8; }
.badge-warning { background: var(--warning-bg); color: #b45309; }
.badge-success { background: var(--success-bg); color: #047857; }
.badge-danger { background: var(--danger-bg); color: #b91c1c; }
.badge-secondary { background: #f1f5f9; color: #64748b; }
.badge-dark { background: #edf0f3; color: #475569; }

/* ==========================================================
   FORMULÁRIOS MOBILE-FIRST
   ========================================================== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  color: #334155;
}

.form-control {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: #ffffff;
  color: var(--text-main);
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 46px;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(197, 155, 39, 0.18);
}

textarea.form-control {
  min-height: 85px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 640px) {
  .form-row-2 { grid-template-columns: 1fr 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
  .form-row-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Autocomplete Container */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 240px;
  overflow-y: auto;
  z-index: 1000;
  margin-top: 4px;
}

.autocomplete-item {
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  flex-direction: column;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover, .autocomplete-item.active {
  background-color: var(--primary-light);
}

.autocomplete-item-title {
  font-weight: 600;
  color: var(--text-main);
}

.autocomplete-item-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.autocomplete-quick-add {
  background: #f8fafc;
  color: var(--primary-dark);
  font-weight: 600;
  padding: 12px 14px;
  cursor: pointer;
  border-top: 1px dashed var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.autocomplete-quick-add:hover {
  background: var(--primary-light);
}

/* ==========================================================
   DASHBOARD KPI CARDS
   ========================================================== */
.hero-cta {
  background: linear-gradient(110deg, #f9fcf4, #edf3e2);
  border: 1px solid #dce5cd;
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  color: #ffffff;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

.hero-cta::after {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(197, 155, 39, 0.25) 0%, rgba(0,0,0,0) 70%);
  pointer-events: none;
}

.hero-cta-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
}

.hero-cta-sub {
  font-size: 14px;
  color: var(--text-muted);
}

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

@media (min-width: 540px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 992px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.kpi-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: #0f172a;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.kpi-card.kpi-success {
  border-left: 4px solid var(--success);
}

.kpi-card.kpi-danger {
  border-left: 4px solid var(--danger);
}

.kpi-card.kpi-warning {
  border-left: 4px solid var(--warning);
}

.kpi-card.kpi-primary {
  border-left: 4px solid var(--primary);
}

/* ==========================================================
   ETAPAS WIZARD ORÇAMENTO MOBILE
   ========================================================== */
.wizard-steps {
  display: flex;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 8px;
  margin-bottom: 20px;
  overflow-x: auto;
  gap: 8px;
  border: 1px solid var(--border);
  scrollbar-width: none;
}

.wizard-steps::-webkit-scrollbar {
  display: none;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  background: transparent;
  border: none;
  cursor: pointer;
}

.wizard-step.active {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.wizard-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.wizard-step.active .wizard-step-num {
  background: var(--primary);
  color: #ffffff;
}

.wizard-pane {
  display: none;
}

.wizard-pane.active {
  display: block;
}

.wizard-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ==========================================================
   ITENS E SEÇÕES DO CARDÁPIO NO ORÇAMENTO
   ========================================================== */
.section-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.section-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-box-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--dark);
}

.budget-item-row {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.budget-item-info {
  flex: 1;
}

.budget-item-name {
  font-weight: 600;
  color: var(--text-main);
}

.budget-item-desc {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================
   MODAIS MOBILE
   ========================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(3px);
  z-index: 1000;
  align-items: flex-end; /* Abre tipo Action Sheet no celular */
  justify-content: center;
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
  }
}

.modal-overlay.active {
  display: flex;
}

.modal-container {
  background: #ffffff;
  width: 100%;
  max-width: 520px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease-out;
}

@media (min-width: 640px) {
  .modal-container {
    border-radius: var(--radius-lg);
  }
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
}

/* ==========================================================
   RESPONSIVIDADE DESKTOP
   ========================================================== */
@media (min-width: 992px) {
  .sidebar {
    display: flex;
  }
  
  .topbar-menu-btn {
    display: none;
  }
  
  .bottom-nav {
    display: none;
  }
  
  .main-wrapper {
    padding-bottom: 30px;
  }

  .content-area {
    padding: 24px;
  }
}

/* Leitura confortável, navegação e foco em todas as páginas. */
.sidebar-brand { min-height: 162px; justify-content: center; background: #f4f6ec; }
.sidebar-brand img { max-width: 100%; height: 120px; }
.card, .kpi-card { box-shadow: 0 2px 8px rgba(71, 58, 30, .035); }
.card-header { gap: 12px; flex-wrap: wrap; }
.btn-primary:hover { color: #55431c; }
:focus-visible { outline: 3px solid #b28a28; outline-offset: 3px; }
.form-control { font: inherit; }
table tbody tr:hover { background-color: #fffdf7; }
@media (max-width: 420px) {
  .topbar { padding: 0 10px; gap: 8px; }
  .topbar-brand img { max-width: 90px; object-fit: contain; }
  .topbar .btn { font-size: 12px; padding: 7px 9px; }
  .form-control { font-size: 16px; }
}
@media (min-width: 992px) {
  .content-area { padding: 32px; }
  .hero-cta { flex-direction: row; align-items: center; justify-content: space-between; padding: 30px; }
  .hero-cta .btn-block { width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.topbar-brand img { height: 46px; }
.sidebar-menu a.active { color: #465737; }

.badge-primary { background: #eaf1df; color: #465737; }
