/* CB Agency Admin Panel CSS */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  --c-bg:         #0A0A0A;
  --c-surface:    #141414;
  --c-surface-2:  #1C1C1C;
  --c-surface-3:  #242424;
  --c-border:     rgba(255,255,255,0.08);
  --c-accent:     #F5C800;
  --c-accent-dim: rgba(245,200,0,0.12);
  --c-green:      #25D366;
  --c-red:        #E03434;
  --c-text:       #FFFFFF;
  --c-text-2:     #AAAAAA;
  --c-text-3:     #666666;
  --sidebar-w:    240px;
  --header-h:     64px;
  --r-sm:  6px;
  --r-md:  12px;
  --r-lg:  16px;
  --t-base: 200ms ease;
}

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

html { font-size: 16px; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
ul { list-style: none; }

/* === ADMIN LAYOUT === */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--t-base);
}

.sidebar-logo {
  padding: 20px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo img { height: 32px; width: auto; }

.sidebar-logo-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--c-text);
}

.sidebar-logo-text span { color: var(--c-accent); }

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav ul { list-style: none; }

.sidebar-nav-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--c-text-2);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--t-base);
  border-radius: 0;
  position: relative;
}

.sidebar-nav-item a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--c-accent);
  border-radius: 0 3px 3px 0;
  opacity: 0;
  transition: opacity var(--t-base);
}

.sidebar-nav-item a:hover,
.sidebar-nav-item.active a {
  color: var(--c-text);
  background: rgba(255,255,255,0.04);
}

.sidebar-nav-item.active a::before { opacity: 1; }
.sidebar-nav-item.active a { color: var(--c-accent); }

.sidebar-nav-item a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-divider {
  height: 1px;
  background: var(--c-border);
  margin: 8px 20px;
}

.sidebar-section-label {
  padding: 12px 20px 4px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-text-3);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--c-border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--c-accent-dim);
  border: 1px solid rgba(245,200,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--c-accent);
}

.sidebar-username { font-size: 0.85rem; font-weight: 600; }
.sidebar-role     { font-size: 0.7rem; color: var(--c-text-3); }

.sidebar-logout {
  margin-left: auto;
  padding: 6px;
  color: var(--c-text-3);
  border-radius: var(--r-sm);
  transition: all var(--t-base);
}

.sidebar-logout:hover { color: var(--c-red); background: rgba(224,52,52,0.1); }
.sidebar-logout svg { width: 16px; height: 16px; }

/* MAIN CONTENT */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ADMIN HEADER */
.admin-header {
  height: var(--header-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.admin-header-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
}

.admin-header-actions { display: flex; align-items: center; gap: 12px; }

/* ADMIN CONTENT AREA */
.admin-content {
  padding: 24px;
  flex: 1;
}

/* === CARDS === */
.admin-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.admin-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-card-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.admin-card-body { padding: 20px; }

/* === STAT CARDS === */
.stats-grid-admin {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: all var(--t-base);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--c-accent);
  opacity: 0;
  transition: opacity var(--t-base);
}

.stat-card:hover { border-color: rgba(255,255,255,0.12); }
.stat-card:hover::before { opacity: 1; }

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  background: var(--c-accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.stat-card-icon svg { width: 20px; height: 20px; color: var(--c-accent); }

.stat-card-number {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  color: var(--c-accent);
  line-height: 1;
}

.stat-card-label {
  font-size: 0.8rem;
  color: var(--c-text-2);
  margin-top: 4px;
}

/* === TABLES === */
.table-container {
  overflow-x: auto;
  border-radius: var(--r-lg);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.admin-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-text-3);
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}

.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}

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

.admin-table tr:hover td { background: rgba(255,255,255,0.02); }

.table-thumb {
  width: 56px;
  height: 80px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--c-surface-3);
}

.table-thumb-placeholder {
  width: 56px;
  height: 80px;
  border-radius: 6px;
  background: var(--c-surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-3);
}

/* === BADGES === */
.badge-admin {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.badge-success { background: rgba(37,211,102,0.15); color: #25D366; }
.badge-danger  { background: rgba(224,52,52,0.15);  color: #E03434; }
.badge-warning { background: rgba(245,200,0,0.15);  color: #F5C800; }
.badge-info    { background: rgba(91,141,239,0.15); color: #5B8DEF; }

/* === BUTTONS === */
.btn-admin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-sm);
  font-size: 0.8rem;
  font-weight: 600;
  transition: all var(--t-base);
  cursor: pointer;
  white-space: nowrap;
}

.btn-admin-primary { background: var(--c-accent); color: #000; }
.btn-admin-primary:hover { background: #FFD600; transform: translateY(-1px); }

.btn-admin-danger { background: rgba(224,52,52,0.15); color: #E03434; border: 1px solid rgba(224,52,52,0.25); }
.btn-admin-danger:hover { background: rgba(224,52,52,0.25); }

.btn-admin-outline { border: 1px solid var(--c-border); color: var(--c-text-2); background: transparent; }
.btn-admin-outline:hover { border-color: rgba(255,255,255,0.2); color: var(--c-text); }

.btn-admin-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-2);
  transition: all var(--t-base);
}

.btn-admin-icon:hover { background: var(--c-surface-2); color: var(--c-text); }
.btn-admin-icon svg { width: 16px; height: 16px; }

/* === FORMS === */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--c-text-2);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.form-label .required { color: var(--c-accent); margin-left: 2px; }

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  color: var(--c-text);
  font-family: inherit;
  font-size: 0.875rem;
  transition: all var(--t-base);
  outline: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(245,200,0,0.1);
}

.form-textarea { resize: vertical; min-height: 80px; }
.form-select   { cursor: pointer; }

.form-hint {
  font-size: 0.75rem;
  color: var(--c-text-3);
  margin-top: 4px;
}

.form-error {
  font-size: 0.75rem;
  color: var(--c-red);
  margin-top: 4px;
  display: none;
}

.form-error.show { display: block; }

/* === UPLOAD ZONES === */
.upload-zone {
  border: 2px dashed var(--c-border);
  border-radius: var(--r-md);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--t-base);
  position: relative;
  overflow: hidden;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--c-accent);
  background: var(--c-accent-dim);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-zone-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  color: var(--c-text-3);
}

