/* ============================================================
   InventarioPro – Hoja de estilos principal
   Tipografía: Montserrat · Paleta profesional neutral
   ============================================================ */

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

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --primary:      #1a56db;
  --primary-dark: #1342b0;
  --primary-light:#e9effd;
  --accent:       #0e9f6e;
  --danger:       #e02424;
  --warning:      #f59e0b;
  --info:         #3b82f6;
  --dark:         #111827;
  --gray-900:     #1f2937;
  --gray-800:     #374151;
  --gray-700:     #4b5563;
  --gray-500:     #6b7280;
  --gray-400:     #9ca3af;
  --gray-300:     #d1d5db;
  --gray-200:     #e5e7eb;
  --gray-100:     #f3f4f6;
  --gray-50:      #f9fafb;
  --white:        #ffffff;
  --sidebar-w:    260px;
  --header-h:     64px;
  --radius:       10px;
  --radius-lg:    16px;
  --shadow:       0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 6px -1px rgba(0,0,0,.10), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg:    0 10px 15px -3px rgba(0,0,0,.10), 0 4px 6px -2px rgba(0,0,0,.05);
  --transition:   .2s ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Montserrat', sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.6;
  min-height: 100vh;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; }
button, input, select, textarea { font-family: inherit; }

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}
.sidebar-brand {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-brand .logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff;
}
.sidebar-brand .logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .5px;
}
.sidebar-brand .logo-text span { color: var(--primary); }

