/* ═══════════════════════════════════════════════════════════
   FARMACODOSIS 2.0 — DESIGN SYSTEM
   Colores: Azul #0A2463 / Naranja #FF6B2B
═══════════════════════════════════════════════════════════ */

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

:root {
  /* Palette principal */
  --blue-900: #040f2b;
  --blue-800: #0A2463;
  --blue-700: #1337A0;
  --blue-600: #1a4bc4;
  --blue-500: #2563eb;
  --blue-400: #3b82f6;
  --blue-200: #bfdbfe;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;

  --orange-600: #c2410c;
  --orange-500: #FF6B2B;
  --orange-400: #fb923c;
  --orange-300: #fdba74;
  --orange-100: #ffedd5;
  --orange-50:  #fff7ed;

  /* Neutros */
  --gray-950: #030712;
  --gray-900: #111827;
  --gray-800: #1f2937;
  --gray-700: #374151;
  --gray-600: #4b5563;
  --gray-400: #9ca3af;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50:  #f9fafb;
  --white:    #ffffff;

  /* Semánticos */
  --success:  #10b981;
  --warning:  #f59e0b;
  --danger:   #ef4444;
  --info:     var(--blue-500);

  /* Sombras */
  --shadow-sm:  0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.14);
  --shadow-xl:  0 16px 48px rgba(0,0,0,.18);
  --shadow-blue: 0 8px 32px rgba(10,36,99,.25);
  --shadow-orange: 0 8px 32px rgba(255,107,43,.30);

  /* Radios */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transiciones */
  --transition: all .25s cubic-bezier(.4,0,.2,1);
  --transition-fast: all .15s ease;
}

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

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: 'Inter', sans-serif;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ── Tipografía ── */
h1,h2,h3,h4,h5,h6 { font-family: 'Outfit', sans-serif; line-height: 1.2; font-weight: 700; }

/* ── Utilidades ── */
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 2rem; }
.text-center { text-align: center; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; } .gap-3 { gap: 1.5rem; } .gap-4 { gap: 2rem; }
.grid { display: grid; }
.mt-1{margin-top:.5rem} .mt-2{margin-top:1rem} .mt-3{margin-top:1.5rem} .mt-4{margin-top:2rem}
.mb-1{margin-bottom:.5rem} .mb-2{margin-bottom:1rem} .mb-3{margin-bottom:1.5rem}

/* ── Botones ── */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .65rem 1.5rem; border-radius: var(--radius-md);
  font-weight: 600; font-size: .9rem; transition: var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--orange-500); color: var(--white);
  box-shadow: var(--shadow-orange);
}
.btn-primary:hover { background: var(--orange-600); transform: translateY(-2px); box-shadow: 0 12px 36px rgba(255,107,43,.4); }

.btn-secondary {
  background: var(--blue-800); color: var(--white);
  box-shadow: var(--shadow-blue);
}
.btn-secondary:hover { background: var(--blue-700); transform: translateY(-2px); }

.btn-outline {
  border: 2px solid var(--blue-800); color: var(--blue-800); background: transparent;
}
.btn-outline:hover { background: var(--blue-800); color: var(--white); }

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }

.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #059669; }

.btn-sm { padding: .4rem 1rem; font-size: .8rem; }
.btn-lg { padding: .9rem 2.2rem; font-size: 1rem; }

/* ── Inputs ── */
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group label { font-weight: 600; font-size: .875rem; color: var(--gray-700); }
.form-control {
  padding: .7rem 1rem; border: 2px solid var(--gray-200);
  border-radius: var(--radius-md); font-family: inherit; font-size: .9rem;
  color: var(--gray-800); background: var(--white);
  transition: var(--transition);
  width: 100%;
}
.form-control:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100); }
.form-control::placeholder { color: var(--gray-400); }
select.form-control { cursor: pointer; }

/* ── Cards ── */
.card {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); overflow: hidden;
}
.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 2px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 1.05rem; color: var(--blue-800); }
.card-body { padding: 1.5rem; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; padding: .25rem .75rem;
  border-radius: var(--radius-full); font-size: .75rem; font-weight: 700;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: var(--blue-100); color: var(--blue-800); }
