@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;600;700;900&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #07071a;
  --bg-secondary: #0e0e2a;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --purple-main: #8b5cf6;
  --purple-light: #a78bfa;
  --blue-accent: #3b82f6;
  --gradient-text: linear-gradient(135deg, #a78bfa, #60a5fa);
  --gradient-btn: linear-gradient(135deg, #8b5cf6, #3b82f6);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: rgba(139, 92, 246, 0.2);
  --border-hover: rgba(139, 92, 246, 0.5);
  --shadow-purple: 0 0 30px rgba(139, 92, 246, 0.3);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-btn: 0 4px 20px rgba(139, 92, 246, 0.4);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(109,40,217,0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(59,130,246,0.1) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--purple-main); border-radius: 3px; }

/* Admin Layout */
.admin-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  position: fixed;
  height: 100vh;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-logo {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo img {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 2px solid var(--purple-main);
  box-shadow: 0 0 12px rgba(139,92,246,0.5);
}

.sidebar-logo-text {
  font-family: 'Orbitron', monospace;
  font-size: 0.9rem;
  font-weight: 700;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-logo-sub { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

.sidebar-nav {
  flex: 1;
  padding: 1.5rem 0.75rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-item a, .sidebar-item button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}

.sidebar-item a:hover,
.sidebar-item button:hover,
.sidebar-item.active a {
  background: rgba(139, 92, 246, 0.15);
  color: var(--purple-light);
}

.sidebar-item.active a {
  border-left: 3px solid var(--purple-main);
}

.sidebar-icon { font-size: 1.1rem; }

.sidebar-footer {
  padding: 1rem 0.75rem;
  border-top: 1px solid var(--border-color);
}

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

/* Topbar */
.admin-topbar {
  background: rgba(14, 14, 42, 0.9);
  border-bottom: 1px solid var(--border-color);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-family: 'Orbitron', monospace;
  font-size: 1rem;
  font-weight: 700;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.topbar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gradient-btn);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: white;
}

/* Admin content area */
.admin-content {
  padding: 2rem;
  flex: 1;
}

/* Panels */
.admin-panel { display: none; }
.admin-panel.active { display: block; animation: fadeInUp 0.4s ease; }

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
  backdrop-filter: blur(10px);
}

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow-card);
}

.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-md);
  background: rgba(139,92,246,0.15);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-info {}
.stat-num {
  font-family: 'Orbitron', monospace;
  font-size: 1.6rem;
  font-weight: 700;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-lbl { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* Panel header */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.panel-title {
  font-family: 'Orbitron', monospace;
  font-size: 1.2rem;
  font-weight: 700;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Table */
.admin-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  backdrop-filter: blur(10px);
}

.admin-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.admin-table th {
  background: rgba(139,92,246,0.1);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--purple-light);
  border-bottom: 1px solid var(--border-color);
}

.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(139,92,246,0.05);
  font-size: 0.875rem;
  color: var(--text-secondary);
  vertical-align: middle;
}

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

.admin-table tr:hover td { background: var(--bg-card-hover); }

.table-img {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-secondary);
}

