/* ============================================
   VoouComMilhas — Estilo inspirado no Lovable
   Sidebar escura, cards modernos, Tailwind-like
   ============================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;
  --sidebar-bg: #1e1b4b;
  --sidebar-hover: #312e81;
  --sidebar-text: rgba(255,255,255,0.7);
  --sidebar-active: #ffffff;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 0.75rem;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; overflow: hidden; }

/* Layout */
.app-container { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: 260px; background: var(--sidebar-bg); color: white;
  display: flex; flex-direction: column; transition: width 0.3s;
  overflow-y: auto; overflow-x: hidden;
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .sidebar-brand h2, .sidebar.collapsed .sidebar-brand small,
.sidebar.collapsed .sidebar-section-title { display: none; }
.sidebar.collapsed .sidebar-nav li a span:not(.icon) { display: none; }
.sidebar.collapsed .sidebar-nav li a { justify-content: center; padding: 0.75rem 0; }
.sidebar.collapsed .sidebar-nav li a .icon { font-size: 1.2rem; }

.sidebar-brand { padding: 1.25rem 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-brand h2 { font-size: 1.1rem; font-weight: 700; color: white; }
.sidebar-brand small { font-size: 0.7rem; color: var(--sidebar-text); }

.sidebar-toggle { background: none; border: none; color: var(--sidebar-text); cursor: pointer; padding: 0.75rem 1.5rem; font-size: 1.1rem; width: 100%; text-align: left; }
.sidebar-toggle:hover { color: white; }
.sidebar.collapsed .sidebar-toggle { text-align: center; padding: 0.75rem 0; }

.sidebar-section-title { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; color: rgba(255,255,255,0.4); padding: 1rem 1.5rem 0.4rem; font-weight: 600; }

.sidebar-nav { list-style: none; padding: 0; margin: 0; }
.sidebar-nav li a {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1.5rem; color: var(--sidebar-text);
  text-decoration: none; font-size: 0.85rem; transition: all 0.15s;
  border-left: 3px solid transparent;
}
.sidebar-nav li a:hover { color: white; background: var(--sidebar-hover); }
.sidebar-nav li a.active { color: var(--sidebar-active); background: var(--sidebar-hover); border-left-color: var(--primary-light); }
.sidebar-nav li a .icon { font-size: 1rem; width: 20px; text-align: center; }

/* Main */
.main-content {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  transition: margin-left 0.3s;
}

.main-header {
  background: var(--card-bg); border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.5rem; display: flex; align-items: center;
  font-size: 0.85rem; color: var(--text); gap: 0.75rem;
}
#main-header-titulo { font-weight: 600; font-size: 0.9rem; white-space: nowrap; }
#main-header-actions { display: flex; gap: 0.5rem; align-items: center; }
.main-header-brand { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; display: flex; align-items: center; gap: 0.5rem; }
.header-logo { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }

.main-body { flex: 1; overflow-y: auto; padding: 1rem 1.5rem; }

/* Page header — hidden (title moved to main-header) */
.page-header { display: none; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; color: var(--text); }

/* Cards */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 0.75rem; }
.card-body { padding: 0.75rem 1rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border: none; border-radius: 0.5rem;
  font-size: 0.8rem; font-weight: 500; cursor: pointer;
  text-decoration: none; transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.75rem; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #f1f5f9; }
.btn-quick-add { padding: 0.2rem 0.45rem; font-size: 0.7rem; border-radius: 50%; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; margin-left: 0.25rem; vertical-align: middle; }

/* Tables */
.table-container { overflow-x: auto; overflow-y: auto; max-height: 60vh; }
table { width: 100%; border-collapse: collapse; }
table th, table td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.8rem; }
table th { background: #f8fafc; font-weight: 600; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); position: sticky; top: 0; z-index: 1; }
table tbody tr:hover { background: #f8fafc; }
.vendas-table th, .vendas-table td { padding: 0.4rem 0.5rem; font-size: 0.72rem; white-space: nowrap; }
.vendas-table { min-width: 1200px; }

/* Forms */
.form-group { margin-bottom: 0.5rem; }
.form-group label { display: block; margin-bottom: 0.15rem; font-weight: 500; font-size: 0.72rem; color: var(--text-muted); }
.form-group label .required { color: var(--danger); }
.form-control {
  width: 100%; padding: 0.35rem 0.5rem; border: 1px solid var(--border);
  border-radius: 0.375rem; font-size: 0.78rem; font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s; background: white;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { color: var(--danger); font-size: 0.7rem; margin-top: 0.2rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.5rem; }
.form-row-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 0.5rem; }

/* Alerts */
.alert { padding: 0.6rem 1rem; border-radius: 0.5rem; margin-bottom: 0.75rem; font-size: 0.8rem; display: flex; align-items: center; justify-content: space-between; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert .close-btn { background: none; border: none; font-size: 1.1rem; cursor: pointer; opacity: 0.5; }
.alert .close-btn:hover { opacity: 1; }

/* Modal */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal-box { background: white; border-radius: var(--radius); padding: 1.5rem; max-width: 400px; width: 90%; box-shadow: var(--shadow-md); }
.modal-box h3 { margin-bottom: 0.75rem; font-size: 1rem; }
.modal-box p { margin-bottom: 1.25rem; color: var(--text-muted); font-size: 0.85rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

.quick-modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 2000; align-items: center; justify-content: center; }
.quick-modal-overlay.active { display: flex; }
.quick-modal-box { background: white; border-radius: var(--radius); padding: 1.5rem; max-width: 450px; width: 90%; box-shadow: var(--shadow-md); }

/* Filtros */
.filtros-toggle { display: flex; align-items: center; justify-content: space-between; cursor: pointer; padding: 0.6rem 1rem; background: #f8fafc; border-radius: 0.5rem; user-select: none; font-size: 0.8rem; }
.filtros-toggle:hover { background: #f1f5f9; }
.filtros-body { display: none; padding: 0.75rem 0 0; }
.filtros-body.open { display: block; }

/* Empty & Loading */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.empty-state p { margin-top: 0.5rem; font-size: 0.85rem; }
.loading { text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.85rem; }

/* Utility */
.text-end { text-align: right; }
.text-center { text-align: center; }
.hidden { display: none; }
