/* ===== EMLECA ADMIN PANEL ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --azul:      #1A237E;
  --azul-dark: #131A5C;
  --azul-light:#3949AB;
  --verde:     #1F3D2B;
  --blanco:    #FFFFFF;
  --gris-50:   #F8F9FA;
  --gris-100:  #F1F3F5;
  --gris-200:  #E9ECEF;
  --gris-300:  #DEE2E6;
  --gris-500:  #ADB5BD;
  --gris-700:  #495057;
  --negro:     #0E0E12;
  --success:   #2E7D32;
  --danger:    #C62828;
  --warning:   #E65100;
  --font:      'Poppins', system-ui, sans-serif;
  --radius:    8px;
  --shadow:    0 2px 8px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.14);
}

body {
  font-family: var(--font);
  background: var(--gris-50);
  color: var(--negro);
  min-height: 100vh;
}

/* ---- LOGIN PAGE ---- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--azul-dark) 0%, var(--azul) 60%, var(--azul-light) 100%);
}

.login-card {
  background: var(--blanco);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-card__logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  margin-bottom: 2rem;
}

.login-card__logo img { height: 40px; width: auto; }

.login-card__logo span {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gris-500);
}

.login-card h1 {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--azul);
  margin-bottom: .25rem;
  text-align: center;
}

.login-card p {
  text-align: center;
  font-size: .875rem;
  color: var(--gris-700);
  margin-bottom: 1.75rem;
}

.field { margin-bottom: 1.25rem; }

.field label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--gris-700);
  margin-bottom: .375rem;
}

.field input {
  width: 100%;
  padding: .6875rem .875rem;
  border: 1.5px solid var(--gris-300);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .9375rem;
  color: var(--negro);
  transition: border-color .15s;
  outline: none;
}

.field input:focus { border-color: var(--azul); }

.btn-login {
  width: 100%;
  padding: .75rem;
  background: var(--azul);
  color: var(--blanco);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: .5rem;
  transition: background .15s;
}

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

.login-error {
  background: #FFEBEE;
  color: var(--danger);
  border-radius: var(--radius);
  padding: .625rem .875rem;
  font-size: .875rem;
  margin-bottom: 1rem;
  display: none;
}

.login-error.show { display: block; }

/* ---- ADMIN LAYOUT ---- */
.admin-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--azul-dark);
  color: var(--blanco);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__brand {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar__brand img { height: 32px; width: auto; filter: brightness(0) invert(1); }

.sidebar__label {
  display: block;
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.45);
  margin-top: .375rem;
}

.sidebar__nav { padding: 1rem 0; flex: 1; }

.sidebar__nav a {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .65rem 1.25rem;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  transition: all .15s;
  border-radius: 0;
}

.sidebar__nav a:hover,
.sidebar__nav a.active {
  background: rgba(255,255,255,.1);
  color: var(--blanco);
}

.sidebar__nav a i { width: 16px; text-align: center; }

.sidebar__footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.1);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  padding: .5rem .75rem;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius);
  color: rgba(255,255,255,.8);
  font-family: var(--font);
  font-size: .875rem;
  cursor: pointer;
  transition: all .15s;
}

.btn-logout:hover { background: rgba(255,255,255,.15); color: var(--blanco); }

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

.topbar {
  background: var(--blanco);
  border-bottom: 1px solid var(--gris-200);
  padding: 0 1.75rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__title { font-size: 1rem; font-weight: 700; color: var(--azul); }

.topbar__meta { font-size: .8125rem; color: var(--gris-500); }

.content { padding: 1.75rem; flex: 1; }

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--blanco);
  border-radius: var(--radius);
  padding: 1.125rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.stat-card__value {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--azul);
  line-height: 1;
}

.stat-card__label { font-size: .8125rem; color: var(--gris-500); }

/* Panel card */
.panel-card {
  background: var(--blanco);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gris-200);
  gap: 1rem;
  flex-wrap: wrap;
}

