/* =========================================================
   Panel de administración — VINILIKO
   ========================================================= */

:root {
  --admin-bg: #f5f4f1;
  --admin-panel: #ffffff;
  --admin-border: #e4e1da;
  --admin-text: #2b2822;
  --admin-muted: #79766e;
  --admin-accent: #b08968;
  --admin-accent-dark: #8c6a4e;
  --admin-blue: #2a78d6;
  --admin-blue-soft: #eaf1fb;
  --admin-green: #2f9e5b;
  --admin-green-soft: #e8f7ee;
  --admin-amber: #b8860b;
  --admin-amber-soft: #fbf3e1;
  --admin-red: #c94b3f;
  --admin-red-soft: #fbeae8;
  --admin-radius: 10px;
  font-family: "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--admin-bg);
  color: var(--admin-text);
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
}

a { color: inherit; }

/* ---------- Login ---------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--admin-panel);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 12px 32px rgba(30, 27, 20, 0.06);
}
.login-logo {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.login-sub {
  color: var(--admin-muted);
  font-size: 13px;
  margin-bottom: 28px;
}
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--admin-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--admin-border);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--admin-text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--admin-accent);
  outline-offset: 1px;
}
.form-error {
  background: var(--admin-red-soft);
  color: var(--admin-red);
  border-radius: 7px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: 7px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}
.btn-primary { background: var(--admin-text); color: #fff; width: 100%; }
.btn-primary:hover { background: #000; }
.btn-accent { background: var(--admin-accent); color: #fff; }
.btn-accent:hover { background: var(--admin-accent-dark); }
.btn-ghost { background: transparent; color: var(--admin-text); border: 1px solid var(--admin-border); }
.btn-ghost:hover { background: var(--admin-bg); }
.btn-danger { background: transparent; color: var(--admin-red); border: 1px solid #f0c9c4; }
.btn-danger:hover { background: var(--admin-red-soft); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ---------- Shell / layout ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #211f1b;
  color: #efece5;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
}
.admin-sidebar .logo {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
  color: #fff;
}
.admin-sidebar .sub {
  font-size: 11px;
  color: #a39d8f;
  margin-bottom: 28px;
}
.admin-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.admin-nav a {
  padding: 10px 12px;
  border-radius: 7px;
  text-decoration: none;
  color: #cfcabf;
  font-size: 13.5px;
  font-weight: 500;
}
.admin-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.admin-nav a.active { background: var(--admin-accent); color: #fff; }
.admin-sidebar .sidebar-foot {
  font-size: 12px;
  color: #a39d8f;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 14px;
  margin-top: 14px;
}
.admin-sidebar .sidebar-foot strong { color: #efece5; display:block; margin-bottom: 6px; }
.admin-sidebar .logout-link { color: #e3aea3; cursor: pointer; }

.admin-main { flex: 1; min-width: 0; }
.admin-topbar {
  background: var(--admin-panel);
  border-bottom: 1px solid var(--admin-border);
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.admin-topbar h1 { font-size: 19px; margin: 0; font-weight: 600; }
.admin-topbar p { margin: 2px 0 0; font-size: 12.5px; color: var(--admin-muted); }
.admin-content { padding: 28px 32px; max-width: 1180px; }

/* ---------- Stat tiles ---------- */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.stat-tile {
  background: var(--admin-panel);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 18px 20px;
}
.stat-tile .label {
  font-size: 12px;
  color: var(--admin-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.stat-tile .value { font-size: 26px; font-weight: 700; }
.stat-tile .value small { font-size: 13px; font-weight: 500; color: var(--admin-muted); }

/* ---------- Panel / card ---------- */
.panel {
  background: var(--admin-panel);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 22px 24px;
  margin-bottom: 22px;
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.panel-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.panel-head span { font-size: 12px; color: var(--admin-muted); }

/* ---------- Bar chart (revenue by day) ---------- */
.chart-wrap { position: relative; }
.chart-svg { width: 100%; height: 220px; display: block; overflow: visible; }
.chart-gridline { stroke: #eceae4; stroke-width: 1; }
.chart-bar { fill: var(--admin-blue); rx: 4; cursor: pointer; }
.chart-bar:hover { fill: #1f5fb0; }
.chart-axis-label { fill: var(--admin-muted); font-size: 10.5px; font-family: inherit; }
.chart-tooltip {
  position: absolute;
  background: #211f1b;
  color: #fff;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  pointer-events: none;
  transform: translate(-50%, -100%);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 5;
}
.chart-tooltip.visible { opacity: 1; }

/* ---------- Top products list ---------- */
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--admin-border);
  font-size: 13.5px;
}
.rank-list li:last-child { border-bottom: none; }
.rank-list .rank-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--admin-blue-soft);
  color: var(--admin-blue);
  font-size: 11.5px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rank-list .rank-name { flex: 1; }
.rank-list .rank-qty { color: var(--admin-muted); font-size: 12.5px; }

/* ---------- Tables ---------- */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--admin-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--admin-border);
}
table.data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--admin-border);
  vertical-align: middle;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table img.thumb {
  width: 40px; height: 48px; object-fit: cover; border-radius: 5px; background: #eee;
}
.table-actions { display: flex; gap: 6px; }

/* ---------- Status badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-nuevo { background: var(--admin-blue-soft); color: var(--admin-blue); }
.badge-en_proceso { background: var(--admin-amber-soft); color: var(--admin-amber); }
.badge-enviado { background: var(--admin-amber-soft); color: var(--admin-amber); }
.badge-entregado { background: var(--admin-green-soft); color: var(--admin-green); }
.badge-cancelado { background: var(--admin-red-soft); color: var(--admin-red); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 18, 14, 0.45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal-card {
  background: #fff;
  border-radius: var(--admin-radius);
  padding: 28px;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}
.modal-card h2 { margin: 0 0 20px; font-size: 17px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Image upload ---------- */
.image-upload-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.image-upload-row img {
  width: 64px; height: 76px; object-fit: cover; border-radius: 6px; border: 1px solid var(--admin-border);
}
.upload-btn {
  width: 64px; height: 76px;
  border: 1px dashed var(--admin-border);
  border-radius: 6px;
  background: var(--admin-bg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 22px;
  color: var(--admin-muted);
}

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--admin-muted);
  font-size: 13.5px;
}

.order-detail-row { background: var(--admin-bg); }
.order-detail-row td { padding: 16px 18px; }
.order-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; font-size: 13px; }
.order-detail-grid h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--admin-muted); }
.order-items-list { list-style: none; margin: 0; padding: 0; }
.order-items-list li { padding: 4px 0; border-bottom: 1px dashed var(--admin-border); }
.order-items-list li:last-child { border-bottom: none; }

@media (max-width: 880px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; flex-direction: row; align-items: center; padding: 14px 18px; }
  .admin-sidebar .logo, .admin-sidebar .sub { display: none; }
  .admin-nav { flex-direction: row; }
  .admin-sidebar .sidebar-foot { display: none; }
  .admin-content { padding: 20px 16px; }
  .field-row { grid-template-columns: 1fr; }
  .order-detail-grid { grid-template-columns: 1fr; }
}
