:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --surface-hover: #f1efe9;
  --gold: #c9a45c;
  --gold-dark: #9f7932;
  --gold-light: #b88e3d;
  --blue: #2563eb;
  --danger: #dc2626;
  --success: #059669;
  --border: #e2dfd7;
  --text: #16181d;
  --muted: #5b6474;
  --input-bg: #ffffff;
  --shadow: 0 8px 24px rgba(22, 24, 29, 0.06);
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
}

body.dark-theme {
  --bg: #111318;
  --surface: #1b1f27;
  --surface-2: #222731;
  --surface-hover: #262b35;
  --gold-light: #e5c98c;
  --danger: #ef4444;
  --border: rgba(255, 255, 255, 0.1);
  --text: #f8fafc;
  --muted: #94a3b8;
  --input-bg: rgba(255, 255, 255, 0.05);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

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

html, body {
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* Login Page (Light Mode Default) */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top right, #ebe6db, var(--bg) 65%);
}

body.dark-theme.login-page {
  background: radial-gradient(circle at top right, #232834, #111318 65%);
}

.login-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 36px 28px;
  box-shadow: var(--shadow);
}

.login-brand {
  text-align: center;
  margin-bottom: 24px;
}

.brand-pill {
  display: inline-block;
  font-size: 10.5px;
  letter-spacing: 0.2em;
  font-weight: 700;
  color: var(--gold-dark);
  background: rgba(201, 164, 92, 0.12);
  border: 1px solid rgba(201, 164, 92, 0.4);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.login-brand h1 {
  font-family: var(--font-serif);
  font-size: 27px;
  margin-bottom: 6px;
}

.login-brand p {
  font-size: 13.5px;
  color: var(--muted);
}

.form-group {
  margin-bottom: 12px;
  min-width: 0;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  max-width: 100%;
  padding: 10px 13px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

select option {
  background: var(--surface);
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 164, 92, 0.2);
}

.toggle-pass {
  position: absolute;
  right: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
}

.login-error {
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.35);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  margin-bottom: 14px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  border-radius: 11px;
  padding: 10px 15px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.12s ease, background 0.18s ease, opacity 0.18s ease;
}

.btn:hover {
  opacity: 0.92;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold), #dfc07f);
  color: #16181d;
}

.btn-blue {
  background: var(--blue);
  color: #ffffff;
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-ghost {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-ghost.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

.btn-danger {
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.28);
  color: var(--danger);
}

.btn-sm {
  padding: 7px 11px;
  font-size: 12px;
  border-radius: 8px;
}

.full-width {
  width: 100%;
}

.back-link {
  display: block;
  text-align: center;
  margin-top: 18px;
  color: var(--muted);
  font-size: 12.5px;
  text-decoration: none;
}

.back-link:hover {
  color: var(--gold-dark);
}

/* Fullscreen Admin Layout with Collapsible Sidebar */
.admin-layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

.admin-sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  transition: width 0.24s ease, padding 0.24s ease, opacity 0.2s ease;
  overflow: hidden;
  position: sticky;
  top: 0;
  height: 100vh;
}

.admin-sidebar.collapsed {
  width: 0;
  padding: 20px 0;
  border-right: none;
  opacity: 0;
  pointer-events: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), #a67f36);
  color: #111;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 19px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.sidebar-brand-text {
  min-width: 0;
}

