/* ==========================================================================
   ADMIN BACKOFFICE - TIENDA LA LUZ (Modern Enterprise SaaS Theme)
   ========================================================================== */

:root {
  --admin-bg: #f8fafc;
  --admin-card-bg: #ffffff;
  --admin-sidebar-bg: #0f172a;
  --admin-sidebar-hover: #1e293b;
  --admin-sidebar-active: #fa6400;
  --admin-text-main: #0f172a;
  --admin-text-muted: #64748b;
  --admin-border: #e2e8f0;
  --admin-primary: #fa6400;
  --admin-primary-hover: #e05500;
  --admin-success: #10b981;
  --admin-warning: #f59e0b;
  --admin-danger: #ef4444;
  --admin-info: #0284c7;
  --admin-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --admin-radius: 12px;
  --admin-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
}

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

body {
  font-family: var(--admin-font);
  background-color: var(--admin-bg);
  color: var(--admin-text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}

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

/* Sidebar */
.admin-sidebar {
  width: 270px;
  background-color: var(--admin-sidebar-bg);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo {
  height: 42px;
  width: auto;
  object-fit: contain;
  background: #ffffff;
  padding: 4px 8px;
  border-radius: 8px;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #ffffff;
}

.brand-badge {
  font-size: 10px;
  color: #fa6400;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.sidebar-nav {
  padding: 20px 14px;
  flex: 1;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #64748b;
  font-weight: 700;
  margin: 16px 0 8px 12px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: 8px;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  margin-bottom: 4px;
}

.sidebar-link:hover {
  background-color: var(--admin-sidebar-hover);
  color: #ffffff;
  transform: translateX(2px);
}

.sidebar-link.active {
  background-color: var(--admin-primary);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(250, 100, 0, 0.35);
}

.sidebar-link svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
}

.sidebar-badge {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.15);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 12px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 18px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-mini {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.user-role {
  font-size: 11px;
  color: #94a3b8;
}

.logout-icon-btn {
  color: #94a3b8;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s;
}

.logout-icon-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* Main Content Wrapper */
.admin-main {
  margin-left: 270px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Topbar */
.admin-topbar {
  height: 70px;
  background: #ffffff;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--admin-text-main);
  letter-spacing: -0.3px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-store-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #f1f5f9;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  transition: all 0.2s;
}

.btn-store-link:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Page Container */
.admin-container {
  padding: 32px;
  flex: 1;
}

/* ==========================================================================
   METRIC / STATS CARDS
   ========================================================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--admin-card-bg);
  border-radius: var(--admin-radius);
  padding: 22px;
  box-shadow: var(--admin-shadow);
  border: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -4px rgba(15, 23, 42, 0.1);
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--admin-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--admin-text-main);
  line-height: 1.1;
}

.stat-subtext {
  font-size: 12px;
  color: #10b981;
  font-weight: 600;
  margin-top: 6px;
}

.stat-icon-wrapper {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon-wrapper.orange { background: #fff4ec; color: #fa6400; }
.stat-icon-wrapper.blue { background: #eff6ff; color: #2563eb; }
.stat-icon-wrapper.green { background: #ecfdf5; color: #10b981; }
.stat-icon-wrapper.purple { background: #f5f3ff; color: #7c3aed; }

/* ==========================================================================
   CARDS & TABLES
   ========================================================================== */
.admin-card {
  background: var(--admin-card-bg);
  border-radius: var(--admin-radius);
  box-shadow: var(--admin-shadow);
  border: 1px solid var(--admin-border);
  margin-bottom: 28px;
  overflow: hidden;
}

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

.card-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--admin-text-main);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Filter / Search bars */
.search-box-admin {
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  padding: 6px 12px;
  gap: 8px;
  width: 260px;
  transition: all 0.2s;
}

.search-box-admin:focus-within {
  background: #ffffff;
  border-color: var(--admin-primary);
  box-shadow: 0 0 0 3px rgba(250, 100, 0, 0.1);
}

.search-box-admin input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
}

.select-admin {
  background: #f8fafc;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  padding: 7px 12px;
  color: var(--admin-text-main);
  font-weight: 500;
  outline: none;
}

.select-admin:focus {
  border-color: var(--admin-primary);
}

/* Buttons */
.btn-primary-admin {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--admin-primary);
  color: #ffffff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 700;
  transition: all 0.2s;
}

.btn-primary-admin:hover {
  background: var(--admin-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(250, 100, 0, 0.25);
}

.btn-secondary-admin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  color: #334155;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-secondary-admin:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Modern Data Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.admin-table th {
  background: #f8fafc;
  padding: 13px 20px;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--admin-border);
}

.admin-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--admin-border);
  font-size: 13.5px;
  color: #334155;
  vertical-align: middle;
}

.admin-table tbody tr {
  transition: background-color 0.15s;
}

.admin-table tbody tr:hover {
  background-color: #f8fafc;
}

/* Badges */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 700;
}

.badge-status.paid, .badge-status.instock, .badge-status.active {
  background: #ecfdf5;
  color: #059669;
}

.badge-status.pending {
  background: #fffbeb;
  color: #d97706;
}

.badge-status.failed, .badge-status.outofstock {
  background: #fef2f2;
  color: #dc2626;
}

.badge-google {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 700;
  color: #334155;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.google-icon-svg {
  width: 14px;
  height: 14px;
}

/* Table Item Visuals */
.table-product-cell {
  display: flex;
  align-items: center;
  gap: 14px;
}

.table-product-img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.table-product-info {
  display: flex;
  flex-direction: column;
}

.table-product-title {
  font-weight: 700;
  color: #0f172a;
  max-width: 320px;
  line-height: 1.3;
}

.table-product-sku {
  font-size: 11.5px;
  color: #64748b;
}

/* Table Action Buttons */
.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-action-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  background: #f1f5f9;
  transition: all 0.2s;
}

.btn-action-icon:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-action-icon.edit:hover {
  background: #eff6ff;
  color: #2563eb;
}

.btn-action-icon.delete:hover {
  background: #fef2f2;
  color: #dc2626;
}

/* ==========================================================================
   MODAL WINDOWS
   ========================================================================== */
.admin-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.admin-modal-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

.admin-modal {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s ease;
  overflow: hidden;
}

.admin-modal-overlay.is-active .admin-modal {
  transform: translateY(0) scale(1);
}

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

.modal-header-admin h2 {
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
}

.modal-close-btn {
  font-size: 20px;
  color: #64748b;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.modal-close-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

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

.modal-footer-admin {
  padding: 16px 24px;
  border-top: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: #f8fafc;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.form-group-full {
  grid-column: span 2;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  font-size: 14px;
  color: #0f172a;
  background: #ffffff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  border-color: var(--admin-primary);
  box-shadow: 0 0 0 3px rgba(250, 100, 0, 0.12);
}

textarea.form-control {
  resize: vertical;
  min-height: 85px;
}

/* Toast */
.admin-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #ffffff;
  padding: 14px 22px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideToastIn 0.3s ease;
}

@keyframes slideToastIn {
  from { transform: translateY(50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 992px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }
  .admin-sidebar.mobile-open {
    transform: translateX(0);
  }
  .admin-main {
    margin-left: 0;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-group-full {
    grid-column: span 1;
  }
}
