/* ── ADMIN PANEL STYLES ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --burg:      #7a3045;
  --burg-dark: #5a1f32;
  --gold:      #c9a96e;
  --sidebar-w: 240px;
  --sidebar-bg:#1a1a1a;
  --content-bg:#f4f5f7;
  --white:     #ffffff;
  --text:      #2a2a2a;
  --text-mid:  #555;
  --text-light:#888;
  --border:    #e0e0e0;
  --danger:    #c0392b;
  --success:   #27ae60;
  --info:      #2980b9;
  --ff-sans:   'Lato', sans-serif;
  --ff-serif:  'Playfair Display', serif;
  --radius:    6px;
  --shadow:    0 2px 8px rgba(0,0,0,.10);
}

body { font-family: var(--ff-sans); background: var(--content-bg); color: var(--text); font-size: 14px; }
a { text-decoration: none; color: inherit; }
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: var(--ff-sans); }
input, select, textarea { font-family: var(--ff-sans); }

/* ── LOGIN ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a0d14 0%, #2a1520 60%, #1a1a1a 100%);
}
.login-box {
  background: #fff;
  width: 100%;
  max-width: 400px;
  padding: 48px 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo-title { font-family: var(--ff-serif); font-style: italic; font-size: 26px; color: var(--text); }
.login-logo-sub { font-size: 10px; letter-spacing: 3px; text-transform: uppercase; color: var(--gold); margin-top: 2px; }
.login-tag { text-align: center; font-size: 12px; color: var(--text-light); margin-bottom: 28px; letter-spacing: 1px; text-transform: uppercase; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 7px; color: var(--text-mid); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; color: var(--text); outline: none;
  transition: border-color .2s;
  background: #fff;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--burg);
  box-shadow: 0 0 0 3px rgba(122,48,69,.12);
}
.form-group textarea { resize: vertical; min-height: 90px; }

.btn-login {
  width: 100%; padding: 13px;
  background: var(--burg); color: #fff; border: none;
  font-size: 12px; font-weight: 700; letter-spacing: 2px;
  text-transform: uppercase; border-radius: var(--radius);
  transition: background .2s;
  margin-top: 8px;
}
.btn-login:hover { background: var(--burg-dark); }

.login-error {
  background: #fdf0ef; border: 1px solid #e8b4b0;
  color: var(--danger); font-size: 12px; padding: 10px 14px;
  border-radius: var(--radius); margin-bottom: 16px; display: none;
}
.login-error.show { display: block; }

/* ── ADMIN LAYOUT ── */
.admin-layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100%;
  z-index: 100;
}
.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid #2a2a2a;
}
.sidebar-logo { font-family: var(--ff-serif); font-style: italic; font-size: 20px; color: #fff; }
.sidebar-logo-sub { font-size: 9px; letter-spacing: 3px; color: var(--gold); text-transform: uppercase; margin-top: 2px; }
.sidebar-badge { font-size: 9px; background: var(--burg); color: #fff; padding: 2px 8px; border-radius: 10px; margin-top: 6px; display: inline-block; letter-spacing: 1px; }

.sidebar-nav { flex: 1; padding: 16px 0; }
.nav-section { font-size: 9px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: #444; padding: 14px 20px 6px; }
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px; color: #888; font-size: 13px;
  transition: all .2s; border-left: 3px solid transparent;
}
.sidebar-link .icon { font-size: 17px; width: 20px; text-align: center; }
.sidebar-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.sidebar-link.active { color: #fff; background: rgba(122,48,69,.25); border-left-color: var(--burg); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid #2a2a2a;
  display: flex; align-items: center; gap: 10px;
}
.admin-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--burg); display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.admin-name { color: #ccc; font-size: 12px; }
.admin-role { color: #555; font-size: 11px; }
.logout-btn {
  margin-left: auto; background: none; border: none;
  color: #444; font-size: 16px;
}
.logout-btn:hover { color: #fff; }

/* MAIN CONTENT */
.admin-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
}

/* TOPBAR */
.admin-topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; font-size: 12px; font-weight: 700;
  letter-spacing: .5px; border-radius: var(--radius);
  border: 1px solid transparent; transition: all .2s;
}
.btn-primary   { background: var(--burg);    color: #fff; }
.btn-primary:hover { background: var(--burg-dark); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--content-bg); }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-success   { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 11px; }

/* ── PAGE BODY ── */
.admin-page { padding: 28px; flex: 1; }

/* ── STAT CARDS ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
  display: flex; align-items: center; gap: 14px;
}
.stat-card.burgundy { border-left-color: var(--burg); }
.stat-card.gold     { border-left-color: var(--gold); }
.stat-card.success  { border-left-color: var(--success); }
.stat-card.danger   { border-left-color: var(--danger); }
.stat-icon { font-size: 28px; }
.stat-val  { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-lbl  { font-size: 11px; color: var(--text-light); margin-top: 3px; }

/* ── CARD / TABLE ── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h2 { font-size: 15px; font-weight: 700; }
.card-body { padding: 22px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-light);
  padding: 10px 14px; border-bottom: 2px solid var(--border);
  text-align: left; white-space: nowrap;
}
tbody td {
  padding: 13px 14px; border-bottom: 1px solid #f0f0f0;
  vertical-align: middle; font-size: 13px;
}
tbody tr:hover td { background: #fafafa; }
tbody tr:last-child td { border-bottom: none; }

.prod-thumb {
  width: 52px; height: 66px;
  object-fit: cover; border-radius: 3px;
  background: #eee;
}
.prod-thumb-placeholder {
  width: 52px; height: 66px;
  background: #f0e8df; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #ccc; flex-shrink: 0;
}

.badge-pill {
  display: inline-block; padding: 3px 9px;
  border-radius: 12px; font-size: 10px; font-weight: 700;
}
.badge-sale   { background: #fdecea; color: var(--danger); }
.badge-nuevo  { background: #eafaf1; color: var(--success); }
.badge-top    { background: #fdf8ee; color: #b7860b; }
.badge-none   { background: #f4f5f7; color: #999; }

.stock-badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 12px; font-size: 11px; font-weight: 700;
}
.stock-ok   { background: #eafaf1; color: var(--success); }
.stock-low  { background: #fef9e7; color: #b7860b; }
.stock-out  { background: #fdecea; color: var(--danger); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 500;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
  overflow-y: auto;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%; max-width: 720px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  transform: translateY(-20px);
  transition: transform .25s;
  margin: auto;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--text-light); line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ── FORM GRID ── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.form-full { grid-column: 1 / -1; }

/* ── IMAGE UPLOAD ── */
.img-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
}
.img-upload-area:hover { border-color: var(--burg); background: #fdf8f9; }
.img-upload-area input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.img-upload-icon { font-size: 36px; margin-bottom: 8px; }
.img-upload-text { font-size: 13px; color: var(--text-mid); }
.img-upload-hint { font-size: 11px; color: var(--text-light); margin-top: 4px; }

.drive-input-row {
  display: flex; gap: 8px; margin-top: 10px;
}
.drive-input-row input {
  flex: 1; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 12px; color: var(--text);
}
.drive-input-row input::placeholder { color: var(--text-light); }
.drive-input-row button {
  padding: 9px 16px; background: var(--burg); color: #fff;
  border: none; border-radius: var(--radius); font-size: 12px;
  font-weight: 700; cursor: pointer; white-space: nowrap;
}
.drive-input-row button:hover { opacity: 0.88; }

.img-preview-grid {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px;
}
.img-preview-item {
  position: relative; width: 80px; height: 100px;
}
.img-preview-item img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 3px;
  border: 1px solid var(--border);
}
.img-preview-remove {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; background: var(--danger);
  color: #fff; border: none; border-radius: 50%;
  font-size: 12px; display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* Tags input (sizes / colors) */
.tags-input { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); min-height: 42px; align-items: center; background: #fff; }
.tags-input:focus-within { border-color: var(--burg); box-shadow: 0 0 0 3px rgba(122,48,69,.12); }
.tag { background: #f0e8df; color: var(--burg); font-size: 12px; padding: 3px 8px; border-radius: 12px; display: flex; align-items: center; gap: 4px; }
.tag-remove { background: none; border: none; color: var(--burg); font-size: 14px; line-height: 1; padding: 0; }
.tags-input input { border: none; outline: none; font-size: 13px; min-width: 80px; flex: 1; background: transparent; }

/* ── SEARCH BAR ── */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--content-bg);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.search-bar input { border: none; background: transparent; outline: none; font-size: 13px; width: 200px; }

/* ── STOCK EDIT INLINE ── */
.stock-input {
  width: 70px; padding: 5px 8px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px; text-align: center;
  outline: none;
}
.stock-input:focus { border-color: var(--burg); }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 13px 20px; border-radius: var(--radius);
  font-size: 13px; color: #fff; z-index: 9999;
  transform: translateY(60px); opacity: 0;
  transition: all .3s; pointer-events: none;
  box-shadow: var(--shadow);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.info    { background: var(--burg); }

/* ── CONFIRM DIALOG ── */
.confirm-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 700; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.confirm-overlay.open { opacity: 1; pointer-events: all; }
.confirm-box {
  background: #fff; border-radius: var(--radius); padding: 28px;
  max-width: 380px; width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.25);
  text-align: center;
}
.confirm-icon { font-size: 36px; margin-bottom: 12px; }
.confirm-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.confirm-msg { font-size: 13px; color: var(--text-mid); margin-bottom: 22px; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-light); }
.empty-state .icon { font-size: 48px; margin-bottom: 14px; }
.empty-state p { font-size: 14px; }