.badge-orange  { background: var(--orange-100); color: var(--orange-600); }
.badge-gray    { background: var(--gray-100); color: var(--gray-700); }

/* ── Alertas ── */
.alert {
  padding: 1rem 1.25rem; border-radius: var(--radius-md);
  font-size: .9rem; font-weight: 500; margin-bottom: 1rem;
  display: flex; align-items: center; gap: .6rem;
}
.alert-success { background: #d1fae5; color: #065f46; border-left: 4px solid var(--success); }
.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: var(--blue-100); color: var(--blue-800); border-left: 4px solid var(--blue-500); }

/* ── Tablas ── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-md); }
.table {
  width: 100%; border-collapse: collapse; font-size: .875rem;
}
.table th {
  background: var(--blue-800); color: var(--white);
  padding: .9rem 1rem; text-align: left; font-weight: 600;
  white-space: nowrap;
}
.table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.table th:last-child { border-radius: 0 var(--radius-sm) 0 0; }
.table td { padding: .85rem 1rem; border-bottom: 1px solid var(--gray-100); }
.table tr:hover td { background: var(--blue-50); }
.table tr:last-child td { border-bottom: none; }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(4,15,43,.7); backdrop-filter: blur(4px);
  z-index: 1000; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--white); border-radius: var(--radius-xl);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalIn .3s cubic-bezier(.4,0,.2,1);
}
.modal-header {
  padding: 1.5rem; border-bottom: 2px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { color: var(--blue-800); }
.modal-close {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--gray-100); color: var(--gray-600);
  font-size: 1.2rem; transition: var(--transition);
}
.modal-close:hover { background: var(--danger); color: var(--white); }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem; border-top: 2px solid var(--gray-100);
  display: flex; gap: 1rem; justify-content: flex-end;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-20px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Sidebar ── */