.sidebar-nav { padding: 16px 0; flex: 1; }
.nav-section {
  padding: 8px 16px 4px;
  font-size: .67rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.nav-item { margin: 2px 8px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 8px;
  color: var(--gray-400);
  font-size: .85rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.08);
  color: var(--white);
}
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link .icon { font-size: 1rem; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-info {
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: .85rem;
  flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-name {
  font-size: .82rem; font-weight: 600;
  color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role { font-size: .72rem; color: var(--gray-500); }
.btn-logout {
  background: none; border: none; cursor: pointer;
  color: var(--gray-500); font-size: 1rem;
  padding: 4px; border-radius: 6px;
  transition: color var(--transition);
}
.btn-logout:hover { color: var(--danger); }

/* Main content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
}

/* Header */
.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title {
  font-size: 1.05rem; font-weight: 700;
  color: var(--gray-900);
}
.topbar-search {
  flex: 1; max-width: 380px;
  position: relative; margin-left: auto;
}
.topbar-search input {
  width: 100%;
  padding: 8px 16px 8px 40px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: .85rem;
  background: var(--gray-50);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.topbar-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}
.topbar-search .search-icon {
  position: absolute; left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400); font-size: .9rem;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-btn {
  position: relative;
  background: var(--gray-100); border: none; cursor: pointer;
  width: 38px; height: 38px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-700); font-size: .95rem;
  transition: background var(--transition);
}
.topbar-btn:hover { background: var(--gray-200); }
.topbar-btn .badge {
  position: absolute; top: 5px; right: 5px;
  background: var(--danger); color: #fff;
  width: 16px; height: 16px; border-radius: 50%;
  font-size: .6rem; display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}

/* Page content */
.page-content {
  padding: 28px;
  flex: 1;
}
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title {
  font-size: 1.4rem; font-weight: 700; color: var(--gray-900);
}
.page-subtitle {
  font-size: .85rem; color: var(--gray-500); margin-top: 2px;
}
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: .8rem; color: var(--gray-500); margin-bottom: 4px;
}
.breadcrumb a { color: var(--primary); }
.breadcrumb .sep { color: var(--gray-300); }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title {
  font-size: .95rem; font-weight: 700; color: var(--gray-900);
}
.card-body { padding: 24px; }

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  display: flex; align-items: flex-start; gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.stat-icon.blue   { background: #eff6ff; color: var(--primary); }
.stat-icon.green  { background: #ecfdf5; color: var(--accent);  }
.stat-icon.orange { background: #fffbeb; color: var(--warning); }
.stat-icon.red    { background: #fef2f2; color: var(--danger);  }
.stat-icon.purple { background: #f5f3ff; color: #7c3aed;        }
.stat-body { flex: 1; }
.stat-value {
  font-size: 1.6rem; font-weight: 800;
  color: var(--gray-900); line-height: 1.2;
}
.stat-label {
  font-size: .78rem; color: var(--gray-500);
  font-weight: 500; margin-top: 2px;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 8px;
  font-size: .85rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--accent); color: #fff; }
.btn-success:hover { background: #0b7a57; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #c21d1d; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-outline {
  background: transparent; color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-outline:hover { background: var(--gray-100); }
.btn-sm { padding: 6px 12px; font-size: .78rem; }
.btn-icon { padding: 8px; }

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse;
  font-size: .85rem;
}
thead tr {
  border-bottom: 2px solid var(--gray-100);
}
thead th {
  padding: 12px 16px; text-align: left;
  font-size: .75rem; font-weight: 700;
  color: var(--gray-500); text-transform: uppercase;
  letter-spacing: .5px; white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
}
tbody tr:hover { background: var(--gray-50); }
tbody td {
  padding: 12px 16px;
  color: var(--gray-800);
  vertical-align: middle;
}
tbody tr:last-child { border-bottom: none; }

/* ── Badges / Pills ────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: .72rem; font-weight: 600;
}
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-gray   { background: var(--gray-200); color: var(--gray-700); }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: .82rem; font-weight: 600;
  color: var(--gray-700); margin-bottom: 6px;
}
.form-control {
  width: 100%; padding: 9px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 8px; font-size: .88rem;
  color: var(--gray-900); background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}
.form-control.is-invalid { border-color: var(--danger); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-text { font-size: .78rem; color: var(--gray-500); margin-top: 4px; }

/* ── Modals ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 95%; max-width: 560px; max-height: 90vh;
  display: flex; flex-direction: column;
  transform: scale(.96) translateY(10px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal-lg { max-width: 800px; }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--gray-500); font-size: 1.2rem;
  width: 32px; height: 32px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-900); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── Alerts / Toasts ───────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: 8px;
  font-size: .85rem; margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert-success { background: #d1fae5; color: #065f46; border-left: 4px solid var(--accent); }
.alert-danger   { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--danger); }
.alert-warning  { background: #fef3c7; color: #92400e; border-left: 4px solid var(--warning); }
.alert-info     { background: #dbeafe; color: #1e40af; border-left: 4px solid var(--info); }

/* Toast */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--gray-900); color: #fff;
  padding: 13px 20px; border-radius: 10px;
  font-size: .85rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  animation: slideUp .3s ease;
  min-width: 260px;
}
.toast.success { background: var(--accent); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: 4px;
  justify-content: flex-end; padding-top: 16px;
}
.page-btn {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .83rem; font-weight: 600; cursor: pointer;
  background: var(--white); border: 1px solid var(--gray-200);
  color: var(--gray-700); transition: all var(--transition);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: default; }

/* ── Search / filter bar ───────────────────────────────────── */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-bottom: 20px;
}
.filter-bar .form-control { max-width: 240px; }

/* ── Low stock indicator ───────────────────────────────────── */
.stock-low { color: var(--danger); font-weight: 700; }
.stock-ok  { color: var(--accent); }
.stock-bar {
  height: 6px; border-radius: 3px;
  background: var(--gray-200); width: 80px; display: inline-block;
  vertical-align: middle; overflow: hidden;
}
.stock-bar-fill {
  height: 100%; border-radius: 3px;
  background: var(--accent); transition: width .4s;
}
.stock-bar-fill.low { background: var(--danger); }
.stock-bar-fill.mid { background: var(--warning); }

/* ── Product image ─────────────────────────────────────────── */
.product-thumb {
  width: 40px; height: 40px; border-radius: 8px;
  object-fit: cover; background: var(--gray-100);
}
.product-thumb-placeholder {
  width: 40px; height: 40px; border-radius: 8px;
  background: var(--gray-100); display: flex;
  align-items: center; justify-content: center;
  color: var(--gray-400); font-size: 1.1rem;
}

/* ── Charts container ──────────────────────────────────────── */
.chart-wrap { position: relative; height: 260px; }

/* ── Login page ────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; background: var(--gray-100);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 420px;
  padding: 44px 40px;
}
.login-logo {
  text-align: center; margin-bottom: 32px;
}
.login-logo .icon {
  width: 56px; height: 56px;
  background: var(--primary); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: #fff;
  margin: 0 auto 12px;
}
.login-logo h1 {
  font-size: 1.3rem; font-weight: 800;
  color: var(--gray-900); letter-spacing: -.3px;
}
.login-logo p { font-size: .83rem; color: var(--gray-500); margin-top: 2px; }
.login-card .form-control { height: 46px; font-size: .9rem; }
.btn-login {
  width: 100%; height: 46px;
  justify-content: center; font-size: .95rem; letter-spacing: .5px;
}

/* ── Utility ───────────────────────────────────────────────── */
.text-muted  { color: var(--gray-500); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--accent); }
.text-primary{ color: var(--primary); }
.fw-bold     { font-weight: 700; }
.fw-medium   { font-weight: 500; }
.d-flex      { display: flex; }
.align-center{ align-items: center; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.mb-0        { margin-bottom: 0; }
.mb-3        { margin-bottom: 12px; }
.mb-4        { margin-bottom: 16px; }
.mt-auto     { margin-top: auto; }
.ms-auto     { margin-left: auto; }
.text-end    { text-align: right; }
.text-center { text-align: center; }
.w-100       { width: 100%; }
.hidden      { display: none !important; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .topbar-search { display: none; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── Table actions ─────────────────────────────────────────── */
.actions { display: flex; gap: 6px; }
.action-btn {
  width: 30px; height: 30px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer; font-size: .85rem;
  transition: all var(--transition);
}
.action-btn.edit   { background: #eff6ff; color: var(--primary); }
.action-btn.delete { background: #fef2f2; color: var(--danger); }
.action-btn.view   { background: #ecfdf5; color: var(--accent); }
.action-btn:hover  { opacity: .8; transform: scale(1.1); }

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1rem; color: var(--gray-600); margin-bottom: 4px; }
.empty-state p  { font-size: .85rem; }