.sidebar-brand-text strong {
  display: block;
  font-size: 14px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand-text span {
  font-size: 11px;
  color: var(--muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.nav-item:hover {
  background: var(--surface-hover);
}

.nav-item.active {
  background: rgba(201, 164, 92, 0.16);
  border-color: rgba(201, 164, 92, 0.35);
  color: var(--gold-dark);
}

body.dark-theme .nav-item.active {
  color: var(--gold-light);
}

.nav-item.danger {
  color: var(--danger);
}

.sidebar-footer {
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Main Content Area (Fullscreen, Zero Empty Margins) */
.admin-main {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 18px 22px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.sidebar-toggle-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 18px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.admin-title-wrap {
  min-width: 0;
}

.admin-title-wrap h1 {
  font-family: var(--font-serif);
  font-size: 21px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.admin-title-wrap p {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--gold-dark);
}

body.dark-theme .stat-value {
  color: var(--gold-light);
}

/* Toolbar: Search, Filters, Reset, View Toggle, Excel */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.toolbar-filters input {
  flex: 1 1 210px;
  min-width: 160px;
}

.toolbar-filters select {
  flex: 0 1 190px;
  min-width: 140px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.view-switch {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.view-switch button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 7px;
  cursor: pointer;
}

.view-switch button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Table Card */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

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

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}

td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}

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

tr:hover td {
  background: var(--surface-hover);
}

.prod-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.prod-thumb {
  width: 50px;
  height: 42px;
  border-radius: 9px;
  object-fit: cover;
  background: #f1f5f9;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.prod-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.prod-sub {
  font-size: 11.5px;
  color: var(--muted);
}

.store-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: rgba(201, 164, 92, 0.16);
  color: var(--gold-dark);
  white-space: nowrap;
}

body.dark-theme .store-badge {
  color: var(--gold-light);
}

.row-actions {
  display: flex;
  gap: 6px;
}

/* Cards View */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.product-card-img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #f1f5f9;
  border-bottom: 1px solid var(--border);
}

.product-card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.product-card-title {
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.product-card-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--blue);
}

.product-card-meta {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.product-card-actions {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  gap: 8px;
}

.product-card-actions .btn {
  flex: 1;
}

/* Pagination Bar */
.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 13px;
  color: var(--muted);
}

.pagination-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pagination-left select {
  width: auto;
  padding: 6px 10px;
  font-size: 12.5px;
}

.pagination-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.page-btn.active {
  background: var(--gold);
  color: #111;
  border-color: var(--gold);
}

.page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(15, 18, 24, 0.58);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 600px;
  max-height: 94vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}

.modal-card.modal-wide {
  max-width: 1140px;
  padding: 20px 26px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-head h2 {
  font-family: var(--font-serif);
  font-size: 21px;
}

.modal-split {
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  gap: 22px;
  align-items: start;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-full {
  grid-column: 1 / -1;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

/* Preview Panel in Add/Edit Modal */
.preview-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold-dark);
}

body.dark-theme .preview-label {
  color: var(--gold-light);
}

.preview-3d-box {
  width: 100%;
  height: 215px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(201, 164, 92, 0.35);
  background: #13161c;
  cursor: grab;
}

.preview-3d-box:active {
  cursor: grabbing;
}

.upload-preview-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.upload-preview-box img {
  width: 68px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  background: #f1f5f9;
  flex-shrink: 0;
}

.upload-preview-meta {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.color-picker-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.color-swatch:hover {
  transform: scale(1.12);
}

.color-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--gold);
}

.native-color-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.upload-dropzone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px dashed rgba(201, 164, 92, 0.55);
  background: rgba(201, 164, 92, 0.08);
  min-width: 0;
}

.upload-dropzone input[type="file"] {
  font-size: 12px;
  color: var(--muted);
  border: none;
  background: transparent;
  padding: 0;
  min-width: 0;
}

/* Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
  display: none;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 10px 18px;
  border-radius: 999px;
  background: #16181d;
  border: 1px solid var(--gold);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  max-width: calc(100vw - 32px);
  text-align: center;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .modal-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .admin-sidebar,
  .sidebar-toggle-btn {
    display: none !important;
  }

  .admin-main {
    padding: 12px 12px 84px;
    gap: 12px;
  }

  .admin-topbar {
    padding: 12px 14px;
    flex-wrap: wrap;
  }

  .topbar-right {
    width: 100%;
    justify-content: flex-end;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-value {
    font-size: 20px;
  }

  .toolbar {
    padding: 12px;
  }

  .toolbar-filters,
  .toolbar-actions {
    width: 100%;
  }

  .toolbar-filters input,
  .toolbar-filters select {
    flex: 1 1 100%;
    min-width: 0;
  }

  .toolbar-actions .btn {
    flex: 1 1 auto;
  }

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

  .upload-dropzone {
    flex-direction: column;
    align-items: stretch;
  }

  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 95;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 4px env(safe-area-inset-bottom, 6px);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.08);
  }

  .mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 10.5px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-nav-btn.active {
    color: var(--gold-dark);
  }

  .mobile-nav-btn.danger {
    color: var(--danger);
  }

  .toast {
    bottom: 78px;
  }
}