/* ── SIDEBAR TOGGLE BUTTON (always hidden on desktop) ── */
.sidebar-toggle {
  display: none;
  background: none; border: none;
  font-size: 22px; color: var(--text);
  padding: 4px 8px; margin-right: 8px;
  line-height: 1;
}

/* ── SIDEBAR OVERLAY ── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }

/* ── COLOR SWATCHES ── */
.color-swatches { display: flex; flex-wrap: wrap; gap: 8px; min-height: 10px; }
.color-swatch {
  width: 34px; height: 34px;
  border-radius: 9px;
  border: 2.5px solid var(--border);
  position: relative; cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.color-swatch:hover { transform: scale(1.18); box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.color-swatch .swatch-x {
  position: absolute; top: -7px; right: -7px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 900;
  display: none; align-items: center; justify-content: center;
  border: 2px solid #fff; line-height: 1;
}
.color-swatch:hover .swatch-x { display: flex; }

/* ── COLOR PICKER OVERLAY ── */
.color-picker-overlay {
  position: fixed; inset: 0; z-index: 600;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); padding: 16px;
}
.color-picker-overlay.open { display: flex; }
.color-picker-box {
  background: #fff; border-radius: 16px;
  padding: 28px 24px; width: min(340px, 92vw);
  box-shadow: 0 24px 64px rgba(0,0,0,.35);
  text-align: center;
  animation: cpPop .3s ease both;
}
@keyframes cpPop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.color-picker-box h4 { font-family: var(--ff-serif); font-size: 18px; margin-bottom: 18px; color: var(--text); }

.color-wheel-wrap { position: relative; width: 230px; height: 230px; margin: 0 auto 16px; }
.color-wheel {
  width: 100%; height: 100%; border-radius: 50%;
  background: conic-gradient(
    hsl(0,100%,50%), hsl(30,100%,50%), hsl(60,100%,50%),
    hsl(90,100%,50%), hsl(120,100%,50%), hsl(150,100%,50%),
    hsl(180,100%,50%), hsl(210,100%,50%), hsl(240,100%,50%),
    hsl(270,100%,50%), hsl(300,100%,50%), hsl(330,100%,50%),
    hsl(360,100%,50%)
  );
  cursor: crosshair; touch-action: none;
  box-shadow: 0 4px 20px rgba(0,0,0,.15); position: relative;
}
.color-wheel::after {
  content: ""; position: absolute; inset: 28%; border-radius: 50%;
  background: #fff; box-shadow: inset 0 2px 10px rgba(0,0,0,.08);
}
.color-wheel-preview {
  position: absolute; inset: 32%; border-radius: 50%; z-index: 2;
  border: 4px solid #fff; box-shadow: 0 4px 16px rgba(0,0,0,.2);
  transition: background-color .08s; background: hsl(0,100%,50%);
}
.color-wheel-thumb {
  position: absolute; width: 26px; height: 26px; border-radius: 50%;
  border: 3.5px solid #fff; box-shadow: 0 2px 10px rgba(0,0,0,.35);
  z-index: 3; pointer-events: none; transform: translate(-50%,-50%);
  top: 14%; left: 50%;
}
.color-brightness-wrap { width: 230px; margin: 0 auto 18px; }
.color-brightness {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 16px; border-radius: 8px;
  outline: none; cursor: pointer; border: 2px solid var(--border);
  background: linear-gradient(to right, #000, hsl(0,100%,50%), #fff);
}
.color-brightness::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; border: 3px solid var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.3); cursor: pointer;
}
.color-brightness::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; border: 3px solid var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.3); cursor: pointer;
}
.color-picker-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.color-picker-actions .btn { font-size: 13px; padding: 11px 20px; }

