/* =====================================================================
   PANEL WEB — Ventas
   Diseño limpio, moderno, Bootstrap 5 + variables CSS
   ===================================================================== */

:root {
  --color-primary:   #1a56db;
  --color-secondary: #6b7280;
  --color-success:   #057a55;
  --color-danger:    #e02424;
  --color-warning:   #d97706;
  --color-dark:      #111827;
  --color-bg:        #f3f4f6;
  --color-card:      #ffffff;
  --color-border:    #e5e7eb;
  --color-sidebar:   #1e293b;
  --color-sidebar-text: #94a3b8;
  --color-sidebar-active: #38bdf8;
  --sidebar-width:   240px;
  --header-height:   60px;
  --radius:          8px;
  --shadow:          0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:       0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --font:            'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-dark);
  min-height: 100vh;
}

/* ---- Login ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}
.login-card {
  background: white;
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--color-primary);
  text-align: center;
  margin-bottom: .25rem;
  letter-spacing: -0.5px;
}
.login-sub {
  text-align: center;
  color: var(--color-secondary);
  font-size: .875rem;
  margin-bottom: 2rem;
}

/* ---- Layout principal ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 1.25rem 1.25rem .75rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand h1 {
  font-size: 1.125rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -.3px;
}
.sidebar-brand small {
  color: var(--color-sidebar-text);
  font-size: .7rem;
}
.sidebar-nav {
  padding: .75rem 0;
  flex: 1;
}
.nav-section {
  padding: .5rem 1rem .25rem;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #475569;
}
.nav-item { list-style: none; }
.nav-link {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .55rem 1.25rem;
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-size: .875rem;
  border-radius: 0;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.nav-link:hover {
  background: rgba(255,255,255,.05);
  color: #f1f5f9;
}
.nav-link.active {
  background: rgba(56,189,248,.1);
  color: var(--color-sidebar-active);
  border-left-color: var(--color-sidebar-active);
}
.nav-link .icon { width: 18px; text-align: center; font-size: 1rem; }
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.07);
}
.user-badge {
  display: flex; align-items: center; gap: .625rem;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
}
.user-name { color: #f1f5f9; font-size: .8rem; font-weight: 600; }
.user-role { color: var(--color-sidebar-text); font-size: .7rem; }

/* ---- Main ---- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.main-header {
  height: var(--header-height);
  background: white;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title { font-size: 1rem; font-weight: 600; color: var(--color-dark); }
.main-body { padding: 1.5rem; flex: 1; }

/* ---- Tarjetas stats ---- */
.stat-card {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.375rem;
  flex-shrink: 0;
}
.stat-icon.blue   { background: #dbeafe; color: var(--color-primary); }
.stat-icon.green  { background: #d1fae5; color: var(--color-success); }
.stat-icon.yellow { background: #fef3c7; color: var(--color-warning); }
.stat-icon.red    { background: #fee2e2; color: var(--color-danger); }
.stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1; }
.stat-label { color: var(--color-secondary); font-size: .8rem; margin-top: .2rem; }

/* ---- Tarjeta genérica ---- */
.card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--color-border);
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: .9rem;
}
.card-body { padding: 1.25rem; }

/* ---- Tablas ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: #f9fafb;
  padding: .625rem 1rem;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--color-secondary);
  border-bottom: 1px solid var(--color-border);
}
tbody td { padding: .75rem 1rem; border-bottom: 1px solid #f1f2f4; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f9fafb; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: .2rem .55rem;
  border-radius: 20px;
  font-size: .72rem; font-weight: 600;
}
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f3f4f6; color: #374151; }

/* ---- Botones ---- */
.btn {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .5rem 1rem;
  border-radius: 6px;
  font-size: .875rem; font-weight: 500;
  border: none; cursor: pointer;
  transition: all .15s; text-decoration: none;
}
.btn-primary   { background: var(--color-primary); color: white; }
.btn-primary:hover { background: #1648c6; }
.btn-success   { background: var(--color-success); color: white; }
.btn-success:hover { background: #046c4e; }
.btn-danger    { background: var(--color-danger);  color: white; }
.btn-danger:hover  { background: #c81e1e; }
.btn-secondary { background: #e5e7eb; color: var(--color-dark); }
.btn-secondary:hover { background: #d1d5db; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-outline {
  background: transparent;
  border: 1px solid currentColor;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---- Formularios ---- */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: .375rem; }
.form-control {
  display: block; width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: .875rem;
  transition: border-color .15s, box-shadow .15s;
  background: white;
}
.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right .5rem center; background-size: 1.25em 1.25em; padding-right: 2.5rem; }
.form-hint { font-size: .75rem; color: var(--color-secondary); margin-top: .25rem; }
.form-error { font-size: .75rem; color: var(--color-danger); margin-top: .25rem; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-box {
  background: white;
  border-radius: 10px;
  padding: 1.5rem;
  width: 100%; max-width: 500px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  transform: translateY(10px);
  transition: transform .2s;
  max-height: 90vh; overflow-y: auto;
}
.modal-overlay.open .modal-box { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--color-secondary); padding: .25rem; }

/* ---- Toast ---- */
.toast-container {
  position: fixed; top: 1rem; right: 1rem;
  z-index: 999; display: flex; flex-direction: column; gap: .5rem;
}
.toast {
  background: white;
  border-radius: 8px;
  padding: .75rem 1rem;
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: .5rem;
  font-size: .875rem; min-width: 260px;
  border-left: 4px solid var(--color-primary);
  animation: slideIn .2s ease;
}
.toast.success { border-left-color: var(--color-success); }
.toast.error   { border-left-color: var(--color-danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- Producto thumb ---- */
.prod-thumb {
  width: 40px; height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: #f3f4f6;
}
.prod-no-img {
  width: 40px; height: 40px;
  border-radius: 6px;
  background: #f3f4f6;
  display: flex; align-items: center; justify-content: center;
  color: #9ca3af; font-size: 1.125rem;
}

/* ---- Upload zona ---- */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-zone:hover { border-color: var(--color-primary); background: #f0f5ff; }
.upload-preview { max-width: 160px; max-height: 160px; object-fit: contain; border-radius: 6px; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}

/* ---- Utilities ---- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1rem; }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .75rem; }
.text-muted { color: var(--color-secondary); }
.text-right { text-align: right; }
.fw-bold { font-weight: 700; }
.w-100 { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; }
@media (max-width: 900px) { .grid-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 600px) { .grid-4, .grid-2 { grid-template-columns: 1fr; } }
.spinner { width: 1.25rem; height: 1.25rem; border: 2px solid #e5e7eb; border-top-color: var(--color-primary); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

