@import url('https://fonts.googleapis.com/icon?family=Material+Icons');
:root {
  --bg: #0d0d12;
  --surface: #161622;
  --surface-alt: #1a1a2e;
  --text: #ffffff;
  --muted: #a1a1aa; /* Neutral muted for modern look */
  --line: rgba(255, 255, 255, 0.05);
  --brand: #e34046;
  --brand-2: #c1272d;
  --primary: #e34046; /* Authentic Brand Red */
  --primary-hover: #ffffff; 
  --primary-glow: rgba(227, 64, 70, 0.25);
  --danger: #ef4444;
  --success: #10b981;
  --info: #e34046;
  --control-h: 44px;
  --radius: 14px;
  --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.24);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap&subset=vietnamese');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');

/* Material Icons Force Fix */
.material-icons {
  font-family: 'Material Icons' !important;
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -moz-osx-font-smoothing: grayscale;
  width: 1em; height: 1em;
  overflow: hidden; /* Prevent text leakage if font fails */
  vertical-align: middle;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  background: radial-gradient(circle at 15% 10%, #2b0d12 0%, #121216 36%, #09090b 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* ===== App Shell ===== */
.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  background: linear-gradient(180deg, #28070b, #5f131a 55%, #8a1d26);
  color: white;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  padding: 32px 24px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: brightness(0) invert(1); /* Force white logo if needed, or remove if already white */
}
.sidebar-header h1 { 
  font-size: 18px; 
  margin: 0; 
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #fff, rgba(255,255,255,0.7));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sidebar-nav {
  flex: 1;
  padding: 0 16px;
  overflow-y: auto;
}
.sidebar-bottom {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.1);
}
.sidebar a.user-profile {
  display: grid !important;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  margin-bottom: 8px;
  transition: all 0.2s ease;
  text-decoration: none;
}
.sidebar a.user-profile:hover {
  background: rgba(255, 255, 255, 0.08);
}
.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}
.user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.user-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  margin-bottom: 2px;
}
.user-role {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  display: block;
}
.btn-logout {
  width: 100%;
  justify-content: flex-start !important;
  background: transparent !important;
  border: 1px solid rgba(255,255,255,0.08) !important;
  color: rgba(255,255,255,0.6) !important;
}
.btn-logout:hover {
  background: rgba(239, 68, 68, 0.1) !important;
  color: #ef4444 !important;
  border-color: rgba(239, 68, 68, 0.2) !important;
}
.sidebar a {
  display: block;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}
.sidebar a:hover { background: rgba(255, 255, 255, 0.12); }
.sidebar a.active {
  background: rgba(255, 255, 255, 0.18);
  font-weight: 600;
  box-shadow: inset 3px 0 0 #fff;
}

/* ===== Main Area ===== */
.main { padding: 24px; min-width: 0; }

/* ===== Topbar ===== */
.topbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.topbar .breadcrumb {
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar .breadcrumb a {
  color: var(--brand); /* Direct brand red */
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s;
  border-bottom: 1px solid transparent;
}

.topbar .breadcrumb a:hover {
  border-bottom-color: var(--brand);
}

.topbar .breadcrumb span {
  color: #fff;
  font-weight: 600;
}
.topbar .topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ===== Page Header ===== */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
}

