/* ═══════════════════════════════════════════════════════════
   OAR Admin Panel — Styles
   Brand: bg #080D09 | sidebar #0D1F15 | green #2D6A4F | gold #C4A55A
════════════════════════════════════════════════════════════════ */

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

:root {
  --bg:       #080D09;
  --sidebar:  #0D1F15;
  --surface:  #111A14;
  --surface2: #172110;
  --border:   #1E3020;
  --green:    #2D6A4F;
  --green-h:  #3A855F;
  --gold:     #C4A55A;
  --gold-h:   #D4B56A;
  --danger:   #C0392B;
  --danger-h: #E74C3C;
  --text:     #E8E8E0;
  --text-muted: #8A9B8C;
  --radius:   8px;
  --sidebar-w: 220px;
  --transition: 0.2s ease;
}

html, body { height: 100%; }
body {
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--green); }

/* ════════════════════════════════════════════════════════════
   LOGIN
════════════════════════════════════════════════════════════════ */
#loginScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #0D2216 0%, var(--bg) 70%);
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-logo {
  width: 80px;
  height: auto;
  margin-bottom: 20px;
  filter: drop-shadow(0 4px 12px rgba(196,165,90,0.3));
}

.login-card h1 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.login-sub {
  color: var(--gold);
  font-size: 0.85rem;
  margin-bottom: 32px;
  letter-spacing: 0.05em;
}

.login-err {
  color: var(--danger-h);
  font-size: 0.82rem;
  margin-bottom: 12px;
  display: none;
}
.login-err.show { display: block; }

/* ════════════════════════════════════════════════════════════
   ADMIN APP LAYOUT
════════════════════════════════════════════════════════════════ */
#adminApp {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition), transform var(--transition);
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 48px;
  height: auto;
  filter: drop-shadow(0 2px 6px rgba(196,165,90,0.3));
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  display: none;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(45,106,79,0.15);
  color: var(--text);
}

.nav-item.active {
  background: rgba(45,106,79,0.25);
  color: var(--gold);
  border-left-color: var(--gold);
}

.nav-icon { font-size: 1rem; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.btn-logout {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--transition);
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger-h); }

/* ── Main ── */
#adminMain {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.mobile-header {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--sidebar);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.mobile-title { font-weight: 600; color: var(--gold); }

/* ── Tab panels ── */
.tab-panel { display: none; padding: 28px; flex: 1; }
.tab-panel.active { display: block; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.panel-header h2 { font-size: 1.4rem; color: var(--gold); font-weight: 600; }
.panel-sub { font-size: 0.85rem; color: var(--text-muted); }

/* ════════════════════════════════════════════════════════════
   DASHBOARD
════════════════════════════════════════════════════════════════ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--green); }

.stat-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--gold); line-height: 1; }

.dash-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.dash-chart-wrap, .dash-recent-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.dash-chart-wrap h3, .dash-recent-wrap h3 {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#chartWeek { width: 100%; display: block; }

.recent-list { display: flex; flex-direction: column; gap: 10px; }

.recent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: 6px;
  font-size: 0.85rem;
}
.recent-item-info { display: flex; flex-direction: column; gap: 2px; }
.recent-item-name { color: var(--text); font-weight: 500; }
.recent-item-date { color: var(--text-muted); font-size: 0.78rem; }
.recent-item-total { color: var(--gold); font-weight: 600; }

/* ════════════════════════════════════════════════════════════
   TOOLBAR / SEARCH
════════════════════════════════════════════════════════════════ */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.toolbar-search {
  flex: 1;
  min-width: 200px;
}
.toolbar-select { min-width: 160px; }

/* ════════════════════════════════════════════════════════════
   CATALOG GRID
════════════════════════════════════════════════════════════════ */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.admin-product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
  position: relative;
}
.admin-product-card:hover { border-color: var(--green); transform: translateY(-2px); }

