:root {
  --sb-w: 260px;
  --tb-h: 70px;
  --sd-bg: #111111;
  --sd-text: #ffffff;
  --sd-active: rgba(255, 255, 255, 0.1);
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  --radius-xl: 16px;
  --bg-rgb: 255, 255, 255;
  --bg: #ffffff;
  --bg-muted: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --accent: #6366f1;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-muted: #1e293b;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --border: #334155;
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --bg-rgb: 15, 23, 42;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

.theme-toggle-btn {
  padding: 0.5rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.theme-toggle-btn:hover {
  background: var(--bg-muted);
  transform: translateY(-1px);
}

/* Dashboard Layout */
.admin-dashboard-wrapper {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.admin-sidebar {
  width: var(--sb-w);
  background: var(--sd-bg);
  color: var(--sd-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.8rem;
}

.logo-text {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sidebar-nav {
  flex: 1;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
}

.sidebar-divider {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
  margin: 1.5rem 0.5rem 0.5rem;
  letter-spacing: 0.05em;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.sidebar-link svg {
  opacity: 0.7;
  transition: all 0.2s;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.sidebar-link.active {
  background: var(--sd-active);
  color: #fff;
  font-weight: 600;
}

.sidebar-link.active svg {
  color: var(--accent);
  opacity: 1;
}

.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Main Content Area */
.admin-content-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
}

/* Toolbar */
.admin-toolbar {
  height: 70px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  flex-shrink: 0;
  z-index: 100;
}

.status-indicator {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-indicator::before {
  content: "";
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
}

.toolbar-actions {
  display: flex;
  gap: 0.75rem;
}

/* Page Content Area */
.admin-page-content {
  flex: 1;
  padding: 2.5rem;
  overflow-y: auto;
  scroll-behavior: smooth;
  height: calc(100vh - 70px);
}

.admin-page-header {
  margin-bottom: 2rem;
}

.admin-h1 {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.admin-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Tab Management */
.tab-content {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.tab-content.active {
  display: block;
}

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

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

.stats-card {
  background: var(--bg);
  padding: 1.5rem;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stats-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.stats-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

/* Card Styling */
.admin-card {
  background: var(--bg);
  padding: 1.75rem;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  margin-bottom: 1.5rem;
}

.admin-h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  letter-spacing: -0.01em;
}

/* Grid & Fields */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.field {
  margin-bottom: 1.25rem;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}

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

.upload-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.upload-group input {
  flex: 1;
}

/* Inputs Refinement */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.2s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

/* Translation Button */
.input-with-action {
  position: relative;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.btn-xs {
  padding: 0.4rem 0.6rem;
  font-size: 0.7rem;
  white-space: nowrap;
}

/* List Items */
.admin-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.admin-item {
  background: var(--bg);
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: transform 0.2s;
}

.admin-item:hover {
  transform: translateX(4px);
  border-color: var(--accent);
}

.item-info {
  display: flex;
  flex-direction: column;
}

.item-title { font-weight: 600; font-size: 0.95rem; }
.item-meta { font-size: 0.8rem; color: var(--text-muted); }

.item-actions {
  display: flex;
  gap: 0.5rem;
}

/* Modals */
.admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none; /* JS will toggle flex */
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease-out;
}

#confirmOverlay {
  z-index: 1100;
  backdrop-filter: none; /* Don't double-blur */
  background: rgba(0, 0, 0, 0.2);
}

.admin-save-area {
  position: sticky;
  bottom: 0;
  margin: 3rem -2.5rem -2.5rem -2.5rem;
  padding: 1.25rem 2.5rem;
  background: rgba(var(--bg-rgb, 255, 255, 255), 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  z-index: 50;
}

.admin-modal {
  background: var(--bg);
  width: 100%;
  max-width: 600px;
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.modal-sm { max-width: 400px; }

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

.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1.25rem 1.5rem; border-top: 1px solid var(--border); }

.close-modal {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* Switches & Toggles */
.flex-title-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.switch-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
}

/* Responsive */
@media (max-width: 1024px) {
  :root { --sb-w: 80px; }
  .logo-text, .sidebar-link span, .sidebar-divider { display: none; }
  .sidebar-link { justify-content: center; padding: 1rem; }
  .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .admin-sidebar { display: none; }
  .admin-toolbar { padding: 0 1rem; }
  .admin-page-content { padding: 1.5rem; }
}
