/* ==========================================================================
   MATRIX SHOP ADMIN CONSOLE - DESIGN SYSTEM
   Palette: Minimalist Dark Sepia & Botanical Sage Green
   ========================================================================== */

:root {
  /* Canvas & Backgrounds (Dark Sepia / Charcoal Warmth) */
  --bg-canvas: #131210;
  --bg-sidebar: #171513;
  --bg-topbar: rgba(23, 21, 19, 0.85);
  --bg-card: #1c1a17;
  --bg-card-hover: #221f1b;
  --bg-elevated: #24211d;
  --bg-input: #141311;
  --bg-overlay: rgba(10, 9, 8, 0.72);

  /* Borders (Warm Sepia Transparencies) */
  --border-subtle: rgba(220, 205, 180, 0.08);
  --border-medium: rgba(220, 205, 180, 0.15);
  --border-highlight: rgba(220, 205, 180, 0.28);
  --border-focus: #52b788;

  /* Typography */
  --font-sans: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'Roboto Mono', 'Cascadia Code', Consolas, ui-monospace, monospace;
  --font-icon: 'Material Symbols Rounded', sans-serif;

  /* Text Colors (Parchment & Sepia) */
  --text-primary: #f5f0e8;
  --text-secondary: #a8a296;
  --text-muted: #726d64;
  --text-inverse: #131210;

  /* Green Accent (Sage / Forest / Olive botanical) */
  --green-primary: #52b788;
  --green-hover: #40916c;
  --green-deep: #2d6a4f;
  --green-light: #74c69d;
  --green-tint: rgba(82, 183, 136, 0.12);
  --green-border: rgba(82, 183, 136, 0.28);
  --green-glow: rgba(82, 183, 136, 0.2);

  /* Sepia / Caramel Gold Accent */
  --sepia-primary: #d4a373;
  --sepia-hover: #c49262;
  --sepia-tint: rgba(212, 163, 115, 0.12);
  --sepia-border: rgba(212, 163, 115, 0.28);

  /* Red / Terracotta (Destructive / Alerts) */
  --red-primary: #e76f51;
  --red-hover: #d65d3f;
  --red-tint: rgba(231, 111, 81, 0.12);
  --red-border: rgba(231, 111, 81, 0.28);

  /* Blue / Slate Accent */
  --blue-primary: #6c9a8b;
  --blue-tint: rgba(108, 154, 139, 0.12);
  --blue-border: rgba(108, 154, 139, 0.28);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 9px;
  --radius-lg: 13px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.55);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  line-height: 1.5;
  color-scheme: dark;
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  overflow-x: hidden;
}

/* Material Symbols Rounded Icon */
.icon {
  font-family: var(--font-icon);
  font-weight: 400;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  vertical-align: middle;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}
.icon.filled {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

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

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-highlight);
}

/* ==========================================================================
   LAYOUT: SIDEBAR + CONTENT
   ========================================================================== */
.layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 250px;
  flex: none;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 50;
  transition: transform .2s ease;
}

.sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--green-deep), var(--green-hover));
  color: #f4efe6;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px var(--green-glow);
  flex: none;
}

.sidebar-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  line-height: 1.2;
}

.sidebar-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Sidebar DB info badge */
.sidebar-db-badge {
  margin-top: 14px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: rgba(255, 245, 230, 0.03);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  transition: background .15s, border-color .15s;
}
.sidebar-db-badge:hover {
  background: rgba(255, 245, 230, 0.06);
  border-color: var(--border-medium);
}
.sidebar-db-name {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--sepia-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Nav Menu */
.sidebar-nav {
  flex: 1;
  padding: 14px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 10px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 11px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all .15s ease;
  position: relative;
}

.nav-item:hover {
  background: rgba(255, 245, 230, 0.05);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--green-tint);
  color: var(--green-light);
  font-weight: 600;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--green-primary);
}

.nav-item .icon {
  font-size: 19px;
  color: var(--text-muted);
  transition: color .15s ease;
}

.nav-item:hover .icon {
  color: var(--text-primary);
}

.nav-item.active .icon {
  color: var(--green-primary);
  font-variation-settings: 'FILL' 1, 'wght' 500;
}