/* ===== Buttons ===== */
button, .btn {
  border: 0;
  border-radius: var(--radius);
  min-height: var(--control-h);
  padding: 10px 16px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  gap: 6px;
  transition: all 0.2s ease;
}
.btn-primary, button.primary {
  background: var(--primary);
  box-shadow: 0 4px 15px var(--primary-glow);
}
.btn-primary:hover, button.primary:hover {
  background: #ff575d;
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-secondary, button.secondary {
  background: #2a2a31;
  color: var(--text);
  border: 1px solid #3a3a43;
}
.btn-secondary:hover, button.secondary:hover {
  background: #353540;
  border-color: #4a4a55;
}
.btn-danger, button.danger { background: var(--danger); }
.btn-danger:hover, button.danger:hover { background: #ff6b73; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: rgba(255,255,255,0.05); color: var(--text); }

.btn-sm {
  padding: 6px 12px;
  min-height: 32px;
  font-size: 13px;
}

.btn-icon {
  width: 32px; height: 32px;
  min-height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.btn-icon:hover { background: rgba(255,255,255,0.08); color: var(--text); transform: none; }
.btn-icon-edit:hover { color: var(--info); }
.btn-icon-copy:hover { color: #22d3ee; }
.btn-icon-delete:hover { color: var(--danger); }

/* ===== Inputs ===== */
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: var(--control-h);
  padding: 10px 14px;
  margin-bottom: 0;
  font: inherit;
  font-size: 14px;
  background: rgba(0,0,0,0.3);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(193,39,45,0.15);
}
input::placeholder, textarea::placeholder { color: rgba(255,255,255,0.4); }
textarea { min-height: 100px; resize: vertical; }
select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.6)' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
}
select option { background: var(--surface); color: var(--text); }

/* Language Tabs Logic (Critical for Layout) */
.lang-content-section {
  display: none !important;
  animation: tabFadeIn 0.3s ease;
}
.lang-content-section.active {
  display: block !important;
}
@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Modal Overlay Fix */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.active {
  display: flex !important;
}

.modal-content-lg { width: 100%; max-width: 1100px; height: 90vh; }
.modal-content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-close {
  position: absolute;
  top: 16px; right: 20px;
  background: none;
  border: none;
  font-size: 28px;
  color: var(--muted);
  cursor: pointer;
  z-index: 10;
}
.modal-close:hover { color: #fff; }

/* ===== Form Groups ===== */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-group small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ===== Data Table ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
/* Strict Percentage-based Layout with Alignment Rules */
.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.data-table th, .data-table td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-table th {
  text-align: center !important; /* All headers centered */
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(0,0,0,0.15);
}

/* Specific Content Alignments */
.col-checkbox { width: 5%; text-align: center !important; }
.col-thumb { width: 10%; text-align: center !important; }
.col-title { width: 22%; text-align: left !important; }
.col-slug { width: 13%; text-align: left !important; color: var(--muted); font-size: 13px; font-family: var(--font-mono, monospace); }
.col-category { width: 15%; text-align: center !important; }
.col-status { width: 10%; text-align: center !important; }
.col-date { width: 15%; text-align: center !important; }
.col-actions { width: 10%; text-align: right !important; }

/* Styling refinements */
.post-title-link {
  font-weight: 600;
  color: #fff !important;
  text-decoration: none;
  font-size: 14px;
}
.post-title-link:hover { text-decoration: underline; }
.col-slug { opacity: 0.7; }
.post-title-link:hover {
  text-decoration: underline;
}
.post-slug-subtext {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-mono, monospace);
  opacity: 0.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}


/* Compact checkboxes — match media manager style */
.data-table input[type="checkbox"],
.batch-actions input[type="checkbox"] {
  width: 16px !important;
  height: 16px !important;
  min-height: 16px !important;
  margin: 0 !important;
  padding: 0 !important;
  cursor: pointer;
  accent-color: var(--brand);
  appearance: checkbox;
  -webkit-appearance: checkbox;
  display: block;
  border: none;
  border-radius: 3px;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Thumbnails */
.post-row-thumb {
  width: 52px; height: 52px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
}
.post-row-thumb-placeholder {
  width: 52px; height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
  margin: 0 auto;
}

/* ===== Toggle Switch ===== */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  margin-bottom: 0 !important;
  height: 20px;
  line-height: 0;
  font-size: 0;
}
.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.toggle-slider,
.slider {
  display: inline-block;
  width: 36px; height: 20px;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  position: relative;
  transition: background 0.25s;
}
.toggle-slider::after,
.slider::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 2px; top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle-switch input:checked + .toggle-slider,
.toggle-switch input:checked + .slider { background: var(--success); }
.toggle-switch input:checked + .toggle-slider::after,
.toggle-switch input:checked + .slider::after { transform: translateX(16px); }
.toggle-switch input:focus-visible + .toggle-slider,
.toggle-switch input:focus-visible + .slider { box-shadow: 0 0 0 2px var(--brand); }

/* Posts list uses .slider; force single knob to avoid duplicate circle from mixed legacy rules */
.data-table .toggle-switch .slider::before {
  content: none !important;
  display: none !important;
}

.data-table .toggle-switch {
  height: 20px;
  line-height: 0;
}

.data-table .toggle-switch .slider::after {
  top: 1px;
}

/* ===== Batch Actions Bar ===== */
.batch-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: rgba(73,69,255,0.08);
  border: 1px solid rgba(73,69,255,0.2);
  border-radius: 12px;
  animation: batchSlideIn 0.25s ease;
}
@keyframes batchSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.batch-actions .batch-count {
  font-weight: 600;
  color: #8b8bff;
  margin-right: 8px;
}