.admin-prod-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--surface2);
  display: block;
}
.admin-prod-no-img {
  width: 100%;
  aspect-ratio: 1;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.admin-prod-info { padding: 12px; }
.admin-prod-code { font-size: 0.72rem; color: var(--gold); letter-spacing: 0.06em; margin-bottom: 2px; }
.admin-prod-name { font-size: 0.9rem; font-weight: 600; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-prod-price { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 10px; }
.admin-prod-price strong { color: var(--text); }

.admin-prod-status {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.status-activo   { background: rgba(45,106,79,0.8); color: #90EEB0; }
.status-inactivo { background: rgba(100,100,100,0.8); color: #ccc; }
.status-agotado  { background: rgba(180,80,30,0.8); color: #FFB07A; }

.admin-prod-actions { display: flex; gap: 6px; }
.admin-prod-actions button { flex: 1; padding: 7px 4px; font-size: 0.78rem; border-radius: 5px; }

/* ════════════════════════════════════════════════════════════
   ORDERS / RECEIPTS LIST
════════════════════════════════════════════════════════════════ */
.orders-list { display: flex; flex-direction: column; gap: 12px; }

.order-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.order-row:hover { border-color: var(--green); }

.order-num { font-size: 0.8rem; color: var(--gold); min-width: 60px; font-weight: 600; }
.order-client { flex: 1; min-width: 140px; }
.order-client-name { font-weight: 500; }
.order-client-meta { font-size: 0.78rem; color: var(--text-muted); }
.order-total { font-weight: 700; color: var(--text); min-width: 80px; text-align: right; }
.order-date { font-size: 0.78rem; color: var(--text-muted); min-width: 90px; text-align: right; }
.order-status-badge {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-nuevo      { background: rgba(45,106,79,0.3); color: #90EEB0; }
.badge-confirmado { background: rgba(52,152,219,0.3); color: #7ECBF2; }
.badge-enviado    { background: rgba(155,89,182,0.3); color: #C9A7E8; }
.badge-entregado  { background: rgba(39,174,96,0.3);  color: #7DE2A8; }
.badge-cancelado  { background: rgba(192,57,43,0.3);  color: #F08070; }

.order-actions { display: flex; gap: 6px; }
.order-actions button { padding: 6px 12px; font-size: 0.78rem; border-radius: 5px; }

/* ════════════════════════════════════════════════════════════
   RECEIPT PRINT AREA
════════════════════════════════════════════════════════════════ */
.receipt-doc {
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--text);
}
.receipt-doc h2 { text-align: center; letter-spacing: 0.1em; margin-bottom: 8px; }
.receipt-sep { border-top: 1px dashed var(--border); margin: 12px 0; }
.receipt-item-row { display: flex; justify-content: space-between; }
.receipt-total-row { display: flex; justify-content: space-between; font-weight: 700; color: var(--gold); }

/* ════════════════════════════════════════════════════════════
   EXPORT SECTION
════════════════════════════════════════════════════════════════ */
.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.export-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.export-card h3 { color: var(--gold); font-size: 1rem; }
.export-card p { color: var(--text-muted); font-size: 0.85rem; }
.import-status { font-size: 0.83rem; padding: 8px 12px; border-radius: 6px; background: var(--surface2); }

/* ════════════════════════════════════════════════════════════
   SETTINGS
════════════════════════════════════════════════════════════════ */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.settings-card h3 { color: var(--gold); font-size: 1rem; margin-bottom: 20px; }
.pass-msg { font-size: 0.82rem; padding: 8px 12px; border-radius: 6px; }
.pass-msg.ok  { background: rgba(45,106,79,0.3); color: #90EEB0; }
.pass-msg.err { background: rgba(192,57,43,0.3); color: #F08070; }

/* ════════════════════════════════════════════════════════════
   FORMS & INPUTS
════════════════════════════════════════════════════════════════ */
.field-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field-wrap label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.field-check { flex-direction: row; align-items: center; gap: 8px; }
.field-check label { font-size: 0.85rem; text-transform: none; letter-spacing: 0; color: var(--text); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); }
textarea { resize: vertical; }
select option { background: var(--surface2); }

.fields-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

/* ════════════════════════════════════════════════════════════
   BUTTONS
════════════════════════════════════════════════════════════════ */
.btn-primary {
  padding: 10px 20px;
  background: var(--green);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.btn-primary:hover { background: var(--green-h); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-secondary:hover { border-color: var(--text-muted); }

.btn-danger {
  padding: 10px 20px;
  background: var(--danger);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-danger:hover { background: var(--danger-h); }

.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-block { width: 100%; display: block; }

.btn-file-label {
  display: inline-block;
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-file-label:hover { border-color: var(--green); color: var(--gold); }

/* ════════════════════════════════════════════════════════════
   MODALS
════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.is-open { opacity: 1; pointer-events: auto; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.2s;
}
.modal-overlay.is-open .modal-box { transform: translateY(0); }
.modal-lg { max-width: 820px; }
.modal-sm { max-width: 380px; }
.modal-receipt { max-width: 480px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 { font-size: 1rem; color: var(--gold); font-weight: 600; }
.modal-header-actions { display: flex; gap: 8px; align-items: center; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Image slots ── */
.img-slots {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.img-slot {
  width: 100px;
  height: 100px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition);
  background: var(--surface2);
  flex-shrink: 0;
}
.img-slot:hover { border-color: var(--green); }
.img-slot span { font-size: 1.8rem; color: var(--text-muted); pointer-events: none; }
.img-slot input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.img-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.img-slot .slot-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.7);
  border: none;
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.65rem;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.img-slot.has-img .slot-remove { display: flex; }
.img-slot.has-img span { display: none; }

.modal-fields { flex: 1; }

/* ════════════════════════════════════════════════════════════
   TOAST
════════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--green);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 999;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
  max-width: 320px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.toast-err { background: var(--danger); }

/* ════════════════════════════════════════════════════════════
   EMPTY STATE
════════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 0.9rem; }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    transform: translateX(-100%);
    width: var(--sidebar-w);
  }
  #sidebar.is-open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .mobile-header { display: flex; }
  #adminMain { padding-top: 0; }
  .tab-panel { padding: 20px 16px; }
  .dash-row { grid-template-columns: 1fr; }
  .catalog-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .order-row { flex-wrap: wrap; }
  .img-slot { width: 80px; height: 80px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .catalog-grid { grid-template-columns: 1fr 1fr; }
}

/* ════════════════════════════════════════════════════════════
   PRINT (receipt)
════════════════════════════════════════════════════════════════ */
@media print {
  #adminApp > * { display: none !important; }
  #receiptModal { display: block !important; position: static; background: none; padding: 0; }
  .modal-overlay { opacity: 1; pointer-events: auto; background: none; }
  .modal-box { box-shadow: none; border: none; max-height: none; }
  .modal-header-actions { display: none; }
  .modal-close { display: none; }
  .receipt-doc { color: #000; font-size: 12px; }
}