.nav-item-badge {
  margin-left: auto;
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 245, 230, 0.06);
  color: var(--text-secondary);
}
.nav-item.active .nav-item-badge {
  background: rgba(82, 183, 136, 0.2);
  color: var(--green-light);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-profile {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.admin-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: rgba(212, 163, 115, 0.15);
  border: 1px solid var(--sepia-border);
  color: var(--sepia-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.admin-info {
  min-width: 0;
}

.admin-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-role {
  font-size: 10px;
  color: var(--text-muted);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  height: 60px;
  background: var(--bg-topbar);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 40;
}

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

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}
.mobile-menu-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 245, 230, 0.06);
}

.topbar-headline {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Content Container */
.content-body {
  flex: 1;
  padding: 28px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all .15s ease;
  user-select: none;
}

.btn .icon {
  font-size: 17px;
}

/* Button Variants */
.btn-primary {
  background: var(--green-deep);
  color: #f7f3eb;
  border-color: rgba(82, 183, 136, 0.4);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.btn-primary:hover {
  background: var(--green-hover);
  border-color: var(--green-primary);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--green-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-medium);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-highlight);
  color: #ffffff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: rgba(255, 245, 230, 0.05);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--red-tint);
  color: var(--red-primary);
  border-color: var(--red-border);
}
.btn-danger:hover {
  background: var(--red-primary);
  color: #ffffff;
  border-color: var(--red-primary);
}

.btn-sepia {
  background: var(--sepia-tint);
  color: var(--sepia-primary);
  border-color: var(--sepia-border);
}
.btn-sepia:hover {
  background: var(--sepia-primary);
  color: #1a1714;
}

.btn-sm {
  padding: 5px 9px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}
.btn-sm .icon {
  font-size: 15px;
}

.btn-icon {
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
}
.btn-icon:hover {
  background: rgba(255, 245, 230, 0.06);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.btn-icon.danger:hover {
  background: var(--red-tint);
  color: var(--red-primary);
  border-color: var(--red-border);
}

/* ==========================================================================
   FORM CONTROLS (INPUTS, SELECTS, TEXTAREAS)
   ========================================================================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.input,
.select,
.textarea {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-primary);
  background-color: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--green-primary);
  box-shadow: 0 0 0 3px var(--green-glow);
  background-color: #171614;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

.textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='%23a8a296'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  user-select: none;
}
.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--green-deep);
  cursor: pointer;
}

/* ==========================================================================
   CARDS & PANELS
   ========================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  transition: border-color .15s ease, background-color .15s ease;
}

.card:hover {
  border-color: var(--border-medium);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* KPI Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform .15s ease, border-color .15s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-medium);
}

.stat-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-card-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.stat-card-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--green-tint);
  color: var(--green-light);
}

.stat-card-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-family: var(--font-mono);
  line-height: 1;
}

.stat-card-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==========================================================================
   TABLES
   ========================================================================== */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.table th {
  padding: 11px 16px;
  background: rgba(14, 13, 11, 0.6);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

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

.table tbody tr {
  transition: background-color .12s ease;
}

.table tbody tr:hover {
  background-color: rgba(255, 245, 230, 0.025);
}

/* Table Empty State */
.table-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.table-empty .icon {
  font-size: 40px;
  display: block;
  margin-bottom: 10px;
  opacity: 0.6;
}

/* ==========================================================================
   BADGES & PILLS
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.badge-green {
  background: var(--green-tint);
  color: var(--green-light);
  border: 1px solid var(--green-border);
}

.badge-sepia {
  background: var(--sepia-tint);
  color: var(--sepia-primary);
  border: 1px solid var(--sepia-border);
}

.badge-red {
  background: var(--red-tint);
  color: var(--red-primary);
  border: 1px solid var(--red-border);
}

.badge-neutral {
  background: rgba(255, 245, 230, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn .18s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 580px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  animation: modalSlideUp .2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
  from { transform: translateY(12px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

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

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 9px;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: rgba(14, 13, 11, 0.4);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ==========================================================================
   TOAST / NOTIFICATIONS
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-medium);
  animation: toastSlide .25s ease-out;
}

@keyframes toastSlide {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-success {
  background: #19271e;
  color: var(--green-light);
  border-color: var(--green-border);
}

.toast-error {
  background: #2b1715;
  color: #ff9b85;
  border-color: var(--red-border);
}

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE / TABLET)
   ========================================================================== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .content-body {
    padding: 18px 16px 36px;
  }

  .topbar {
    padding: 0 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}
