/* =========================================================
   Materiais PDV — Estilos globais
   ========================================================= */

:root {
  --primary:      #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light:#dbeafe;
  --success:      #16a34a;
  --warning:      #d97706;
  --danger:       #dc2626;
  --gray-50:      #f9fafb;
  --gray-100:     #f3f4f6;
  --gray-200:     #e5e7eb;
  --gray-300:     #d1d5db;
  --gray-400:     #9ca3af;
  --gray-500:     #6b7280;
  --gray-600:     #4b5563;
  --gray-700:     #374151;
  --gray-800:     #1f2937;
  --gray-900:     #111827;
  --sidebar-w:    240px;
  --header-h:     60px;
  --radius:       8px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
  --shadow:       0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:    0 8px 24px rgba(0,0,0,.12);
  --font:         'Inter', system-ui, sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

button { cursor: pointer; font-family: inherit; }

/* =========================================================
   Tela de Login
   ========================================================= */

.login-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 50%, #2563eb 100%);
  padding: 24px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 44px;
  height: 44px;
  background: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.login-logo .logo-text h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}

.login-logo .logo-text span {
  font-size: 12px;
  color: var(--gray-500);
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 28px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  color: var(--gray-900);
  background: #fff;
  transition: border-color .15s;
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.form-input::placeholder { color: var(--gray-400); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: background .15s, opacity .15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-full { width: 100%; }

.btn:disabled { opacity: .6; cursor: not-allowed; }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
}

.alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: var(--warning);
}

/* =========================================================
   Layout do App
   ========================================================= */

.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--gray-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.sidebar-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-logo h2 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-logo span {
  font-size: 11px;
  color: var(--gray-400);
}

.sidebar-user {
  background: rgba(255,255,255,.06);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.sidebar-user .user-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .user-role {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
  text-transform: capitalize;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gray-500);
  padding: 8px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-400);
  cursor: pointer;
  transition: background .12s, color .12s;
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}

.nav-item.active {
  background: var(--primary);
  color: #fff;
}

.nav-item .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .nav-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.15);
}

.nav-item.active .nav-badge {
  background: rgba(255,255,255,.25);
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* Main */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--header-h);
  min-height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

/* =========================================================
   Cards KPI
   ========================================================= */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}

.kpi-card .kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 8px;
}

.kpi-card .kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
  margin-bottom: 6px;
}

.kpi-card .kpi-sub {
  font-size: 12px;
  color: var(--gray-400);
}

.kpi-card .kpi-icon {
  font-size: 24px;
  float: right;
  margin-top: -4px;
}

/* =========================================================
   Seção "em breve"
   ========================================================= */

.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 360px;
  text-align: center;
  color: var(--gray-400);
}

.coming-soon .cs-icon { font-size: 48px; margin-bottom: 16px; }

.coming-soon h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.coming-soon p {
  font-size: 14px;
  margin-bottom: 16px;
  max-width: 320px;
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: #dcfce7; color: var(--success); }
.badge-yellow { background: #fef9c3; color: var(--warning); }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-gray   { background: var(--gray-100); color: var(--gray-500); }
.badge-red    { background: #fee2e2; color: var(--danger); }

/* =========================================================
   Tabela
   ========================================================= */

.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  background: var(--gray-50);
  text-align: left;
  padding: 10px 16px;
  font-weight: 600;
  color: var(--gray-600);
  font-size: 12px;
  border-bottom: 1px solid var(--gray-200);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

tr:last-child td { border-bottom: none; }

.table-empty {
  text-align: center;
  padding: 32px !important;
  color: var(--gray-400);
}

/* =========================================================
   Spinner
   ========================================================= */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   Modais
   ========================================================= */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

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

.modal-box {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
}

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}

.modal-close:hover { background: var(--gray-100); }

.modal-body {
  overflow-y: auto;
  padding: 20px;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--gray-200);
  flex-shrink: 0;
}

/* =========================================================
   Form grid
   ========================================================= */

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}

textarea.form-input {
  resize: vertical;
  min-height: 64px;
}

select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  appearance: none;
}

/* =========================================================
   Toast animation
   ========================================================= */

@keyframes slideIn {
  from { transform: translateX(60px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* =========================================================
   PDV Layout
   ========================================================= */

.pdv-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  height: calc(100vh - 72px);
  overflow: hidden;
}

.pdv-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
}

.pdv-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.pdv-search-card {
  padding: 12px 16px;
  flex-shrink: 0;
}

.pdv-cart {
  flex: 1;
  min-height: 200px;
}

.pdv-empty {
  padding: 40px;
  text-align: center;
  color: var(--gray-400);
  font-size: 13px;
}

.pdv-sug-box {
  position: absolute;
  top: 2px;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 200;
  max-height: 280px;
  overflow-y: auto;
}

.pdv-sug-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  transition: background .1s;
}

.pdv-sug-item:last-child { border-bottom: none; }
.pdv-sug-item:hover      { background: var(--primary-bg, #eff6ff); }

.pdv-sug-empty {
  padding: 14px;
  text-align: center;
  color: var(--gray-400);
  font-size: 13px;
}

.pdv-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.pdv-forma-btn {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  justify-content: flex-start;
  gap: 6px;
  transition: background .15s, border-color .15s;
}

.pdv-forma-btn:hover {
  background: var(--primary-bg, #eff6ff);
  border-color: var(--primary, #2563eb);
}

/* =========================================================
   Tabs
   ========================================================= */

.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--gray-200);
  padding-bottom: 0;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  transition: color .15s, border-color .15s, background .15s;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--primary);
  background: var(--primary-bg, #eff6ff);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--primary-bg, #eff6ff);
}

.badge-danger { background: #fee2e2; color: var(--danger); }

/* ── NF-e ─────────────────────────────────────────────────── */
.nfe-wrapper { max-width: 1200px; }

.nfe-drop-area {
  border: 2px dashed var(--gray-300);
  border-radius: 12px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  color: var(--gray-500);
}
.nfe-drop-area:hover,
.nfe-drop-area.drag-over {
  border-color: var(--primary);
  background: #eff6ff;
  color: var(--primary);
}
.nfe-drop-icon { font-size: 40px; margin-bottom: 8px; }