/* ===== Filter Bar ===== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.filter-bar select {
  width: auto;
  min-width: 140px;
  min-height: 36px;
  padding: 6px 32px 6px 12px;
  font-size: 13px;
}
.filter-bar .btn { min-height: 36px; }

/* ===== Message / Alerts ===== */
.message {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}
.message-success { background: rgba(50,128,72,0.2); color: #7dd89a; border: 1px solid rgba(50,128,72,0.3); }
.message-error { background: rgba(242,84,91,0.15); color: #f28b82; border: 1px solid rgba(242,84,91,0.25); }
.message a { color: inherit; font-weight: 600; }

/* ===== Save Toast ===== */
.save-toast {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  background: var(--success);
  color: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  font-weight: 600;
  animation: toastIn 0.35s cubic-bezier(0.18,0.89,0.32,1.28);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.save-toast-icon {
  width: 24px; height: 24px;
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* ===== Post Editor Layout ===== */
.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: flex-start;
}

.editor-main {
  flex: 1;
  min-width: 0;
}

.editor-sidebar {
  width: 320px;
  flex-shrink: 0;
}
.editor-main {
  flex: 1;
  min-width: 0;
}
.editor-sidebar {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.editor-sidebar .card { padding: 18px; }
.editor-sidebar .card h3 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* ===== Quill Editor Dark Theme ===== */
.quill-block { margin-bottom: 1.5rem; }
.quill-block label { display: block; margin-bottom: 8px; }

/* ===== Professional Multitab Language Switcher ===== */
.language-tabs {
  display: flex !important;
  flex-direction: row !important; /* Explicitly horizontal */
  background: rgba(0, 0, 0, 0.2) !important;
  border-radius: 12px 12px 0 0 !important;
  margin: -24px -24px 32px -24px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
  padding: 0 !important;
  overflow: hidden;
  width: calc(100% + 48px) !important;
}

.lang-tab {
  flex: 1;
  padding: 16px 24px !important;
  cursor: pointer;
  font-size: 14px !important;
  font-weight: 700 !important;
  color: rgba(255, 255, 255, 0.3) !important;
  text-align: center !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px !important;
  transition: all 0.2s ease !important;
  border-bottom: 3px solid transparent !important;
  background: transparent !important;
  border-right: 1px solid rgba(255, 255, 255, 0.03) !important;
}

.lang-tab.active {
  background: rgba(255, 255, 255, 0.03) !important;
  color: #fff !important;
  border-bottom-color: var(--primary) !important;
}

.lang-tab:hover:not(.active) {
  background: rgba(255, 255, 255, 0.05) !important;
  color: #fff !important;
}

/* ===== Premium Form Control Redesign ===== */
.form-group {
  margin-bottom: 24px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.3);
  margin-bottom: 10px;
  transition: color 0.2s;
}

.form-group:focus-within label {
  color: var(--primary);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.2) !important;
  border: 1px solid rgba(255, 255, 255, 0.05) !important;
  border-radius: 12px !important;
  color: #e2e8f0 !important;
  padding: 14px 18px !important;
  font-size: 14px !important;
  font-family: inherit;
  transition: all 0.25s ease !important;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05) !important;
}

.slug-preview {
  display: flex !important;
  align-items: center !important;
  font-size: 12px !important;
  margin-top: 10px !important;
  padding: 6px 14px !important;
  color: rgba(255, 255, 255, 0.3) !important;
  background: rgba(255,255,255,0.03) !important;
  border-radius: 8px !important;
  gap: 4px;
  border: 1px dashed rgba(255,255,255,0.05) !important;
}

.slug-base {
  color: #ffffff !important; /* Pure white as requested */
  user-select: none !important;
  opacity: 0.8; /* Slight transparency for depth, but still very bright */
}

.slug-input {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  color: #ffffff !important; /* Pure white by default */
  font-family: inherit !important;
  font-weight: 600 !important;
  padding: 0 !important;
  width: auto !important;
  flex: 1 !important;
  min-width: 50px !important;
  outline: none !important;
  box-shadow: none !important;
  cursor: text !important;
  transition: all 0.2s ease !important;
}

.slug-input:focus {
  background: transparent !important;
  color: var(--primary) !important; /* Glow primary blue on focus */
}

.edit-icon {
  font-size: 14px !important;
  opacity: 0.3;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  background: rgba(0, 0, 0, 0.3) !important;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 4px rgba(73, 69, 255, 0.1), inset 0 2px 4px rgba(0, 0, 0, 0.1) !important;
  outline: none !important;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

.quill-editor .ql-editor { 
  min-height: 400px; 
  color: #e2e8f0; 
  font-size: 15px; 
  line-height: 1.8; 
  padding: 24px !important;
}

.quill-editor .ql-editor.ql-blank::before { 
  color: rgba(255, 255, 255, 0.2) !important; 
  font-style: normal !important; 
  left: 24px !important; /* Sync with padding-left */
  top: 24px !important;  /* Sync with padding-top */
  pointer-events: none !important;
}
.quill-editor .ql-editor p, .quill-editor .ql-editor li { color: #e4e4eb; }
/* ===== Quill Toolbar Premium Fix ===== */
.ql-toolbar.ql-snow {
  background: var(--surface) !important;
  border: 1px solid rgba(255, 255, 255, 0.05) !important;
  border-bottom: none !important;
  border-radius: 12px 12px 0 0 !important;
  padding: 10px 14px !important;
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.ql-container.ql-snow {
  background: rgba(0, 0, 0, 0.15) !important;
  border: 1px solid rgba(255, 255, 255, 0.05) !important;
  border-radius: 0 0 12px 12px !important;
  transition: border-color 0.3s, box-shadow 0.3s;
}

/* Premium Focus State */
.ql-container.ql-snow:focus-within {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 4px rgba(73, 69, 255, 0.1) !important;
}

.ql-toolbar.ql-snow .ql-formats {
  margin-right: 8px !important;
  padding-right: 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  display: flex !important;
  align-items: center;
  gap: 2px;
}
.ql-toolbar.ql-snow .ql-formats:last-child { border-right: none; }

/* Restoring SVGs and making them look premium */
.ql-snow.ql-toolbar button svg,
.ql-snow .ql-toolbar button svg {
  display: block !important;
  width: 18px !important;
  height: 18px !important;
  margin: 0 auto !important;
}

.ql-snow.ql-toolbar .ql-stroke {
  stroke: #cbd5e1 !important; /* Light slate stroke */
  stroke-width: 2px !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
}

.ql-snow.ql-toolbar .ql-fill {
  fill: #cbd5e1 !important;
}

.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-stroke {
  stroke: #4945ff !important; /* Primary color on hover */
}

.ql-snow.ql-toolbar button:hover .ql-fill,
.ql-snow.ql-toolbar button.ql-active .ql-fill {
  fill: #4945ff !important;
}

.ql-snow.ql-toolbar .ql-picker-label svg .ql-stroke {
  stroke: rgba(255,255,255,0.5) !important;
}

/* Individual Buttons Polish */
.ql-snow.ql-toolbar button {
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  border-radius: 6px !important;
  border: 1px solid transparent !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s !important;
  background: transparent !important;
}

.ql-snow.ql-toolbar button:hover,
.ql-snow.ql-toolbar button.ql-active {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

/* Hide fallback Material Icons if any remain */
.ql-toolbar button .material-icons {
  display: none !important;
}

/* Custom Buttons Expansion */
.ql-image-custom {
  margin-left: 4px;
}
.btn-html-toggle {
  height: 30px !important;
  padding: 0 12px !important;
  font-size: 11px !important;
  letter-spacing: 0.5px;
  background: rgba(255,255,255,0.05) !important;
  border: 1px solid var(--line) !important;
  color: var(--muted) !important;
  margin-left: 8px !important;
}
.btn-html-toggle:hover {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}/* Dropdown Options List - Bulletproof Visibility */
.ql-snow.ql-toolbar .ql-picker-options,
.ql-snow .ql-toolbar .ql-picker-options {
  background: #1e1e36 !important; /* Dark Surface */
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7) !important;
  border-radius: 12px !important;
  padding: 6px !important;
  z-index: 999999 !important; /* Extremely high z-index */
  margin-top: 4px !important;
  min-width: 150px !important;
  /* display is handled by Quill's .ql-expanded class */
}

.ql-snow.ql-toolbar .ql-picker-item,
.ql-snow .ql-toolbar .ql-picker-item {
  color: #e2e8f0 !important; /* Light Slate text */
  padding: 10px 14px !important;
  border-radius: 8px !important;
  font-size: 14px !important;
  font-family: var(--font) !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  transition: all 0.15s ease !important;
  background: transparent; /* Removed !important to allow inline background-colors */
  border: none !important;
  position: relative !important;
}

.ql-snow.ql-toolbar .ql-picker-item:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #ffffff !important;
}

/* Explicitly Handle Heading and Size Labels in the list */
.ql-snow.ql-toolbar .ql-picker.ql-header .ql-picker-item::before { 
  font-size: 14px !important; 
  color: #cbd5e1 !important; 
}
.ql-snow.ql-toolbar .ql-picker.ql-header .ql-picker-item:hover::before { 
  color: #fff !important; 
}

/* Override the built-in Quill label pseudo-elements that might be invisible */
/* Dropdown Labels (Heading, Size) */
.ql-snow.ql-toolbar .ql-picker.ql-header .ql-picker-label,
.ql-snow.ql-toolbar .ql-picker.ql-size .ql-picker-label {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding-left: 8px !important;
  padding-right: 4px !important;
  height: 100% !important;
  width: auto !important;
  min-width: 95px !important; /* Fixed width only for text pickers */
  color: #cbd5e1 !important;
  font-weight: 700 !important;
}

.ql-snow.ql-toolbar .ql-picker.ql-header .ql-picker-label::before,
.ql-snow.ql-toolbar .ql-picker.ql-size .ql-picker-label::before {
  color: #cbd5e1 !important;
  font-size: 13px !important;
  transition: color 0.2s !important;
}

.ql-snow.ql-toolbar .ql-picker.ql-header .ql-picker-label svg,
.ql-snow.ql-toolbar .ql-picker.ql-size .ql-picker-label svg {
  position: static !important;
  margin: 0 !important;
  width: 14px !important;
  height: 14px !important;
  filter: brightness(0) invert(1) !important;
}

/* Color/Background Picker (Square Style) */
.ql-snow.ql-toolbar .ql-color-picker .ql-picker-label,
.ql-snow.ql-toolbar .ql-background-picker .ql-picker-label {
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 6px !important;
  background: rgba(255, 255, 255, 0.03) !important;
}

.ql-snow.ql-toolbar .ql-color-picker .ql-picker-label svg,
.ql-snow.ql-toolbar .ql-background-picker .ql-picker-label svg {
  margin: 0 !important;
  width: 18px !important;
  height: 18px !important;
  filter: brightness(0) invert(1) !important;
}
.ql-snow.ql-toolbar .ql-picker.ql-header .ql-picker-item[data-value="1"]::before { content: 'Heading 1' !important; font-size: 18px !important; font-weight: 700 !important; }
.ql-snow.ql-toolbar .ql-picker.ql-header .ql-picker-item[data-value="2"]::before { content: 'Heading 2' !important; font-size: 16px !important; font-weight: 600 !important; }
.ql-snow.ql-toolbar .ql-picker.ql-header .ql-picker-item[data-value="3"]::before { content: 'Heading 3' !important; font-size: 14px !important; font-weight: 600 !important; }
.ql-snow.ql-toolbar .ql-picker.ql-header .ql-picker-item:not([data-value])::before { content: 'Paragraph' !important; font-weight: 400 !important; }

/* Font Size Labels in list */
.ql-snow.ql-toolbar .ql-picker.ql-size .ql-picker-item[data-value="small"]::before { content: 'Small' !important; font-size: 12px !important; }
.ql-snow.ql-toolbar .ql-picker.ql-size .ql-picker-item[data-value="large"]::before { content: 'Large' !important; font-size: 18px !important; }
.ql-snow.ql-toolbar .ql-picker.ql-size .ql-picker-item[data-value="huge"]::before { content: 'Huge' !important; font-size: 22px !important; }
.ql-snow.ql-toolbar .ql-picker.ql-size .ql-picker-item:not([data-value])::before { content: 'Normal' !important; font-size: 14px !important; }

/* Color/Background Picker UI Stabilization */
.ql-snow .ql-color-picker,
.ql-snow .ql-background-picker {
  width: 28px !important;
  height: 32px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.ql-snow.ql-toolbar .ql-color-picker .ql-picker-label,
.ql-snow.ql-toolbar .ql-background-picker .ql-picker-label {
  padding: 0 !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  border-radius: 6px !important;
  background: rgba(255,255,255,0.03) !important;
  width: 28px !important;
  height: 28px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.ql-snow.ql-toolbar .ql-color-picker .ql-picker-label svg,
.ql-snow.ql-toolbar .ql-background-picker .ql-picker-label svg {
  margin: 0 !important;
  filter: brightness(0) invert(1) !important; /* Make icon white */
}

.ql-snow .ql-color-picker .ql-picker-options,
.ql-snow .ql-background-picker .ql-picker-options {
  width: 152px !important;
  padding: 8px !important;
  background: #1e1e36 !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8) !important;
  /* Quill handles display: none/block by default. We only override when expanded. */
}

.ql-snow .ql-color-picker.ql-expanded .ql-picker-options,
.ql-snow .ql-background-picker.ql-expanded .ql-picker-options {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 4px !important;
}

.ql-snow .ql-color-picker .ql-picker-item,
.ql-snow .ql-background-picker .ql-picker-item {
  width: 16px !important;
  height: 16px !important;
  border-radius: 4px !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  padding: 0 !important;
  margin: 0 !important;
}

.ql-snow .ql-color-picker .ql-picker-item:hover,
.ql-snow .ql-background-picker .ql-picker-item:hover {
  border-color: #fff !important;
  transform: scale(1.1);
}

/* Tooltip & Link Editor Fixes */
.ql-snow .ql-tooltip {
  background: #252542 !important;
  border: 1px solid var(--line) !important;
  color: #fff !important;
  border-radius: 12px !important;
  box-shadow: 0 15px 50px rgba(0,0,0,0.6) !important;
  z-index: 10005 !important;
  padding: 10px 15px !important;
}
.ql-snow .ql-tooltip input[type=text] {
  background: rgba(0,0,0,0.2) !important;
  border: 1px solid var(--line) !important;
  color: #fff !important;
  border-radius: 6px !important;
  padding: 6px 10px !important;
}
.ql-snow .ql-tooltip .ql-action { color: var(--primary) !important; font-weight: 600 !important; }

/* Custom HEX Input - Compact & Pro (Fixing Overflow) */
.ql-snow .ql-picker-options .custom-hex-wrap.compact {
  box-sizing: border-box !important;
  width: 100% !important;
  display: flex !important;
  align-items: center !important;
  padding: 4px 8px !important;
  margin-top: 4px !important;
  background: rgba(255,255,255,0.06) !important;
  border-top: 1px solid rgba(255,255,255,0.1) !important;
  border-radius: 0 0 12px 12px !important;
  gap: 6px !important;
  height: 30px !important;
  overflow: hidden !important;
}

.ql-snow .ql-picker-options .hex-preview {
  flex-shrink: 0 !important;
  width: 14px !important;
  height: 14px !important;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
}

.ql-snow .ql-picker-options .hex-label {
  flex-shrink: 0 !important;
  color: var(--primary) !important;
  font-weight: 800 !important;
  font-size: 13px !important;
  margin-right: 0 !important;
}

.ql-snow .ql-picker-options .hex-input {
  box-sizing: border-box !important;
  flex-grow: 1 !important;
  min-width: 0 !important;
  background: transparent !important;
  border: none !important;
  color: #fff !important;
  font-family: "Fira Code", monospace !important;
  font-size: 12px !important;
  outline: none !important;
  padding: 0 !important;
  text-transform: uppercase !important;
}

/* Recent Colors Row Styles */
.ql-snow .ql-picker-options .recent-colors-row {
  box-sizing: border-box !important;
  width: 100% !important;
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 4px !important;
  padding: 6px 0 2px 0 !important; /* Remove horizontal padding to align with parent grid */
  border-top: 1px solid rgba(255,255,255,0.05) !important;
  margin-top: 4px !important;
}

.ql-snow .ql-picker-options .recent-colors-row .ql-picker-item {
  width: 16px !important;
  height: 16px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 4px !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
}



/* HTML source toggle */
.quill-html-wrap { margin-bottom: 1rem; }
.quill-html-source {
  width: 100%;
  min-height: 200px;
  font-family: "Fira Code", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.5;
  background: rgba(0,0,0,0.4);
  color: #a8e6cf;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

/* ===== SEO Section ===== */
.advance-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.advance-block summary {
  cursor: pointer;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  background: rgba(0,0,0,0.15);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.advance-block summary::before {
  content: '▶';
  font-size: 10px;
  transition: transform 0.2s;
  color: var(--muted);
}
.advance-block[open] summary::before { transform: rotate(90deg); }
.advance-block summary::-webkit-details-marker { display: none; }
.advance-fields { padding: 18px; }

/* SEO Preview */
.seo-preview {
  background: #1a1a2e;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 16px 20px;
  margin-top: 16px;
}
.seo-preview-label {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  color: #1a0dab;
  font-family: arial, sans-serif;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  margin-top: 15px;
}
.seo-preview-url {
  font-size: 14px;
  color: #202124;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.seo-preview-title {
  font-size: 20px;
  font-weight: 400;
  margin-bottom: 4px;
  text-decoration: none;
  display: block;
  line-height: 1.3;
}
.seo-preview-title:hover {
  text-decoration: underline;
}
.seo-preview-desc {
  font-size: 14px;
  color: #4d5156;
  line-height: 1.58;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Character counter */
.char-counter-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}
.char-counter {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 4px;
}
.char-counter.warning { color: #ffab00; }
.char-counter.danger { color: var(--danger); }

/* Sidebar Widgets (Cards) */
.sidebar-widget {
  background: var(--surface-alt);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 20px;
  margin-bottom: 20px;
}
.widget-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Featured Image Preview */
.featured-image-preview {
  width: 100%;
  aspect-ratio: 16/9;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border: 2px dashed rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.featured-image-preview:hover { border-color: var(--primary); }
.featured-image-preview img { width: 100%; height: 100%; object-fit: cover; }
.featured-image-preview .placeholder-icon { font-size: 32px; color: rgba(255, 255, 255, 0.15); }

/* Tag Chips */
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.tag-chip {
  background: rgba(73, 69, 255, 0.1);
  color: var(--primary);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(73, 69, 255, 0.2);
}
.tag-chip-remove {
  cursor: pointer;
  opacity: 0.6;
  font-size: 16px;
}
.tag-chip-remove:hover { opacity: 1; }
.char-counter-bar {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}
.char-counter-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.2s, background 0.2s;
  background: var(--success);
}
.char-counter-fill.warning { background: #f59e0b; }
.char-counter-fill.danger { background: var(--danger); }
.char-counter-text {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* ===== Media Picker ===== */
.input-with-btn {
  display: flex;
  gap: 8px;
  align-items: center;
}
.input-with-btn input { flex: 1; min-width: 0; }
.input-with-btn .btn { flex-shrink: 0; }

/* Featured Image Preview */
.featured-image-preview {
  margin-top: 8px;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  max-width: 100%;
}
.featured-image-preview img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: cover;
  border-radius: 8px;
}
.featured-image-preview .clear-image {
  position: absolute;
  top: 6px; right: 6px;
  width: 28px; height: 28px;
  min-height: 28px;
  padding: 0;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border-radius: 50%;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(6px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal.active { opacity: 1; pointer-events: auto; }
.modal-content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  width: 90vw;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  transform: scale(0.92) translateY(16px);
  transition: transform 0.3s cubic-bezier(0.18,0.89,0.32,1.28);
}
.modal.active .modal-content { transform: scale(1) translateY(0); }
.modal-content-lg { max-width: 800px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}
.modal-header h3 { margin: 0; font-size: 16px; font-weight: 700; }
.close-modal {
  width: 32px; height: 32px;
  min-height: 32px;
  padding: 0;
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 8px;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.close-modal:hover { background: rgba(255,255,255,0.15); color: #fff; }
.modal-body { padding: 24px; }

/* Media picker grid */
.media-picker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.media-picker-actions select {
  width: auto;
  min-width: 140px;
  min-height: 36px;
  padding: 6px 32px 6px 12px;
  font-size: 13px;
}
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
}
.media-item {
  background: var(--surface-alt);
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s;
}
.media-item:hover { border-color: var(--brand); transform: translateY(-2px); }
.media-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}
.media-item-name {
  padding: 6px 8px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-item-icon {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  background: rgba(0,0,0,0.15);
}

/* Import URL */
.import-url-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}
.import-url-wrap input {
  width: 200px;
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13px;
}

/* ===== Image Edit Modal ===== */
.image-align-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.image-align-row .btn { flex: 1; }
.image-size-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.image-size-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  text-transform: none;
  font-weight: 500;
}
.image-size-row input[type="number"] {
  width: 80px;
  min-height: 36px;
  padding: 6px 8px;
  font-size: 13px;
}
.image-keep-ratio { white-space: nowrap; }
.image-keep-ratio input[type="checkbox"] { width: auto; min-height: auto; margin-right: 4px; }

.image-edit-hint {
  position: fixed;
  z-index: 9999;
  background: var(--brand);
  color: #fff;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  animation: hintPop 0.2s ease;
}
@keyframes hintPop {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* ===== Tag Chips ===== */
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(73,69,255,0.12);
  border: 1px solid rgba(73,69,255,0.25);
  border-radius: 100px;
  font-size: 12px;
  color: #8b8bff;
}
.tag-chip-remove {
  width: 18px; height: 18px;
  min-height: 18px;
  padding: 0;
  background: transparent;
  border: none;
  color: rgba(139,139,255,0.6);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.tag-chip-remove:hover { color: #fff; background: rgba(139,139,255,0.3); }

/* Tag Suggestions */
.tag-suggestions {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
  width: 100%;
}
.tag-suggestion {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background 0.1s;
}
.tag-suggestion:hover { background: rgba(255,255,255,0.08); }

/* ===== Form Actions ===== */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 15% 10%, #4c0910 0%, #1c0a0d 36%, #09090b 100%);
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.75)),
    url('/admin/assets/login-bg.webp');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  padding: 20px;
}
.login-card {
  width: min(440px, 100%);
  background: rgba(22, 22, 34, 0.85);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 40px;
  box-shadow: 
    0 4px 24px -1px rgba(0, 0, 0, 0.2),
    0 25px 50px -12px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  animation: loginCardIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.login-brand { display: grid; place-items: center; margin-bottom: 24px; }
.login-logo { width: min(220px, 80%); height: auto; object-fit: contain; filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3)); }
.login-card h1 { 
  font-size: 28px; 
  font-weight: 900; 
  margin: 0 0 8px; 
  text-align: center;
  background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,0.7) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-card p { text-align: center; color: var(--muted); margin: 0 0 32px; font-size: 15px; font-weight: 500; }

.login-form .form-group { margin-bottom: 20px; }
.login-form label { 
  font-size: 13px; 
  font-weight: 700; 
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.4); 
  display: block;
  margin-bottom: 8px;
  margin-left: 4px;
  transition: color 0.3s;
}
.login-form .form-group:focus-within label { color: var(--brand); }

.login-form input {
  height: 52px;
  background: rgba(0, 0, 0, 0.3) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 16px !important;
  padding: 0 18px !important;
  font-size: 15px !important;
  transition: all 0.3s ease !important;
  color: #fff !important;
}
.login-form input:focus {
  background: rgba(0, 0, 0, 0.5) !important;
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 4px rgba(227, 64, 70, 0.1) !important;
  outline: none;
}
.login-actions button {
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.login-actions button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(227, 64, 70, 0.3);
}
.login-actions button:active {
  transform: translateY(0);
}

/* ===== Stats Grid ===== */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { background: var(--surface-alt); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.stat h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.stat p { margin: 0; font-size: 28px; font-weight: 700; color: var(--brand); }

/* ===== Alert (legacy) ===== */
.hidden { display: none; }
.alert { padding: 10px 12px; border-radius: var(--radius); margin-bottom: 10px; font-size: 14px; }
.alert.success { background: #123324; color: #84f0b2; border: 1px solid #1f6f49; }
.alert.error { background: #3b1318; color: #ffb4ba; border: 1px solid #7d202a; }

/* ===== Table (legacy compat) ===== */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  font-size: 14px;
}
.table th { color: var(--muted); font-weight: 600; }

/* ===== Image Picker (legacy) ===== */
.image-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 15px;
}
.image-picker .preview-box {
  width: 100%;
  max-width: 300px;
  aspect-ratio: 16/9;
  background: var(--surface-alt);
  border: 1px dashed var(--muted);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: border-color 0.2s;
}
.image-picker .preview-box:hover { border-color: var(--brand); }
.image-picker .preview-box img { width: 100%; height: 100%; object-fit: contain; }
.image-picker .preview-box .placeholder { color: var(--muted); font-size: 14px; position: absolute; }
.image-picker .actions { display: flex; gap: 8px; }

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  .editor-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
  }

  .editor-sidebar {
    width: 300px;
  }
}

@media (max-width: 860px) {
  .editor-layout {
    grid-template-columns: 1fr;
  }

  .editor-main {
    flex: none;
    width: 100%;
  }

  .editor-sidebar {
    width: 100%;
    order: -1;
  }
}
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; gap: 4px; padding: 12px; }
  .sidebar h1 { width: 100%; margin-bottom: 8px; }
  .grid-3 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar select { width: 100%; }
}
@media (max-width: 640px) {
  .batch-actions { flex-direction: column; align-items: stretch; }
  .data-table .col-slug { display: none; }
}

/* ===== Modern Script Manager Branding & UI (Polished) ===== */
.script-manager-card {
  font-family: var(--font) !important;
}

.script-filters {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  display: flex !important;
  gap: 8px !important;
  flex-direction: row !important;
}

.btn-filter {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 8px 20px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-filter.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.scripts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.script-card {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: all 0.3s ease;
  font-family: var(--font);
}

.script-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.12);
}

.script-platform {
  display: flex;
  align-items: center;
  gap: 12px;
}

.script-platform-icon {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.script-platform-icon img { width: 20px; height: 20px; }
.script-platform-icon .material-icons { font-size: 20px; color: var(--muted); }

.script-name {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  letter-spacing: -0.01em;
}

.script-location-badge {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  font-family: var(--font);
}

.badge-head { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.2); }
.badge-body_start { background: rgba(139, 92, 246, 0.15); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.2); }
.badge-body_end { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.2); }