.panel-card__header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--negro);
}

.header-actions { display: flex; gap: .625rem; align-items: center; flex-wrap: wrap; }

/* Search */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box i {
  position: absolute;
  left: .625rem;
  color: var(--gris-500);
  font-size: .875rem;
  pointer-events: none;
}

.search-box input {
  padding: .45rem .75rem .45rem 2rem;
  border: 1.5px solid var(--gris-300);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .875rem;
  outline: none;
  width: 220px;
  transition: border-color .15s;
}

.search-box input:focus { border-color: var(--azul); }

/* Filter select */
.filter-select {
  padding: .45rem .75rem;
  border: 1.5px solid var(--gris-300);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .875rem;
  outline: none;
  background: var(--blanco);
  cursor: pointer;
  transition: border-color .15s;
}

.filter-select:focus { border-color: var(--azul); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .45rem .875rem;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn--success { background: var(--success); color: var(--blanco); }
.btn--success:hover { background: #1B5E20; }

.btn--danger { background: var(--danger); color: var(--blanco); }
.btn--danger:hover { background: #B71C1C; }

.btn--warning { background: var(--warning); color: var(--blanco); }
.btn--warning:hover { background: #BF360C; }

.btn--toggle-on  { background: #E8F5E9; color: #2E7D32; border: 1.5px solid #A5D6A7; }
.btn--toggle-on:hover  { background: #C8E6C9; }
.btn--toggle-off { background: #F3F3F3; color: #9E9E9E; border: 1.5px solid #DDDDDD; }
.btn--toggle-off:hover { background: #E0E0E0; }

/* ── Toggle Switch gooey ─────────────────────────────────────────────── */
.toggle-sw {
  position: relative;
  display: inline-block;
  cursor: pointer;
  height: 28px;
  width: 48px;
  flex-shrink: 0;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.toggle-sw__input {
  display: block;
  height: 100%;
  width: 100%;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 999px;
  background: #D2D6E9;
  outline: none;
  transition: background .5s;
  pointer-events: none;
  margin: 0;
}

.toggle-sw--on .toggle-sw__input  { background: #10B981; }
.toggle-sw--off .toggle-sw__input { background: #D2D6E9; }

.toggle-sw__svg {
  pointer-events: none;
  position: absolute;
  inset: 0;
  fill: white;
}

.toggle-sw__circle {
  transition: transform .5s cubic-bezier(.4,0,.2,1);
}

.btn--ghost {
  background: transparent;
  color: var(--gris-700);
  border: 1.5px solid var(--gris-300);
}
.btn--ghost:hover { border-color: var(--gris-500); color: var(--negro); }

.btn--sm { padding: .3rem .625rem; font-size: .8125rem; }

.btn--icon {
  width: 30px;
  height: 30px;
  padding: 0;
  justify-content: center;
  font-size: .875rem;
}

/* Product table */
.product-table { width: 100%; border-collapse: collapse; }

.product-table th {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gris-500);
  padding: .625rem 1.25rem;
  text-align: left;
  background: var(--gris-50);
  border-bottom: 1px solid var(--gris-200);
  white-space: nowrap;
}

.product-table td {
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--gris-100);
  font-size: .875rem;
  vertical-align: middle;
}

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

.product-table tr:hover td { background: var(--gris-50); }

.product-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--gris-200);
  background: var(--gris-100);
}

.product-name { font-weight: 600; color: var(--negro); }

.product-desc {
  color: var(--gris-700);
  font-size: .8125rem;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.badge--corporales { background: #E3F2FD; color: #1565C0; }
.badge--faciales   { background: #FCE4EC; color: #880E4F; }
.badge--laser      { background: #FFF3E0; color: #E65100; }
.badge--insumos    { background: #E8F5E9; color: #2E7D32; }

.tags-list { display: flex; gap: .25rem; flex-wrap: wrap; }
.tag-chip {
  background: var(--gris-100);
  border-radius: 999px;
  padding: .125rem .5rem;
  font-size: .7rem;
  color: var(--gris-700);
}

.actions-cell { display: flex; gap: .375rem; align-items: center; }

/* Botón de promoción */
.btn--promo-off { background: #F3F3F3; color: #9E9E9E; border: 1.5px solid #DDDDDD; }
.btn--promo-off:hover { background: #E0E0E0; color: var(--warning); }
.btn--promo-on { background: #FFF3E0; color: var(--warning); border: 1.5px solid #FFCC80; }
.btn--promo-on:hover { background: #FFE0B2; }

.row--inactive td { opacity: 0.45; }
.row--inactive .actions-cell { opacity: 1; }

.empty-state {
  text-align: center;
  padding: 3rem 1.25rem;
  color: var(--gris-500);
}

.empty-state i { font-size: 2.5rem; margin-bottom: .75rem; display: block; color: var(--gris-300); }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--blanco);
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform .2s;
}

.modal--sm { max-width: 420px; }

.modal-overlay.open .modal { transform: translateY(0); }

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.125rem 1.5rem;
  border-bottom: 1px solid var(--gris-200);
  position: sticky;
  top: 0;
  background: var(--blanco);
  z-index: 1;
}

.modal__header h3 { font-size: 1.0625rem; font-weight: 700; color: var(--azul); }

.btn-close {
  background: none;
  border: none;
  font-size: 1.125rem;
  color: var(--gris-500);
  cursor: pointer;
  padding: .25rem;
  line-height: 1;
  transition: color .15s;
}
.btn-close:hover { color: var(--negro); }

.modal__body { padding: 1.5rem; }

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: .625rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gris-200);
  position: sticky;
  bottom: 0;
  background: var(--blanco);
}

/* Form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid .span-2 { grid-column: span 2; }

.form-field { display: flex; flex-direction: column; gap: .375rem; }

.form-field label {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--gris-700);
}

.form-field input,
.form-field select,
.form-field textarea {
  padding: .5625rem .75rem;
  border: 1.5px solid var(--gris-300);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .9rem;
  color: var(--negro);
  outline: none;
  transition: border-color .15s;
  background: var(--blanco);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus { border-color: var(--azul); }

.form-field textarea { resize: vertical; min-height: 90px; }

.form-hint { font-size: .75rem; color: var(--gris-500); }

.form-error { font-size: .75rem; color: var(--danger); }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: .625rem;
  background: var(--negro);
  color: var(--blanco);
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  box-shadow: var(--shadow-lg);
  animation: slideIn .2s ease;
  min-width: 260px;
}

.toast--success { background: var(--success); }
.toast--danger  { background: var(--danger); }

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

/* Confirm dialog */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}

.confirm-overlay.open { opacity: 1; pointer-events: all; }

.confirm-dialog {
  background: var(--blanco);
  border-radius: 12px;
  padding: 1.75rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.confirm-dialog i { font-size: 2.5rem; color: var(--danger); margin-bottom: .75rem; display: block; }
.confirm-dialog h4 { font-size: 1.125rem; font-weight: 700; margin-bottom: .5rem; }
.confirm-dialog p  { font-size: .9rem; color: var(--gris-700); margin-bottom: 1.5rem; }
.confirm-dialog__actions { display: flex; gap: .625rem; justify-content: center; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--gris-200);
  font-size: .8125rem;
  color: var(--gris-500);
}

.page-btns { display: flex; gap: .375rem; }

.page-btn {
  width: 30px;
  height: 30px;
  border: 1.5px solid var(--gris-300);
  border-radius: 6px;
  background: var(--blanco);
  color: var(--gris-700);
  font-size: .8125rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}

.page-btn:hover { border-color: var(--azul); color: var(--azul); }
.page-btn.active { background: var(--azul); color: var(--blanco); border-color: var(--azul); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* Responsive */
@media (max-width: 768px) {
  .admin-layout { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: relative; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .product-table { font-size: .8125rem; }
  .search-box input { width: 160px; }
}
