:root {
  --bg: #0b0f19;
  --sidebar-bg: #0f172a;
  --card-bg: rgba(22, 28, 45, 0.6);
  --card-border: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(15, 23, 42, 0.8);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #8b5cf6;
  --accent-rgb: 139, 92, 246;
  --accent-hover: #7c3aed;
  --accent-glow: rgba(139, 92, 246, 0.15);
  --logo-start: #ffffff;
  
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --danger-border: rgba(239, 68, 68, 0.2);
  
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --success-border: rgba(16, 185, 129, 0.2);
  
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --warning-border: rgba(245, 158, 11, 0.2);

  --font: 'Outfit', -apple-system, sans-serif;
  --sidebar-width: 260px;
}

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(var(--accent-rgb), 0.04) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(var(--accent-rgb), 0.02) 0%, transparent 50%);
  background-attachment: fixed;
}

/* Sidebar Layout */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  padding: 2rem 1.5rem;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--logo-start) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-brand span {
  font-size: 0.75rem;
  background: var(--accent-glow);
  color: var(--accent);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid rgba(var(--accent-rgb), 0.3);
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  cursor: pointer;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.sidebar-link.active {
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--text);
  border: 1px solid rgba(var(--accent-rgb), 0.15);
  box-shadow: inset 0 0 10px rgba(var(--accent-rgb), 0.05);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
}

.logout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border-radius: 10px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: var(--danger-bg);
  color: #f87171;
}

/* Main Dashboard Area */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 2.5rem 3rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: calc(100% - var(--sidebar-width));
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2.5rem;
}

.dashboard-title h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
}

.dashboard-title p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* Dashboard Sections */
.dashboard-section {
  display: none;
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.dashboard-section.active {
  display: block;
}

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

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: 0 10px 20px rgba(0,0,0,0.15);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  background: var(--accent-glow);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  border: 1px solid rgba(var(--accent-rgb), 0.15);
}

.stat-icon.green {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}

.stat-icon.amber {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning-border);
}

.stat-info .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-info .stat-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

/* Panel Card */
.panel-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 15px 30px rgba(0,0,0,0.2);
  margin-bottom: 2rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

/* Forms & Fields */
.form-group {
  margin-bottom: 1.25rem;
}

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

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

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: var(--input-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.25rem;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  color: #ffffff;
}

.btn-primary {
  background: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 15px var(--accent-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.2);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* Sleek Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th, td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
}

th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

tr:hover td {
  background: rgba(255, 255, 255, 0.01);
}

/* Status Pills */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-published {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success);
}

.badge-draft {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning);
}

/* Action Groups in Tables */
.actions-cell {
  display: flex;
  gap: 0.5rem;
}

/* Dialog Modals */
dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  border: none;
  background: transparent;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

dialog[open] {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

dialog::backdrop {
  background: rgba(5, 7, 13, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.dialog-box {
  background: #0f172a;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  width: 90%;
  max-width: 650px;
  padding: 2.25rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  position: relative;
  display: flex;
  flex-direction: column;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dialog-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.dialog-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50px;
  transition: all 0.2s ease;
}

.dialog-close:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

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

.toast {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  color: var(--text);
  font-weight: 500;
  font-size: 0.9rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 250px;
  max-width: 350px;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  position: relative;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 10px 0 0 10px;
}

.toast-success::before {
  background-color: var(--success);
}

.toast-error::before {
  background-color: var(--danger);
}

/* Toast Animations */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%) translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0) translateY(0);
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

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

/* Media Library styles */
.media-dropzone {
  border: 2px dashed var(--card-border);
  background: rgba(15, 23, 42, 0.4);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  margin-bottom: 2rem;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.media-dropzone.dragover {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
  box-shadow: 0 0 20px var(--accent-glow);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1.5rem;
}

.media-item-placeholder {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.media-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
  overflow: hidden;
}

.media-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(var(--accent-rgb), 0.3);
  transform: translateY(-2px);
}

.media-item-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-item-icon.folder {
  color: var(--accent);
  filter: drop-shadow(0 4px 6px var(--accent-glow));
}

.media-item-icon.file {
  color: #f87171; /* PDF red icon */
  filter: drop-shadow(0 4px 6px rgba(239, 68, 68, 0.15));
}

.media-item-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}