.image-count-badge {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.68rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-active { background: rgba(34,197,94,0.15); color: #86efac; border: 1px solid rgba(34,197,94,0.3); }
.badge-inactive { background: rgba(239,68,68,0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
.badge-pending { background: rgba(251,191,36,0.15); color: #fde68a; border: 1px solid rgba(251,191,36,0.3); }
.badge-paid { background: rgba(34,197,94,0.15); color: #86efac; border: 1px solid rgba(34,197,94,0.3); }

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

/* Buttons (shared) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 20px;
  border-radius: var(--radius-md);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary { background: var(--gradient-btn); color: white; box-shadow: var(--shadow-btn); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(139,92,246,0.6); }
.btn-outline { background: transparent; color: var(--purple-light); border: 1px solid var(--border-hover); }
.btn-outline:hover { background: rgba(139,92,246,0.1); }
.btn-danger { background: linear-gradient(135deg, #dc2626, #b91c1c); color: white; }
.btn-danger:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(220,38,38,0.4); }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-ghost { background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text-primary); }

/* Product Form Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-card), var(--shadow-purple);
  animation: slideUp 0.4s cubic-bezier(0.4,0,0.2,1);
}

.modal-header {
  padding: 1.5rem 1.5rem 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-title {
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-close {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  width: 32px; height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: var(--transition);
}

.modal-close:hover { color: var(--text-primary); background: var(--bg-card-hover); }

.modal-body { padding: 0 1.5rem 1.5rem; }

/* Form elements */
.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  transition: var(--transition);
}

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

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--purple-main);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.15);
}

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

.form-select option { background: var(--bg-secondary); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Image preview */
.image-preview-wrap {
  margin-top: 0.75rem;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  transition: var(--transition);
}

.image-preview-wrap:hover { border-color: var(--border-hover); }

.image-preview {
  max-width: 100%;
  max-height: 160px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  display: none;
}

.image-preview.show { display: block; margin: 0 auto 0.75rem; }

.image-placeholder { color: var(--text-muted); font-size: 0.85rem; }
.image-placeholder-icon { font-size: 2rem; margin-bottom: 0.5rem; }

.gallery-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.gallery-item {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem;
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.gallery-item img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
}

.gallery-item-info {
  min-width: 0;
}

.gallery-item-info strong {
  display: block;
  color: var(--text-primary);
  font-size: 0.82rem;
}

.gallery-item-info span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.gallery-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Tags input for colors */
.tags-input-wrap {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 44px;
  cursor: text;
  transition: var(--transition);
}

.tags-input-wrap:focus-within {
  border-color: var(--purple-main);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.15);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(139,92,246,0.2);
  border: 1px solid rgba(139,92,246,0.3);
  border-radius: 100px;
  padding: 2px 10px;
  font-size: 0.8rem;
  color: var(--purple-light);
}

.tag-remove {
  background: none;
  border: none;
  color: var(--purple-light);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
  line-height: 1;
}

.tags-input {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  outline: none;
  min-width: 120px;
  flex: 1;
}

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

/* Size-specific prices */
.size-prices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.size-price-field {
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}

.size-price-field label {
  display: block;
  color: var(--purple-light);
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 0.45rem;
}

/* Color presets */
.color-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.color-preset {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 100px;
  padding: 3px 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.color-preset:hover { border-color: var(--purple-main); color: var(--purple-light); }

.preset-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
}

/* Confirmation modal */
.confirm-modal {
  max-width: 420px;
  text-align: center;
  padding: 2.5rem;
}

.confirm-icon { font-size: 3rem; margin-bottom: 1rem; }
.confirm-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.5rem; }
.confirm-msg { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1.5rem; }
.confirm-actions { display: flex; gap: 0.75rem; justify-content: center; }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 2rem; right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  max-width: 340px;
  animation: slideInRight 0.4s ease;
  backdrop-filter: blur(10px);
}

.toast.success { border-color: rgba(34,197,94,0.4); }
.toast.error { border-color: rgba(239,68,68,0.4); }

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

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

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

@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Responsive */
@media (max-width: 900px) {
  .admin-layout {
    display: block;
  }
  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    max-height: none;
    transform: none;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .sidebar-logo {
    padding: 1rem;
  }
  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 0.75rem;
    gap: 0.5rem;
  }
  .sidebar-item {
    flex: 0 0 auto;
  }
  .sidebar-item a,
  .sidebar-item button {
    white-space: nowrap;
    min-height: 42px;
  }
  .sidebar-footer {
    padding: 0 0.75rem 0.75rem;
  }
  .admin-main { margin-left: 0; }
  .admin-topbar {
    padding: 0 1rem;
    height: 56px;
  }
  .admin-content {
    padding: 1rem;
  }
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
  .stat-card {
    padding: 1rem;
  }
  .panel-header {
    align-items: stretch;
  }
  .panel-header .btn {
    width: 100%;
    min-height: 42px;
  }
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    max-height: 94vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .table-actions {
    flex-wrap: wrap;
  }
  .gallery-item {
    grid-template-columns: 52px minmax(0, 1fr);
  }
  .gallery-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }
  .gallery-actions .btn {
    flex: 1;
  }
}

@media (max-width: 520px) {
  .sidebar-logo img {
    width: 38px;
    height: 38px;
  }
  .sidebar-logo-text {
    font-size: 0.82rem;
  }
  .panel-title {
    font-size: 1rem;
  }
  .modal-header,
  .modal-body {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .confirm-modal {
    padding: 1.5rem 1rem;
  }
  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }
  .toast {
    max-width: 100%;
  }
}