.sidebar {
  width: 260px; min-height: 100vh; background: var(--blue-900);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; z-index: 100;
  box-shadow: 4px 0 20px rgba(0,0,0,.3);
}
.sidebar-logo {
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.sidebar-logo img {
  width: 250px;
  height: auto;
  max-height: 120px;
  object-fit: contain;
  transform: scale(1.5);
  transform-origin: center;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.sidebar-nav { flex: 1; padding: 0.5rem 1rem; display: flex; flex-direction: column; gap: .25rem; }
.nav-section-title {
  color: rgba(255,255,255,.35); font-size: .7rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  padding: 0.5rem .75rem .25rem;
}
.nav-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem; border-radius: var(--radius-md);
  color: rgba(255,255,255,.65); font-size: .9rem; font-weight: 500;
  transition: var(--transition);
}
.nav-link:hover { background: rgba(255,255,255,.08); color: var(--white); }
.nav-link.active {
  background: linear-gradient(135deg, var(--orange-500), var(--orange-600));
  color: var(--white); box-shadow: var(--shadow-orange);
}
.nav-link .icon { 
  display: flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; flex-shrink: 0;
}
.nav-link .icon svg { width: 100%; height: 100%; fill: currentColor; }

/* Dropdown Sidebar */
.nav-dropdown {
  display: flex; flex-direction: column; gap: 0.15rem;
  overflow: hidden; transition: max-height 0.3s ease;
  padding-left: 1rem;
}
.nav-dropdown.closed { max-height: 0; }
.nav-dropdown .nav-link { font-size: 0.85rem; padding: 0.6rem 1rem; }
.nav-dropdown-toggle { cursor: pointer; justify-content: space-between; }
.nav-dropdown-toggle .arrow { font-size: 0.7rem; transition: transform 0.3s; }
.nav-dropdown-toggle.active .arrow { transform: rotate(90deg); }

.sidebar-footer {
  padding: 1rem; border-top: 1px solid rgba(255,255,255,.08);
}
.user-card {
  background: rgba(255,255,255,.06); border-radius: var(--radius-md);
  padding: .9rem 1rem; display: flex; align-items: center; gap: .75rem;
}
.user-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--orange-500), var(--blue-600));
  display: flex; align-items: center; justify-content: center;
  color: var(--white); font-weight: 700; font-size: .9rem; flex-shrink: 0;
}
.user-info { flex: 1; overflow: hidden; }
.user-info .name {
  color: var(--white); font-size: .85rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-info .role { color: var(--orange-400); font-size: .72rem; font-weight: 500; }
.logout-btn {
  color: rgba(255,255,255,.5); font-size: 1rem; transition: var(--transition);
  display: flex; padding: .4rem;
}
.logout-btn:hover { color: var(--danger); }

/* ── Main layout con sidebar ── */
.app-layout { display: flex; }
.main-content {
  margin-left: 260px; flex: 1; min-height: 100vh;
  background: var(--gray-50);
  min-width: 0;
  width: calc(100% - 260px);
}
.topbar {
  height: 70px; background: var(--white);
  border-bottom: 2px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem; position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-title { font-family: 'Outfit', sans-serif; font-size: 1.2rem; font-weight: 700; color: var(--blue-800); }
.page-content { padding: 2rem; }

/* ── Stat cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.stat-card {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 1.5rem; box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: 1.25rem;
  transition: var(--transition); border-left: 4px solid transparent;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card.blue { border-left-color: var(--blue-600); }
.stat-card.orange { border-left-color: var(--orange-500); }
.stat-card.green { border-left-color: var(--success); }
.stat-card.red { border-left-color: var(--danger); }

.stat-icon {
  width: 52px; height: 52px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.stat-card.blue .stat-icon { background: var(--blue-100); color: var(--blue-700); }
.stat-card.orange .stat-icon { background: var(--orange-100); color: var(--orange-500); }
.stat-card.green .stat-icon { background: #d1fae5; color: #065f46; }
.stat-card.red .stat-icon { background: #fee2e2; color: #991b1b; }

.stat-info .value { font-size: 2rem; font-weight: 800; color: var(--gray-900); line-height: 1; }
.stat-info .label { font-size: .8rem; color: var(--gray-500); font-weight: 500; margin-top: .2rem; }

/* ── Producto card ── */
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; }
.product-card {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); overflow: hidden; transition: var(--transition);
  display: flex; flex-direction: column;
}
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.product-card-img {
  height: 140px; background: linear-gradient(135deg, var(--blue-800), var(--blue-600));
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem;
}
.product-card-body { padding: 1.25rem; flex: 1; display: flex; flex-direction: column; gap: .5rem; }
.product-card-title { font-weight: 700; color: var(--gray-900); font-size: .95rem; }
.product-card-cat { font-size: .75rem; color: var(--blue-600); font-weight: 600; text-transform: uppercase; }
.product-card-lab { font-size: .8rem; color: var(--gray-500); }
.product-card-price {
  font-size: 1.5rem; font-weight: 800; color: var(--orange-500);
  margin-top: auto;
}
.product-card-price span { font-size: .75rem; color: var(--gray-500); font-weight: 400; }
.product-card-footer {
  padding: 1rem 1.25rem; border-top: 1px solid var(--gray-100);
  display: flex; gap: .5rem;
}

/* ── Empty state ── */
.empty-state {
  text-align: center; padding: 4rem 2rem; color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 4rem; margin-bottom: 1rem; opacity: .5; }
.empty-state p { font-size: 1rem; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--blue-800); border-radius: 3px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: var(--transition); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .container { padding: 0 1rem; }
  .page-content { padding: 1rem; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* Toast Notifications */
.toast-container {
  position: fixed; top: 2rem; right: 2rem;
  z-index: 9999; display: flex; flex-direction: column; gap: 1rem;
  pointer-events: none;
}
.toast {
  background: white; padding: 1rem 1.5rem; border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  display: flex; align-items: center; gap: 0.75rem;
  min-width: 300px; transform: translateX(120%);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border-left: 4px solid var(--blue-600);
  pointer-events: auto;
}
.toast.active { transform: translateX(0); }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast-icon { font-size: 1.2rem; }
.toast-content { flex: 1; }
.toast-title { font-weight: 700; font-size: 0.95rem; color: var(--blue-900); display: block; }
.toast-msg { font-size: 0.85rem; color: var(--gray-500); }