.media-item-size {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.media-item-delete {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 24px;
  height: 24px;
  border-radius: 50px;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s ease;
  z-index: 10;
}

.media-item:hover .media-item-delete {
  opacity: 1;
}

.media-item-delete:hover {
  background: var(--danger);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

/* Breadcrumb nav links */
.media-breadcrumb {
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s ease;
  font-size: 1.15rem;
  font-weight: 600;
}

.media-breadcrumb:hover {
  color: var(--text);
  text-decoration: underline;
}

.media-breadcrumb-sep {
  color: rgba(255, 255, 255, 0.15);
  margin: 0 0.5rem;
}

.media-breadcrumb-active {
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 600;
}

/* Dialog Two-Column Grid */
.dialog-grid {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 1.5rem;
  text-align: left;
}
@media (max-width: 768px) {
  .dialog-grid {
    grid-template-columns: 1fr;
  }
}

.sidebar-help-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.dialog-folders-list {
  background: var(--input-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 380px;
  overflow-y: auto;
}

.draggable-folder-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: grab;
  user-select: none;
  transition: all 0.2s ease;
  text-align: left;
}

.draggable-folder-item:hover {
  background: rgba(var(--accent-rgb), 0.06);
  border-color: rgba(var(--accent-rgb), 0.25);
}

.draggable-folder-item:active {
  cursor: grabbing;
}

.draggable-folder-item svg {
  color: var(--accent);
  flex-shrink: 0;
}

.draggable-folder-item .folder-name-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.folder-widget-placeholder {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 1.5rem 0;
}

/* Responsive Admin panel */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
    max-width: 100%;
    padding: 1.5rem;
  }
}

/* Theme selection cards */
.theme-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}

.theme-card-option {
  cursor: pointer;
  display: block;
  position: relative;
}

.theme-radio-hidden {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-card-content {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 120px;
  justify-content: space-between;
  overflow: hidden;
  position: relative;
}

.theme-card-option:hover .theme-card-content {
  border-color: rgba(var(--accent-rgb), 0.4);
  background: rgba(255, 255, 255, 0.04);
  transform: translateY(-2px);
}

.theme-radio-hidden:checked + .theme-card-content {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
  box-shadow: 0 0 15px var(--accent-glow);
}

.theme-card-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.theme-preview-dots {
  display: flex;
  gap: 4px;
}

.theme-preview-dots span {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
}

.theme-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.theme-card-preview-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.25rem;
}

.preview-text {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.midnight-violet-preview .preview-mini-glass {
  background: rgba(17, 24, 39, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 4px 8px;
  color: #8b5cf6;
  backdrop-filter: blur(4px);
}

.cyberpunk-preview .preview-mini-cyber {
  background: #0c0c0e;
  border: 1px solid #ff0055;
  padding: 4px 8px;
  color: #00f0ff;
  font-family: monospace;
}

.emerald-preview .preview-mini-emerald {
  background: rgba(8, 22, 15, 0.7);
  border: 1px solid rgba(52, 211, 153, 0.2);
  border-radius: 8px;
  padding: 4px 8px;
  color: #10b981;
}

/* ---------------------------------------------------- */
/* Theme Overrides for Admin Panel */
/* ---------------------------------------------------- */

/* Cyberpunk Theme admin overrides */
:root.theme-cyberpunk {
  --bg: #08080a;
  --sidebar-bg: #0c0c0e;
  --card-bg: #141416;
  --card-border: rgba(0, 240, 255, 0.25);
  --input-bg: #08080a;
  --text: #f1f5f9;
  --text-muted: #64748b;
  --font: 'Share Tech Mono', monospace;
  --logo-start: #00f0ff;
  --bg-pattern: linear-gradient(rgba(0, 240, 255, 0.02) 1px, transparent 1px),
                linear-gradient(90deg, rgba(0, 240, 255, 0.02) 1px, transparent 1px);
}

:root.theme-cyberpunk body {
  background-size: 30px 30px;
}

:root.theme-cyberpunk .panel-card,
:root.theme-cyberpunk .sidebar,
:root.theme-cyberpunk .btn,
:root.theme-cyberpunk input,
:root.theme-cyberpunk textarea,
:root.theme-cyberpunk select,
:root.theme-cyberpunk dialog,
:root.theme-cyberpunk .dialog-box {
  border-radius: 0px !important;
}

:root.theme-cyberpunk .panel-card {
  border: 1px solid var(--accent) !important;
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.1);
}

/* Emerald Theme admin overrides */
:root.theme-emerald {
  --bg: #030c08;
  --sidebar-bg: #05160e;
  --card-bg: rgba(8, 22, 15, 0.75);
  --card-border: rgba(52, 211, 153, 0.15);
  --input-bg: rgba(3, 12, 8, 0.8);
  --text: #e6f4ea;
  --text-muted: #8cd6a7;
  --logo-start: #ffffff;
  --bg-pattern: radial-gradient(circle at 20% 30%, rgba(16, 185, 129, 0.06) 0%, transparent 45%),
                radial-gradient(circle at 80% 70%, rgba(52, 211, 153, 0.04) 0%, transparent 50%);
}

:root.theme-emerald .panel-card,
:root.theme-emerald .dialog-box {
  border-radius: 24px !important;
}

:root.theme-emerald .btn,
:root.theme-emerald input,
:root.theme-emerald textarea,
:root.theme-emerald select {
  border-radius: 12px !important;
}
