/* =========================================================
   ADMIN.CSS - 100VH FIXED SIDEBAR, ISOLATED MAIN SCROLL & BULLETPROOF MODALS
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,400;1,600;1,700&family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;600;700;800&display=swap&subset=vietnamese');

:root {
  --primary-emerald: #10b981;
  --primary-glow: rgba(16, 185, 129, 0.4);
  --bg-dark: #040810;
  --card-bg: #091222;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --font-mono: 'JetBrains Mono', monospace;
}

/* 1. ROOT VIEWPORT: 100VH LOCKED (NO BODY SCROLL) */
html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg-dark);
  color: #e2e8f0;
  font-family: 'Be Vietnam Pro', 'Inter', sans-serif;
  overflow: hidden !important;
}

/* Icon font safety */
.fa, .fas, .far, .fab, .fa-solid, .fa-regular, .fa-brands, [class*="fa-"] {
  font-family: "Font Awesome 6 Free", "Font Awesome 6 Brands", "FontAwesome" !important;
  font-style: normal;
  display: inline-block;
}

/* 2. ADMIN CONTAINER: 100VH FLEX */
.admin-layout {
  height: 100vh;
  width: 100vw;
  display: flex;
  overflow: hidden;
  background: var(--bg-dark);
}

/* 3. SIDEBAR: 100VH ABSOLUTELY FIXED (NEVER MOVES ON MAIN SCROLL) */
.admin-sidebar {
  height: 100vh;
  width: 260px;
  flex-shrink: 0;
  background: #080f1e;
  border-right: 1px solid var(--border-subtle);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  z-index: 100;
}
.admin-sidebar::-webkit-scrollbar {
  display: none;
}

.admin-brand {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary-emerald);
  letter-spacing: 0.5px;
  margin-bottom: 28px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-brand-img {
  height: 34px;
  width: auto;
  object-fit: contain;
}
.sidebar-custom-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  filter: brightness(1.2);
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-radius: 12px;
  color: #94a3b8;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}
.admin-nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}
.admin-nav-item.active {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.16), transparent);
  color: var(--primary-emerald);
  border-left: 3px solid var(--primary-emerald);
}
.admin-sidebar-bottom {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* 4. MAIN CONTENT AREA: 100VH ONLY THIS AREA SCROLLS (0 PADDING AT CONTAINER LEVEL) */
.admin-main {
  height: 100vh;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 !important;
  margin: 0 !important;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(16, 185, 129, 0.4) transparent;
  background: var(--bg-dark);
}
.admin-main::-webkit-scrollbar {
  width: 8px;
}
.admin-main::-webkit-scrollbar-track {
  background: transparent;
}
.admin-main::-webkit-scrollbar-thumb {
  background: rgba(16, 185, 129, 0.35);
  border-radius: 4px;
}
.admin-main::-webkit-scrollbar-thumb:hover {
  background: #10b981;
}

/* STICKY PAGE HEADER INSIDE ADMIN MAIN - ZERO-GAP AT TOP, SOLID OPAQUE BACKGROUND */
.admin-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: #040810 !important; /* 100% Solid Opaque Dark Background */
  padding: 22px clamp(20px, 3.5vw, 40px);
  margin: 0 !important;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.7);
}
.admin-subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0;
  line-height: 1.4;
}
.admin-title {
  font-size: 1.65rem;
  font-weight: 900;
  color: #fff;
  margin: 0 0 6px 0;
}

/* PAGE CONTENT PANELS: PADDING LIVES HERE */
.tab-panel {
  padding: 24px clamp(20px, 3.5vw, 40px) 40px;
  box-sizing: border-box;
}

/* 5. CARDS & FORMS */
.cms-card {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: clamp(20px, 3vw, 32px);
  margin-bottom: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.cms-card-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-title-icon {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 800px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 8px;
}
.form-control {
  width: 100%;
  padding: 12px 16px;
  background: #050a14;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #fff;
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
  transition: all 0.2s ease;
}
.form-control:focus {
  border-color: var(--primary-emerald);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.25);
}

/* 6. BUTTONS */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #03150c;
  font-weight: 800;
  font-size: 0.92rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
  transition: all 0.2s ease;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(16, 185, 129, 0.5);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  font-weight: 700;
  font-size: 0.88rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.btn-cms-edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
  font-size: 0.84rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-cms-edit:hover {
  background: #10b981;
  color: #03150c;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.btn-cms-delete {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #ef4444;
  font-size: 0.84rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-cms-delete:hover {
  background: #ef4444;
  color: #fff;
}

/* 7. TABLES */
.cms-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.cms-table th {
  padding: 14px 16px;
  background: #060b17;
  color: #94a3b8;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-subtle);
}
.cms-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #e2e8f0;
  font-size: 0.9rem;
  vertical-align: middle;
}
.cms-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}
.table-logo-img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 8. BULLETPROOF MODALS (Z-INDEX 99999, STANDALONE TOP LAYER - HIDDEN BY DEFAULT) */
body > .modal-overlay,
.modal-overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 99999 !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  padding: clamp(16px, 3vw, 40px);
  background: rgba(2, 6, 12, 0.88) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
  box-sizing: border-box;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  overscroll-behavior: contain;
}