.script-code-preview {
  background: #09090b;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 12px 16px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', 'Cascadia Code', 'Ubuntu Mono', monospace;
  font-size: 11px;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.4);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
}

.script-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.01em;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-active { color: var(--success); }
.status-active .status-dot { background: var(--success); box-shadow: 0 0 10px var(--success); }
.status-paused { color: var(--muted); }
.status-paused .status-dot { background: var(--muted); }

.script-modal-content {
  max-width: 960px !important;
  width: 95% !important;
  background: var(--surface) !important;
  font-family: var(--font);
}

.modal-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 0;
}

.modal-sidebar {
  padding: 40px;
  background: rgba(0, 0, 0, 0.1);
  border-right: 1px solid var(--line);
}

.modal-main {
  padding: 40px;
}

.platform-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.platform-opt {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.25s;
}

.platform-opt.active {
  background: var(--primary-glow);
  border-color: var(--primary);
}

.platform-opt span { font-weight: 700; font-size: 13px; color: var(--muted); }
.platform-opt.active span { color: #fff; }

.code-editor-container {
  flex: 1;
  background: #050505;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.code-editor-container textarea {
  width: 100%;
  height: 100%;
  padding: 24px !important;
  background: transparent !important;
  border: none !important;
  color: #e5e7eb !important;
  font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', 'Cascadia Code', 'Ubuntu Mono', monospace !important;
  font-size: 13px !important;
  line-height: 1.7 !important;
  resize: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.script-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.script-card-actions .btn-icon {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: all 0.2s;
}

.script-card-actions .btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

.alert-hint {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 12px;
  padding: 16px;
  margin-top: 32px;
  display: flex;
  gap: 12px;
}

.alert-hint .material-icons { color: #f59e0b; font-size: 20px; width: 20px; height: 20px; overflow: hidden; }
.alert-hint p { margin: 0; font-size: 12px; line-height: 1.6; color: #fbbf24; font-weight: 500; }

@media (max-width: 900px) {
  .modal-layout { grid-template-columns: 1fr; }
  .modal-sidebar { border-right: none; border-bottom: 1px solid var(--line); padding: 24px; }
  .modal-main { padding: 24px; min-height: 300px; }
}

/* ===== NUCLEAR-ISOLATED PREMIUM TOGGLE (Zero Conflict) ===== */
.p-toggle {
  position: relative !important;
  display: block !important;
  width: 48px !important;
  height: 24px !important;
  cursor: pointer !important;
  margin: 0 !important;
  padding: 0 !important;
  flex-shrink: 0 !important;
}

.p-toggle input {
  position: absolute !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  pointer-events: none !important;
}

.p-slider {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background-color: #2d3748 !important; /* Neutral Slate */
  border-radius: 12px !important;
  transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Precision Actuator (The ONLY Dot) */
.p-slider::before {
  content: "" !important;
  display: block !important;
  position: absolute !important;
  top: 4px !important;
  left: 4px !important;
  width: 16px !important;
  height: 16px !important;
  background-color: #ffffff !important;
  border-radius: 50% !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4) !important;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  z-index: 10 !important;
}

/* KILL ALL OTHER PSEUDO ELEMENTS */
.p-slider::after {
  content: none !important;
  display: none !important;
}

.p-toggle input:checked + .p-slider {
  background-color: #10b981 !important; /* Vibrant Emerald */
}

.p-toggle input:checked + .p-slider::before {
  transform: translateX(24px) !important;
}

.p-toggle:hover .p-slider {
  filter: brightness(1.1) !important;
}

.product-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 18px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.product-tabs a {
  min-width: 128px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.product-tabs a:hover {
  color: #fff;
  border-color: rgba(212, 175, 55, 0.26);
  background: rgba(255, 255, 255, 0.055);
}

.product-tabs a.active {
  color: #fff;
  border-color: rgba(212, 175, 55, 0.5);
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.22), rgba(255, 255, 255, 0.055));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.product-tabs-edit {
  margin-bottom: 16px;
}

@media (max-width: 720px) {
  .product-tabs {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .product-tabs a {
    width: 100%;
  }
}



