/* ============================================================================
   E-Commerce Admin Panel — Custom Styles
   ============================================================================ */

:root {
  --sidebar-width: 250px;
  --sidebar-collapsed: 76px;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --sidebar-bg: #111827;
  --sidebar-text: #9ca3af;
  --sidebar-text-active: #ffffff;
  --topbar-h: 64px;
  --body-bg: #f3f4f6;
}

* { box-sizing: border-box; }

body {
  background: var(--body-bg);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #1f2937;
}

.app-wrapper { display: flex; min-height: 100vh; }

/* ---------------- Sidebar ---------------- */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  transition: width .2s ease, transform .2s ease;
  z-index: 1030;
}
.app-sidebar.collapsed { width: var(--sidebar-collapsed); }
.app-sidebar.collapsed .brand-text,
.app-sidebar.collapsed .nav-link span { display: none; }

.sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  color: #fff; font-weight: 700; font-size: 1.1rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand i { font-size: 1.4rem; color: var(--primary); }

.sidebar-nav { padding: .75rem; flex: 1; overflow-y: auto; }
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: .8rem;
  color: var(--sidebar-text);
  padding: .65rem .9rem;
  border-radius: .5rem;
  margin-bottom: .2rem;
  font-size: .92rem;
  transition: background .15s, color .15s;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--primary); color: #fff; }
.sidebar-divider { height: 1px; background: rgba(255,255,255,.08); margin: .75rem .5rem; }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1020;
}

/* ---------------- Main area ---------------- */
.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left .2s ease;
}
.app-main.collapsed { margin-left: var(--sidebar-collapsed); }

.topbar { height: var(--topbar-h); position: sticky; top: 0; z-index: 1010; }
.avatar-circle {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600;
}

.app-content { flex: 1; }

/* ---------------- Cards ---------------- */
.stat-card {
  border: none; border-radius: 1rem;
  color: #fff; overflow: hidden; position: relative;
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
}
.stat-card .stat-icon {
  position: absolute; right: 1rem; top: 1rem; font-size: 2.4rem; opacity: .3;
}
.stat-card .stat-value { font-size: 1.9rem; font-weight: 700; }
.stat-card .stat-label { font-size: .85rem; opacity: .9; }

.bg-grad-indigo { background: linear-gradient(135deg,#6366f1,#4338ca); }
.bg-grad-emerald { background: linear-gradient(135deg,#10b981,#047857); }
.bg-grad-amber { background: linear-gradient(135deg,#f59e0b,#b45309); }
.bg-grad-rose { background: linear-gradient(135deg,#f43f5e,#be123c); }
.bg-grad-sky { background: linear-gradient(135deg,#0ea5e9,#0369a1); }

.card { border: none; border-radius: .9rem; box-shadow: 0 2px 10px rgba(0,0,0,.05); }
.card-header { background: #fff; border-bottom: 1px solid #eef0f3; font-weight: 600; }

/* ---------------- Product / category thumbnails ---------------- */
.thumb-sm {
  width: 46px; height: 46px; object-fit: cover; border-radius: .5rem; border: 1px solid #e5e7eb;
}
.thumb-lg { width: 100%; height: 140px; object-fit: cover; border-radius: .6rem; border: 1px solid #e5e7eb; }
.color-swatch {
  width: 22px; height: 22px; border-radius: 50%; display: inline-block;
  border: 2px solid #fff; box-shadow: 0 0 0 1px #d1d5db;
}

/* ---------------- Login page ---------------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg,#111827,#4338ca);
}
.login-card { border-radius: 1rem; overflow: hidden; max-width: 400px; width: 100%; }
.login-card .card-header-brand {
  background: rgba(0,0,0,.15); text-align: center; padding: 2rem 1.5rem 1rem;
}

/* ---------------- Image upload preview grid ---------------- */
.image-preview-grid { display: flex; flex-wrap: wrap; gap: .75rem; }
.image-preview-item {
  position: relative; width: 100px; height: 100px; border-radius: .5rem; overflow: hidden;
  border: 1px solid #e5e7eb;
}
.image-preview-item img { width: 100%; height: 100%; object-fit: cover; }
.image-preview-item .remove-btn {
  position: absolute; top: 3px; right: 3px; background: rgba(220,38,38,.9); color: #fff;
  border-radius: 50%; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: .7rem;
}

.color-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }

/* ---------------- Image position controls (First / Move / Last) ---------------- */
.image-preview-item .img-position-badge {
  position: absolute; top: 3px; left: 3px; background: rgba(17,24,39,.75); color: #fff;
  border-radius: .3rem; font-size: .68rem; line-height: 1; padding: 2px 5px; font-weight: 600;
}
.image-preview-item .img-position-controls {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 1px;
  background: rgba(17,24,39,.55); opacity: 0; transition: opacity .15s ease;
}
.image-preview-item:hover .img-position-controls { opacity: 1; }
.image-preview-item .btn-pos {
  border: none; background: transparent; color: #fff; width: 22px; height: 20px; font-size: .65rem;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.image-preview-item .btn-pos:hover { background: rgba(255,255,255,.2); }

/* ---------------- Custom Options list ---------------- */
.option-item { border: 1px solid #eef0f3; border-radius: .6rem; padding: .75rem .9rem; margin-bottom: .65rem; }
.option-item .option-config { border-top: 1px dashed #e5e7eb; margin-top: .6rem; padding-top: .6rem; }
.palette-color-row, .size-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.design-row {
  border: 1px dashed #d1d5db; border-radius: .5rem; padding: .6rem; margin-bottom: .6rem; background: #fafafa;
}

/* Responsive: sidebar collapses off-canvas below lg */
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.show { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .sidebar-backdrop.show { display: block; }
}