.modal-overlay.active {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.modal-box {
  background: #081220;
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: 20px;
  max-height: calc(100vh - 50px);
  width: 100%;
  max-width: 960px;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: auto;
  position: relative;
  padding: clamp(24px, 3.5vw, 36px);
  box-sizing: border-box;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.9), 0 0 40px rgba(16, 185, 129, 0.2);
  scrollbar-width: thin;
  scrollbar-color: #10b981 rgba(255, 255, 255, 0.05);
}
.modal-box::-webkit-scrollbar {
  width: 6px;
}
.modal-box::-webkit-scrollbar-thumb {
  background: #10b981;
  border-radius: 4px;
}

.modal-close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
  z-index: 10;
}
.modal-close-btn:hover {
  background: #ef4444;
  border-color: #ef4444;
  transform: rotate(90deg);
}

/* 9. 12 BADGE COLOR SWATCHES */
.color-palette-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 10px;
}
@media (max-width: 600px) {
  .color-palette-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.color-swatch-pill {
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.15);
  transition: all 0.2s ease;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
.color-swatch-pill:hover, .color-swatch-pill.active {
  border-color: #fff;
  transform: scale(1.08);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
}

/* 10. CATEGORY MANAGER UI */
.category-status-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
}
.category-status-tag.active {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.category-status-tag.inactive {
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

/* Category Product Multi-Select List */
.cat-prod-select-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px;
  background: #050a14;
  margin-top: 10px;
}
.cat-prod-item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.2s ease;
  cursor: pointer;
}
.cat-prod-item-row:hover {
  background: rgba(16, 185, 129, 0.08);
}
.cat-prod-item-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #10b981;
  cursor: pointer;
}

/* Image Upload Cards */
.image-upload-card {
  display: flex;
  align-items: center;
  gap: 20px;
  background: #050a14;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 16px;
}
.upload-preview-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #10b981;
}
.upload-preview-product {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.15);
}
.upload-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 10px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  padding: 14px 20px;
  background: #0f172a;
  border: 1px solid #10b981;
  color: #fff;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastSlideIn 0.3s ease;
}
@keyframes toastSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Cropper Studio */
.cropper-modal-box {
  background: #070d18;
  border: 1px solid #10b981;
  border-radius: 20px;
  padding: 24px;
  max-width: 520px;
  width: 100%;
  position: relative;
  margin: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
}
.cropper-viewport-stage {
  position: relative;
  width: 340px;
  height: 340px;
  margin: 14px auto;
  overflow: hidden;
  background: #02060c;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cropper-visual-mask {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.65);
  border: 2px dashed #10b981;
  aspect-ratio: 1/1;
  width: 340px;
  height: 340px;
  border-radius: 14px;
}
.cropper-toolbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 14px 0 18px;
  gap: 10px;
}
.cropper-zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.btn-tool-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}


/* CMS Badge Pill in Table */
.cms-badge-pill {
  display: inline-block !important;
  position: static !important;
  padding: 4px 10px !important;
  border-radius: 9999px !important;
  font-size: 0.72rem !important;
  font-weight: 800 !important;
  color: #ffffff !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4) !important;
  white-space: nowrap !important;
  line-height: 1.2 !important;
}


/* =========================================================================
   ADMIN MODALS: ORIGINAL WIDE PC SIZE (85VW) + INVISIBLE SMOOTH SCROLLBAR
   ========================================================================= */

#cms-prod-modal .modal-box,
#cms-category-modal .modal-box,
.admin-layout .modal-box,
body > .modal-overlay .modal-box {
  width: 85vw !important;
  max-width: 1350px !important;
  min-width: 320px !important;
  max-height: 90vh !important;
  height: auto !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  display: block !important;
  padding: clamp(24px, 3.5vw, 36px) !important;
  margin: auto !important;
  box-sizing: border-box !important;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

#cms-prod-modal .modal-box::-webkit-scrollbar,
#cms-category-modal .modal-box::-webkit-scrollbar,
.admin-layout .modal-box::-webkit-scrollbar,
body > .modal-overlay .modal-box::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}


/* =========================================================================
   SYSTEM SETTINGS TAB STYLING & RESPONSIVE
   ========================================================================= */

.system-account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.system-images-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.btn-admin-logout:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #f87171 !important;
}

@media (max-width: 900px) {
  .system-account-grid {
    grid-template-columns: 1fr !important;
  }
  .system-images-grid {
    grid-template-columns: 1fr !important;
  }
}


/* =========================================================================
   REALTIME CHARACTER COUNTER & INPUT SAFETY
   ========================================================================= */

.cms-char-counter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 4px;
  font-family: var(--font-mono, monospace);
  user-select: none;
  transition: color 0.2s ease;
}

.cms-char-counter .remain-val {
  font-weight: 700;
  color: #94a3b8;
}

.cms-char-counter.warning .remain-val {
  color: #f59e0b;
}

.cms-char-counter.at-limit {
  color: #ef4444 !important;
}

.cms-char-counter.at-limit .remain-val {
  color: #ef4444 !important;
}

.cms-char-counter.at-limit .limit-status {
  font-weight: 700;
  color: #ef4444;
}

/* Ensure all text inputs wrap and don't break flex */
.form-control, input, textarea, select {
  font-family: 'Be Vietnam Pro', 'Inter', -apple-system, sans-serif !important;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}