@keyframes wheelPop { from { transform: scale(.85) rotate(-30deg); opacity: 0; } to { transform: scale(1) rotate(0deg); opacity: 1; } }
.color-picker-overlay.open .color-wheel-wrap { animation: wheelPop .4s cubic-bezier(.34,1.56,.64,1) both; }

/* ── COLOR DOTS IN TABLES ── */
.admin-color-dots { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 2px; }
.admin-color-dot { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); display: inline-block; }

@media (prefers-reduced-motion: reduce) {
  .color-picker-overlay.open .color-wheel-wrap { animation: none; }
}

/* ── MOBILE ── */
@media (max-width: 768px) {
  /* Mostrar botón hamburguesa */
  .sidebar-toggle { display: block; }

  /* Sidebar oculto por defecto */
  .sidebar {
    transform: translateX(-100%);
    transition: transform .28s ease;
  }
  .sidebar.sidebar--open {
    transform: translateX(0);
  }

  /* Content sin margen izquierdo */
  .admin-content {
    margin-left: 0;
  }

  /* Stats en 2 columnas */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Tabla con scroll horizontal */
  .table-wrap { overflow-x: auto; }

  /* Formulario en 1 columna */
  .form-row { flex-direction: column; }

  /* Reducir padding de páginas */
  .admin-page { padding: 16px; }
  .admin-topbar { padding: 0 16px; }
}