.upload-zone-icon svg { width: 100%; height: 100%; }

.upload-zone-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.upload-zone-sub {
  font-size: 0.8rem;
  color: var(--c-text-3);
}

.upload-zone.has-file {
  border-color: var(--c-green);
  background: rgba(37,211,102,0.05);
}

.upload-file-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--c-green);
  margin-top: 8px;
  display: none;
}

.upload-zone.has-file .upload-file-name { display: block; }
.upload-zone.has-file .upload-zone-icon { color: var(--c-green); }

/* === PROGRESS BAR === */
.upload-progress {
  margin-top: 16px;
  display: none;
}

.upload-progress.show { display: block; }

.progress-bar-wrap {
  height: 6px;
  background: var(--c-surface-3);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c-accent), #FF8C00);
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 3px;
}

.progress-text {
  font-size: 0.75rem;
  color: var(--c-text-2);
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
}

/* === TOGGLE SWITCH === */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--c-surface-3);
  border-radius: 24px;
  cursor: pointer;
  transition: background var(--t-base);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--c-text-2);
  left: 3px;
  top: 3px;
  transition: all var(--t-base);
}

.toggle input:checked + .toggle-slider { background: var(--c-accent); }
.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #000;
}

/* === MODAL === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  transform: scale(0.95) translateY(8px);
  transition: transform 0.25s ease;
}

.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 1rem; font-weight: 700; }

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-2);
  transition: all var(--t-base);
}

.modal-close:hover { background: var(--c-surface-2); color: var(--c-text); }
.modal-close svg { width: 16px; height: 16px; }

.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--c-border); display: flex; gap: 8px; justify-content: flex-end; }

/* === ALERT === */
.alert {
  padding: 12px 16px;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: rgba(37,211,102,0.1);  border: 1px solid rgba(37,211,102,0.25); color: #25D366; }
.alert-error   { background: rgba(224,52,52,0.1);   border: 1px solid rgba(224,52,52,0.25);  color: #E03434; }
.alert-warning { background: rgba(245,200,0,0.1);   border: 1px solid rgba(245,200,0,0.25);  color: #F5C800; }

/* === LOGIN PAGE === */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--c-bg);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(245,200,0,0.07) 0%, transparent 70%);
  pointer-events: none;
}

.login-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  position: relative;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--c-accent), transparent);
}

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

.login-logo img { height: 48px; margin: 0 auto; }

.login-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--c-text-2);
  text-align: center;
  margin-bottom: 24px;
}

/* === UPLOAD PAGE GRID === */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 600px) {
  .upload-grid { grid-template-columns: repeat(3, 1fr); }
}

/* === PAGINATION === */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 16px 20px;
  border-top: 1px solid var(--c-border);
  justify-content: center;
}

.page-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--c-text-2);
  border: 1px solid var(--c-border);
  transition: all var(--t-base);
  cursor: pointer;
  text-decoration: none;
}

.page-btn:hover { border-color: rgba(255,255,255,0.2); color: var(--c-text); }
.page-btn.active { background: var(--c-accent); color: #000; border-color: var(--c-accent); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* === CATEGORIES PAGE === */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  padding: 20px;
}

.category-card {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: all var(--t-base);
}

.category-card:hover { border-color: rgba(255,255,255,0.12); }

.category-card-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.category-card-count {
  font-size: 0.75rem;
  color: var(--c-text-3);
  margin-top: 2px;
}

.category-card-actions { display: flex; gap: 4px; }

/* === SETTINGS PAGE === */
.settings-section {
  margin-bottom: 24px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-border);
}

.settings-row:last-child { border-bottom: none; }

.settings-row-info { flex: 1; }

.settings-row-label {
  font-size: 0.875rem;
  font-weight: 600;
}

.settings-row-desc {
  font-size: 0.75rem;
  color: var(--c-text-3);
  margin-top: 2px;
}

.settings-row-control { flex-shrink: 0; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .admin-header { padding: 0 16px; }
  .admin-content { padding: 16px; }

  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--c-text);
  }
  .mobile-menu-btn svg { width: 22px; height: 22px; }
}

.mobile-menu-btn { display: none; }

/* Overlay for mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.show { display: block; }

/* === UTILITY === */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--c-text-2); }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }
