/*
 * TensorFive CMS Stylesheet
 * Reuses CSS custom properties from the main website for visual consistency
 *
 * Font: Satoshi via Fontshare
 * Primary: #842CC3 (purple)
 * Layout: Fixed sidebar + scrollable content area
 */

/* ============================================
   CSS CUSTOM PROPERTIES (copied from website)
   ============================================ */

:root {
  /* Brand Colors */
  --color-primary: #842CC3;
  --color-primary-light: #a855f7;
  --color-primary-dark: #5b1a8a;
  --color-primary-glow: rgba(132, 44, 195, 0.4);
  --color-secondary: #87F3A4;

  /* Light Mode */
  --color-bg: #fafaf9;
  --color-bg-subtle: #f5f5f4;
  --color-bg-muted: #e7e5e4;
  --color-surface: #fff;
  --color-text: #1c1917;
  --color-text-secondary: #57534e;
  --color-text-muted: #78716c;
  --color-border: #d6d3d1;
  --color-border-subtle: #e7e5e4;

  /* Typography */
  --font-display: 'Satoshi', -apple-system, blinkmacsystemfont, sans-serif;
  --font-body: 'Satoshi', -apple-system, blinkmacsystemfont, sans-serif;

  /* Font Sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;

  /* Font Weights */
  --font-normal: 400;
  --font-medium: 500;
  --font-bold: 700;
  --font-black: 900;

  /* Line Heights */
  --leading-tight: 1.1;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;

  /* Letter Spacing */
  --tracking-tight: -0.025em;
  --tracking-wide: 0.025em;
  --tracking-wider: 0.1em;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Border Radius */
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(28, 25, 23, 0.07), 0 2px 4px -2px rgba(28, 25, 23, 0.07);
  --shadow-lg: 0 10px 15px -3px rgba(28, 25, 23, 0.08), 0 4px 6px -4px rgba(28, 25, 23, 0.08);
  --shadow-card: 0 1px 3px rgba(28, 25, 23, 0.04), 0 8px 24px rgba(28, 25, 23, 0.08);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* CMS-specific */
  --sidebar-width: 260px;
  --sidebar-collapsed: 64px;
}

/* ============================================
   DARK MODE (copied from website)
   ============================================ */

[data-theme="dark"] {
  --color-bg: #0c0a09;
  --color-bg-subtle: #1c1917;
  --color-bg-muted: #292524;
  --color-surface: #1c1917;
  --color-text: #fafaf9;
  --color-text-secondary: #a8a29e;
  --color-text-muted: #918a84;
  --color-border: #44403c;
  --color-border-subtle: #292524;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* ============================================
   RESET & BASE
   ============================================ */

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

html {
  font-size: 16px;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Logo switching for light/dark mode */
.logo-dark { display: none; }

[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: block; }

/* ============================================
   CMS LAYOUT (sidebar + content)
   ============================================ */

body.cms {
  display: flex;
  min-height: 100vh;
  overflow: hidden;
}

/* ============================================
   SIDEBAR
   ============================================ */

.cms-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-slow);
}

.cms-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--color-border-subtle);
}

.cms-sidebar__logo-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cms-sidebar__logo-icon {
  flex-shrink: 0;
}

.cms-sidebar__logo-text {
  height: 20px;
  width: auto;
}

/* Inline logo-text switching inside sidebar */
.cms-sidebar__logo-link .logo-dark { display: none; }
[data-theme="dark"] .cms-sidebar__logo-link .logo-light { display: none; }
[data-theme="dark"] .cms-sidebar__logo-link .logo-dark { display: block; }

.cms-sidebar__badge {
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--color-primary);
  background: rgba(132, 44, 195, 0.08);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

[data-theme="dark"] .cms-sidebar__badge {
  background: rgba(132, 44, 195, 0.2);
}

/* Navigation */
.cms-sidebar__nav {
  flex: 1;
  padding: var(--space-3) var(--space-3);
  overflow-y: auto;
}

.cms-sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
  margin-bottom: 2px;
}

.cms-sidebar__link:hover {
  color: var(--color-text);
  background: var(--color-bg-subtle);
}

.cms-sidebar__link.is-active {
  color: var(--color-primary);
  background: rgba(132, 44, 195, 0.08);
}

[data-theme="dark"] .cms-sidebar__link.is-active {
  background: rgba(132, 44, 195, 0.15);
}

.cms-sidebar__link.is-disabled {
  color: var(--color-text-muted);
  opacity: 0.5;
  pointer-events: none;
}

.cms-sidebar__link-icon {
  flex-shrink: 0;
  opacity: 0.7;
}

.cms-sidebar__link.is-active .cms-sidebar__link-icon {
  opacity: 1;
}

.cms-sidebar__soon {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: var(--color-bg-muted);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

/* Website link (above footer) */
.cms-sidebar__website-link {
    padding: 0 var(--space-3);
    margin-bottom: var(--space-2);
}

.cms-sidebar__link--website {
    color: var(--color-text-muted);
    border: 1px dashed var(--color-border-subtle);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
}

.cms-sidebar__link--website:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background: transparent;
}

/* Footer */
.cms-sidebar__footer {
  padding: var(--space-4) var(--space-4);
  border-top: 1px solid var(--color-border-subtle);
}

.cms-sidebar__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.cms-sidebar__user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  flex-shrink: 0;
}

.cms-sidebar__user-photo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
}

.cms-sidebar__user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cms-sidebar__user-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cms-sidebar__user-role {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.cms-sidebar__actions {
  display: flex;
  gap: var(--space-2);
}

.cms-sidebar__action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: all var(--transition-fast);
}

.cms-sidebar__action-btn:hover {
  color: var(--color-text);
  background: var(--color-bg-subtle);
}

/* ============================================
   COLLAPSIBLE SIDEBAR (Desktop)
   ============================================ */

/* Collapse toggle button */
.cms-sidebar__collapse-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    background: transparent;
    transition: all var(--transition-fast);
    margin-left: auto;
}

.cms-sidebar__collapse-btn:hover {
    color: var(--color-text);
    background: var(--color-bg-subtle);
}

.cms-sidebar__collapse-btn svg {
    transition: transform var(--transition-base);
}

/* Show collapse button on desktop */
@media (min-width: 769px) {
    .cms-sidebar__collapse-btn {
        display: flex;
    }
}

/* Collapsed sidebar state */
.cms-sidebar.is-collapsed {
    width: var(--sidebar-collapsed);
}

.cms-sidebar.is-collapsed .cms-sidebar__logo-text,
.cms-sidebar.is-collapsed .cms-sidebar__badge,
.cms-sidebar.is-collapsed .cms-sidebar__link span,
.cms-sidebar.is-collapsed .cms-sidebar__soon,
.cms-sidebar.is-collapsed .cms-sidebar__user-info {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.cms-sidebar.is-collapsed .cms-sidebar__header {
    justify-content: center;
    padding: var(--space-5) var(--space-3) var(--space-4);
}

.cms-sidebar.is-collapsed .cms-sidebar__logo-link {
    justify-content: center;
}

.cms-sidebar.is-collapsed .cms-sidebar__collapse-btn {
    display: none;
}

.cms-sidebar.is-collapsed .cms-sidebar__nav {
    padding: var(--space-3) var(--space-2);
}

.cms-sidebar.is-collapsed .cms-sidebar__link {
    justify-content: center;
    padding: var(--space-3);
}

.cms-sidebar.is-collapsed .cms-sidebar__footer {
    padding: var(--space-4) var(--space-2);
}

.cms-sidebar.is-collapsed .cms-sidebar__user {
    justify-content: center;
}

.cms-sidebar.is-collapsed .cms-sidebar__actions {
    justify-content: center;
}

.cms-sidebar.is-collapsed .cms-sidebar__website-link {
    padding: 0 var(--space-2);
}

.cms-sidebar.is-collapsed .cms-sidebar__link--website {
    justify-content: center;
    padding: var(--space-3);
}

.cms-sidebar.is-collapsed .cms-sidebar__link--website span {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}

/* Rotate chevron when collapsed */
.cms-sidebar.is-collapsed .cms-sidebar__collapse-btn svg {
    transform: rotate(180deg);
}

/* Content area adjusts to collapsed sidebar */
body.sidebar-collapsed .cms-content {
    margin-left: var(--sidebar-collapsed);
}

/* Collapsed sidebar expand button (appears when collapsed) */
.cms-sidebar__expand-btn {
    display: none;
    position: absolute;
    top: var(--space-5);
    right: 50%;
    transform: translateX(50%);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    background: transparent;
    transition: all var(--transition-fast);
}

.cms-sidebar__expand-btn:hover {
    color: var(--color-text);
    background: var(--color-bg-subtle);
}

.cms-sidebar.is-collapsed .cms-sidebar__expand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .cms-sidebar__expand-btn {
        display: none !important;
    }
}

/* Sidebar toggle (mobile) */
.cms-sidebar-toggle {
  display: none;
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  z-index: 150;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  color: var(--color-text);
}

.cms-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 90;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.cms-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  padding: var(--space-8);
}

/* ============================================
   PAGE HEADER
   ============================================ */

.cms-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  gap: var(--space-4);
}

.cms-page-header__title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-tight);
}

.cms-page-header__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ============================================
   VIEW TOGGLE (list/grid)
   ============================================ */

.cms-view-toggle {
  display: flex;
  background: var(--color-bg-subtle);
  border-radius: var(--radius-md);
  padding: 2px;
}

.cms-view-toggle__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: calc(var(--radius-md) - 2px);
  color: var(--color-text-muted);
  transition: all var(--transition-fast);
}

.cms-view-toggle__btn:hover {
  color: var(--color-text);
}

.cms-view-toggle__btn.is-active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* ============================================
   BUTTONS
   ============================================ */

.cms-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
}

.cms-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.cms-btn:focus:not(:focus-visible) {
  box-shadow: none;
}

.cms-btn:focus-visible {
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.cms-btn--primary {
  background: var(--color-primary);
  color: #fff;
}

.cms-btn--primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.cms-btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

.cms-btn--secondary:hover:not(:disabled) {
  background: var(--color-bg-subtle);
  border-color: var(--color-text-muted);
}

.cms-btn--ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

.cms-btn--ghost:hover:not(:disabled) {
  background: var(--color-bg-subtle);
  color: var(--color-text);
}

.cms-btn--danger {
  background: #dc2626;
  color: #fff;
}

.cms-btn--danger:hover:not(:disabled) {
  background: #b91c1c;
}

.cms-btn--danger:focus-visible {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.4);
}

.cms-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Loading state */
.cms-btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.cms-btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: cms-btn-spin 0.6s linear infinite;
}

.cms-btn--primary.is-loading::after {
  border-color: rgba(255, 255, 255, 0.3);
  border-right-color: transparent;
  border-top-color: #fff;
}

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

/* ============================================
   EMPTY STATE
   ============================================ */

.cms-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-20) var(--space-8);
  color: var(--color-text-muted);
}

.cms-empty-state svg {
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.cms-empty-state h2 {
  font-size: var(--text-lg);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.cms-empty-state p {
  font-size: var(--text-sm);
}

/* ============================================
   LOGIN PAGE
   ============================================ */

body.cms-login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-bg);
}

.cms-login__container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 400px;
  padding: var(--space-4);
}

.cms-login__card {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-10) var(--space-8);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.cms-login__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.cms-login__logo-icon {
  flex-shrink: 0;
}

.cms-login__logo-text {
  display: flex;
  align-items: center;
}

.cms-login__logo-text .logo-dark { display: none; }
[data-theme="dark"] .cms-login__logo-text .logo-light { display: none; }
[data-theme="dark"] .cms-login__logo-text .logo-dark { display: block; }

.cms-login__title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.cms-login__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-8);
}

/* Alert messages */
.cms-login__alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  text-align: left;
  margin-bottom: var(--space-4);
}

.cms-login__alert svg {
  flex-shrink: 0;
  margin-top: 1px;
}

.cms-login__alert--warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

[data-theme="dark"] .cms-login__alert--warning {
  background: rgba(251, 191, 36, 0.1);
  color: #fcd34d;
  border-color: rgba(251, 191, 36, 0.2);
}

.cms-login__alert--error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

[data-theme="dark"] .cms-login__alert--error {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.2);
}

/* Microsoft sign-in button */
.cms-login__microsoft-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: #2f2f2f;
  color: #fff;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.cms-login__microsoft-btn:hover {
  background: #404040;
}

.cms-login__microsoft-btn svg {
  flex-shrink: 0;
}

.cms-login__footer-text {
  margin-top: var(--space-6);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Login page theme toggle */
.cms-login__theme-toggle {
  position: fixed;
  bottom: var(--space-4);
  right: var(--space-4);
}

.cms-login__theme-toggle button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  color: var(--color-text-muted);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.cms-login__theme-toggle button:hover {
  color: var(--color-text);
  box-shadow: var(--shadow-md);
}

/* ============================================
   THEME TOGGLE ICONS (three-state: light/dark/system)
   Icons are shown/hidden via JavaScript based on current mode.
   Default state (before JS loads): show light icon.
   ============================================ */

.cms-theme-icon--light,
.cms-theme-icon--dark,
.cms-theme-icon--system {
  display: none;
}

/* Default before JS initializes: show light icon */
.cms-theme-icon--light {
  display: block;
}

/* ============================================
   ERROR PAGES
   ============================================ */

body.cms-error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.cms-error__container {
  text-align: center;
  padding: var(--space-8);
}

.cms-error__code {
  font-size: 6rem;
  font-weight: var(--font-black);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text-muted);
  line-height: 1;
  margin-bottom: var(--space-4);
}

.cms-error__message {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-8);
}

/* ============================================
   FLASH MESSAGES
   ============================================ */

.cms-flash {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-6);
    font-size: var(--text-sm);
}

.cms-flash--success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

[data-theme="dark"] .cms-flash--success {
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
    border-color: rgba(34, 197, 94, 0.3);
}

.cms-flash--error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

[data-theme="dark"] .cms-flash--error {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.3);
}

.cms-flash--info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

[data-theme="dark"] .cms-flash--info {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.3);
}

/* ============================================
   FILTER TABS
   ============================================ */

.cms-filter-tabs {
    display: flex;
    gap: var(--space-1);
    margin-bottom: var(--space-6);
    border-bottom: 1px solid var(--color-border-subtle);
    padding-bottom: var(--space-1);
}

.cms-filter-tab {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text-secondary);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.cms-filter-tab:hover {
    color: var(--color-text);
    background: var(--color-bg-subtle);
}

.cms-filter-tab.is-active {
    color: var(--color-primary);
    background: rgba(132, 44, 195, 0.08);
}

[data-theme="dark"] .cms-filter-tab.is-active {
    background: rgba(132, 44, 195, 0.15);
}

.cms-filter-tab__count {
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    color: var(--color-text-muted);
    background: var(--color-bg-muted);
    padding: 1px 6px;
    border-radius: var(--radius-full);
}

.cms-filter-tab.is-active .cms-filter-tab__count {
    background: rgba(132, 44, 195, 0.2);
    color: var(--color-primary);
}

/* ============================================
   ARTICLES TABLE
   ============================================ */

.cms-articles-table-wrapper {
    background: var(--color-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.cms-articles-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.cms-articles-table th,
.cms-articles-table td {
    padding: var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--color-border-subtle);
}

.cms-articles-table th {
    font-weight: var(--font-medium);
    color: var(--color-text-secondary);
    background: var(--color-bg-subtle);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
}

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

.cms-articles-table__row:hover td {
    background: var(--color-bg-subtle);
}

.cms-articles-table__col-title {
    width: auto;
}

.cms-articles-table__col-author {
    width: 150px;
    min-width: 150px;
}

.cms-articles-table__col-status {
    width: 120px;
    min-width: 120px;
}

.cms-articles-table__col-date {
    width: 140px;
    min-width: 140px;
    white-space: nowrap;
}

.cms-articles-table__col-actions {
    width: 140px;
    min-width: 140px;
    text-align: right;
}

.cms-articles-table__title-link {
    font-weight: var(--font-medium);
    color: var(--color-text);
    transition: color var(--transition-fast);
}

.cms-articles-table__title-link:hover {
    color: var(--color-primary);
}

.cms-articles-table__title-link--full {
    display: block;
    margin: calc(-1 * var(--space-4));
    padding: var(--space-4);
}

/* ============================================
   STATUS BADGES
   ============================================ */

.cms-status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 4px 10px;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    border-radius: var(--radius-full);
}

.cms-status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

/* Draft - Gray */
.cms-status-badge.is-draft {
    background: var(--color-bg-muted);
    color: var(--color-text-muted);
}

.cms-status-badge.is-draft::before {
    background: var(--color-text-muted);
}

/* Published - Green */
.cms-status-badge.is-published {
    background: rgba(135, 243, 164, 0.15);
    color: #166534;
}

[data-theme="dark"] .cms-status-badge.is-published {
    background: rgba(135, 243, 164, 0.2);
    color: #87f3a4;
}

.cms-status-badge.is-published::before {
    background: #22c55e;
}

.cms-status-badge.is-scheduled {
    background: rgba(251, 191, 36, 0.15);
    color: #b45309;
}

[data-theme="dark"] .cms-status-badge.is-scheduled {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.cms-status-badge.is-scheduled::before {
    background: #f59e0b;
}

/* ============================================
   ACTION BUTTONS
   ============================================ */

.cms-actions {
    display: flex;
    gap: var(--space-1);
    justify-content: flex-end;
}

.cms-action-form {
    display: inline-flex;
}

.cms-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    background: transparent;
    transition: all var(--transition-fast);
}

.cms-action-btn:hover {
    background: var(--color-bg-muted);
    color: var(--color-text);
}

.cms-action-btn--success:hover {
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
}

.cms-action-btn--warning:hover {
    background: rgba(251, 191, 36, 0.15);
    color: #ca8a04;
}

.cms-action-btn--danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

.cms-action-btn--disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ============================================
   RESPONSIVE (mobile sidebar)
   ============================================ */

@media (max-width: 768px) {
  .cms-sidebar-toggle {
    display: flex;
  }

  .cms-sidebar {
    transform: translateX(-100%);
  }

  .cms-sidebar.is-open {
    transform: translateX(0);
  }

  .cms-sidebar-overlay.is-visible {
    display: block;
  }

  .cms-content {
    margin-left: 0;
    padding: var(--space-16) var(--space-4) var(--space-4);
    height: auto;
    min-height: 100vh;
  }

  .cms-page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .cms-page-header__right {
    width: 100%;
    justify-content: space-between;
  }
}

/* ============================================
   MEDIA LIBRARY
   ============================================ */

/* Page header count */
.cms-page-header__count {
    margin-left: var(--space-4);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    font-weight: var(--font-medium);
}

/* User filter dropdown */
.cms-user-filter {
    margin-right: var(--space-3);
}

.cms-select {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.cms-select:hover {
    border-color: var(--color-primary);
}

.cms-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(132, 44, 195, 0.1);
}

/* Media Grid */
.media-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}

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

@media (max-width: 900px) {
    .media-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

/* Media Card */
.media-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: box-shadow var(--transition-base), transform var(--transition-base);
    position: relative;
}

.media-card:hover {
    box-shadow: var(--shadow-card);
    transform: translateY(-2px);
}

/* Thumbnail */
.media-thumbnail {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--color-bg-subtle);
    overflow: hidden;
}

.media-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-base);
}

.media-card:hover .media-thumbnail img {
    transform: scale(1.05);
}

/* Thumbnail Overlay */
.media-thumbnail__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.media-card:hover .media-thumbnail__overlay {
    opacity: 1;
}

/* Media Buttons */
.media-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    border: none;
    cursor: pointer;
}

.media-btn--copy {
    background: var(--color-surface);
    color: var(--color-text);
}

.media-btn--copy:hover {
    background: var(--color-primary);
    color: #fff;
}

.media-btn--delete {
    background: transparent;
    color: var(--color-text-muted);
    padding: var(--space-2);
}

.media-btn--delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

/* Media Meta */
.media-meta {
    padding: var(--space-3);
}

.media-filename {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: var(--space-1);
}

.media-details {
    display: flex;
    gap: var(--space-2);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-bottom: var(--space-1);
}

.media-dimensions::after,
.media-size::after {
    content: '•';
    margin-left: var(--space-2);
    color: var(--color-text-muted);
}

.media-uploader {
    font-size: var(--text-xs);
    color: var(--color-primary);
    font-weight: var(--font-medium);
}

/* Media Actions */
.media-actions {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.media-card:hover .media-actions {
    opacity: 1;
}

.media-delete-form {
    display: inline-flex;
}

.media-actions .media-btn {
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
}

.media-actions .media-btn:hover {
    background: #dc2626;
    color: #fff;
}

/* Pagination */
.media-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-4);
    border-top: 1px solid var(--color-border-subtle);
    margin-top: var(--space-4);
}

.media-pagination__btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.media-pagination__btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.media-pagination__btn--disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.media-pagination__btn--disabled:hover {
    border-color: var(--color-border);
    color: var(--color-text);
}

.media-pagination__info {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

/* Toast Notification */
.media-toast {
    position: fixed;
    bottom: var(--space-8);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--color-text);
    color: var(--color-surface);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all var(--transition-base);
    z-index: 1000;
}

.media-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Responsive adjustments for media library */
@media (max-width: 768px) {
    .media-card:hover {
        transform: none;
    }

    .media-thumbnail__overlay {
        opacity: 1;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent 50%);
        align-items: flex-end;
        padding: var(--space-3);
    }

    .media-btn--copy {
        background: var(--color-surface);
    }

    .media-actions {
        opacity: 1;
    }
}

/* ============================================
   CUSTOM SIDE-BY-SIDE EDITOR LAYOUT
   ============================================ */

/*
 * Custom side-by-side implementation:
 * - Editor pane (left) contains EasyMDE
 * - Preview pane (right) is our own div
 * - Both scroll independently, synced via JS
 */

/* Wrapper for editor + preview */
.cms-editor-wrapper {
    display: flex;
    gap: var(--space-6);
    align-items: flex-start;
}

/* When side-by-side is active: fixed viewport height with independent scrolling */
.cms-editor-wrapper.is-side-by-side {
    align-items: stretch;
    height: calc(100vh - 2rem);
    overflow: hidden;
}

/* Editor pane - full width by default */
.cms-editor-pane {
    flex: 1;
    min-width: 0;
    transition: flex var(--transition-base);
}

/* Preview pane - hidden by default */
.cms-preview-pane {
    display: none;
    flex: 1;
    min-width: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* When side-by-side is active */
.cms-editor-wrapper.is-side-by-side .cms-editor-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cms-editor-wrapper.is-side-by-side .cms-editor-pane .cms-form-group--editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-top: 0;
}

.cms-editor-wrapper.is-side-by-side .cms-editor-pane .EasyMDEContainer {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.cms-editor-wrapper.is-side-by-side .cms-editor-pane .CodeMirror {
    flex: 1;
    height: auto !important;
    max-height: none !important;
    overflow-y: auto;
}

.cms-editor-wrapper.is-side-by-side .cms-preview-pane {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Match editor container styling to preview pane in side-by-side mode */
.cms-editor-wrapper.is-side-by-side .cms-editor-pane .EasyMDEContainer {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    overflow: hidden;
}

.cms-editor-wrapper.is-side-by-side .EasyMDEContainer .editor-statusbar {
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-subtle);
    padding: var(--space-1) var(--space-3);
}

/* Preview pane header */
.cms-preview-pane__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    background: var(--color-bg-subtle);
    border-bottom: 1px solid var(--color-border);
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

.cms-preview-pane__close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.cms-preview-pane__close:hover {
    background: var(--color-bg-muted);
    color: var(--color-text);
}

/* Preview pane content */
.cms-preview-pane__content {
    flex: 1;
    padding: var(--space-6);
    overflow-y: auto;
}

.cms-preview-placeholder {
    color: var(--color-text-muted);
    font-style: italic;
}

/* Preview content styling (matches blog article styling) */
.cms-preview-pane__content h1,
.cms-preview-pane__content h2,
.cms-preview-pane__content h3,
.cms-preview-pane__content h4 {
    margin-top: var(--space-6);
    margin-bottom: var(--space-3);
    color: var(--color-text);
}

.cms-preview-pane__content p {
    margin-bottom: var(--space-4);
    line-height: 1.7;
}

.cms-preview-pane__content pre {
    background: var(--color-bg-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    overflow-x: auto;
    margin: var(--space-4) 0;
}

.cms-preview-pane__content code {
    background: var(--color-bg-subtle);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.9em;
}

.cms-preview-pane__content pre code {
    background: transparent;
    padding: 0;
}

.cms-preview-pane__content blockquote {
    border-left: 4px solid var(--color-primary);
    padding-left: var(--space-4);
    margin: var(--space-4) 0;
    color: var(--color-text-secondary);
}

.cms-preview-pane__content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
}

.cms-preview-pane__content ul,
.cms-preview-pane__content ol {
    margin: var(--space-4) 0;
    padding-left: var(--space-6);
}

.cms-preview-pane__content li {
    margin-bottom: var(--space-2);
}

/* Hide EasyMDE's built-in side-by-side preview */
.EasyMDEContainer .editor-preview-side {
    display: none !important;
}

/* Ensure EasyMDE doesn't go into its side-by-side mode visually */
.EasyMDEContainer.sided--no-fullscreen {
    display: block !important;
}

.EasyMDEContainer.sided--no-fullscreen .CodeMirror-sided {
    width: 100% !important;
    border-right: none !important;
}

/* ============================================
   COLLAPSIBLE METADATA PANEL (Editor)
   ============================================ */

.cms-meta-panel {
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    background: var(--color-bg-subtle);
    margin: var(--space-6) 0;
}

.cms-meta-panel.is-collapsed {
    overflow: hidden;
}

.cms-meta-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-fast);
}

.cms-meta-panel__header:hover {
    background: var(--color-bg-muted);
}

.cms-meta-panel__title {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text);
    margin: 0;
}

.cms-meta-panel__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--color-text-muted);
    transition: transform var(--transition-base);
}

.cms-meta-panel__content {
    padding: 0 var(--space-4) var(--space-4);
    overflow: visible;
    transition: max-height var(--transition-slow), padding var(--transition-slow), opacity var(--transition-base);
    max-height: 800px;
    opacity: 1;
}

.cms-meta-panel__content .cms-meta-grid {
    margin: 0;
}

.cms-meta-panel.is-collapsed .cms-meta-panel__content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    overflow: hidden;
}

.cms-meta-panel.is-collapsed .cms-meta-panel__toggle {
    transform: rotate(-90deg);
}

/* ============================================
   SETTINGS PAGE TABS
   ============================================ */

.cms-settings {
    margin-top: calc(-1 * var(--space-4));
}

.cms-settings-tabs {
    display: flex;
    gap: var(--space-1);
    border-bottom: 1px solid var(--color-border-subtle);
    background: var(--color-surface);
    margin-bottom: var(--space-6);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.cms-settings-tabs::-webkit-scrollbar {
    display: none;
}

.cms-settings-tab {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border: none;
    background: none;
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all var(--transition-fast);
}

.cms-settings-tab:hover {
    color: var(--color-text);
}

.cms-settings-tab.is-active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.cms-settings-tab svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.cms-settings-content {
    min-height: 400px;
}

/* Settings Section */
.cms-settings-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
}

.cms-settings-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border-subtle);
}

.cms-settings-section__title {
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    color: var(--color-text);
    margin: 0;
}

/* Settings Placeholder (for future tabs) */
.cms-settings-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-16) var(--space-8);
    background: var(--color-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    color: var(--color-text-muted);
}

.cms-settings-placeholder svg {
    margin-bottom: var(--space-4);
    opacity: 0.4;
}

.cms-settings-placeholder h2 {
    font-size: var(--text-lg);
    font-weight: var(--font-medium);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-2);
}

.cms-settings-placeholder p {
    font-size: var(--text-sm);
    max-width: 300px;
}

/* Toast styles (used by users tab) */
.cms-toast {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    box-shadow: var(--shadow-lg);
    transform: translateY(calc(100% + 2rem));
    opacity: 0;
    transition: all var(--transition-slow);
    z-index: 1000;
    pointer-events: none;
}

.cms-toast.is-visible {
    transform: translateY(0);
    opacity: 1;
}

.cms-toast--success {
    background: #16a34a;
    color: #fff;
}

.cms-toast--error {
    background: #dc2626;
    color: #fff;
}

/* Responsive settings tabs */
@media (max-width: 768px) {
    .cms-settings-tabs {
        padding: 0 var(--space-2);
    }

    .cms-settings-tab {
        padding: var(--space-3);
    }

    .cms-settings-tab span {
        display: none;
    }

    .cms-settings-section {
        padding: var(--space-4);
    }

    .cms-settings-section__header {
        flex-direction: column;
        gap: var(--space-3);
        align-items: flex-start;
    }
}

/* ============================================
   SETTINGS FORM (Blog/CMS settings)
   ============================================ */

.cms-settings-form {
    max-width: 600px;
    background: var(--color-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
}

.cms-settings-form-section {
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-6);
    border-bottom: 1px solid var(--color-border-subtle);
}

.cms-settings-form-section:last-of-type {
    border-bottom: none;
    margin-bottom: var(--space-4);
    padding-bottom: 0;
}

.cms-settings-form-section__title {
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    color: var(--color-text-muted);
    margin-bottom: var(--space-4);
}

/* Form elements */
.cms-form-group {
    margin-bottom: var(--space-4);
}

.cms-form-group:last-child {
    margin-bottom: 0;
}

.cms-form-label,
.cms-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text);
    margin-bottom: var(--space-2);
}

.cms-form-input,
.cms-input {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.cms-form-input:focus,
.cms-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(132, 44, 195, 0.1);
}

.cms-form-input--small {
    width: 120px;
}

.cms-form-select {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.cms-form-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(132, 44, 195, 0.1);
}

.cms-form-hint {
    display: block;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-1);
}

.cms-form-actions {
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border-subtle);
}

/* Toggle Switch */
.cms-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
}

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

.cms-toggle__slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--color-bg-muted);
    border-radius: 12px;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

.cms-toggle__slider::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.cms-toggle input:checked + .cms-toggle__slider {
    background: var(--color-primary);
}

.cms-toggle input:checked + .cms-toggle__slider::after {
    transform: translateX(20px);
}

.cms-toggle input:focus + .cms-toggle__slider {
    box-shadow: 0 0 0 3px rgba(132, 44, 195, 0.2);
}

.cms-toggle__label {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text);
}

/* Alert Messages */
.cms-alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    font-size: var(--text-sm);
}

.cms-alert--success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

[data-theme="dark"] .cms-alert--success {
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
    border-color: rgba(34, 197, 94, 0.3);
}

.cms-alert--error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

[data-theme="dark"] .cms-alert--error {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.3);
}

/* ============================================
   EXPORT TAB
   ============================================ */

.cms-settings-desc {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    margin-bottom: var(--space-4);
}

.cms-export-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.cms-export-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.cms-export-card__icon {
    width: 48px;
    height: 48px;
    background: var(--color-bg-subtle);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
}

.cms-export-card__content h4 {
    font-size: var(--text-base);
    font-weight: var(--font-bold);
    color: var(--color-text);
    margin-bottom: var(--space-1);
}

.cms-export-card__content p {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.cms-export-card .cms-btn {
    margin-top: auto;
}

.cms-export-stats {
    padding: var(--space-3) var(--space-4);
    background: var(--color-bg-subtle);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

.cms-export-stats strong {
    color: var(--color-text);
}

/* ============================================
   GLOBAL CONFIRM MODAL
   ============================================ */

.cms-confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.cms-confirm-modal[hidden] {
  display: none;
}

.cms-confirm-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  animation: cms-fade-in 150ms ease-out;
}

.cms-confirm-modal__dialog {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-6);
  max-width: 400px;
  width: 100%;
  text-align: center;
  animation: cms-scale-in 150ms ease-out;
}

.cms-confirm-modal__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

.cms-confirm-modal__icon.is-warning {
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
}

.cms-confirm-modal__icon.is-info {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
}

[data-theme="dark"] .cms-confirm-modal__icon {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

[data-theme="dark"] .cms-confirm-modal__icon.is-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

[data-theme="dark"] .cms-confirm-modal__icon.is-info {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.cms-confirm-modal__title {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.cms-confirm-modal__message {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-5);
}

.cms-confirm-modal__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
}

.cms-confirm-modal__actions .cms-btn {
  min-width: 100px;
}

@keyframes cms-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes cms-scale-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ============================================
   GLOBAL TOAST NOTIFICATIONS
   ============================================ */

.cms-toast-container {
  position: fixed;
  bottom: var(--space-4);
  right: var(--space-4);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.cms-toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 360px;
  pointer-events: auto;
  animation: cms-toast-in 200ms ease-out;
}

.cms-toast.is-removing {
  animation: cms-toast-out 150ms ease-in forwards;
}

.cms-toast__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.cms-toast__content {
  flex: 1;
  min-width: 0;
}

.cms-toast__title {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.cms-toast__message {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.4;
}

.cms-toast__close {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.cms-toast__close:hover {
  background: var(--color-bg-subtle);
  color: var(--color-text);
}

/* Toast variants */
.cms-toast--success {
  border-left: 3px solid #16a34a;
}

.cms-toast--success .cms-toast__icon {
  color: #16a34a;
}

.cms-toast--error {
  border-left: 3px solid #dc2626;
}

.cms-toast--error .cms-toast__icon {
  color: #dc2626;
}

.cms-toast--warning {
  border-left: 3px solid #d97706;
}

.cms-toast--warning .cms-toast__icon {
  color: #d97706;
}

.cms-toast--info {
  border-left: 3px solid #2563eb;
}

.cms-toast--info .cms-toast__icon {
  color: #2563eb;
}

@keyframes cms-toast-in {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes cms-toast-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* Mobile toast positioning */
@media (max-width: 480px) {
  .cms-toast-container {
    left: var(--space-4);
    right: var(--space-4);
    bottom: var(--space-4);
  }

  .cms-toast {
    max-width: none;
  }
}

/* ============================================
   FORM INPUT FOCUS IMPROVEMENTS
   ============================================ */

.cms-input:focus,
.cms-select:focus,
.cms-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

/* Action buttons focus states */
.cms-action-btn:focus {
  outline: none;
}

.cms-action-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--color-primary-glow);
  border-radius: var(--radius-md);
}

/* Settings tabs focus */
.cms-settings-tab:focus {
  outline: none;
}

.cms-settings-tab:focus-visible {
  box-shadow: inset 0 0 0 2px var(--color-primary-glow);
}

/* Filter tabs focus */
.cms-filter-tab:focus {
  outline: none;
}

.cms-filter-tab:focus-visible {
  box-shadow: 0 0 0 2px var(--color-primary-glow);
  border-radius: var(--radius-md);
}

/* Sidebar links focus */
.cms-sidebar__link:focus {
  outline: none;
}

.cms-sidebar__link:focus-visible {
  box-shadow: inset 0 0 0 2px var(--color-primary-glow);
}

/* ============================================
   FULLSCREEN EDITOR MODE
   ============================================ */

/* Icon button style */
.cms-btn--icon {
  padding: var(--space-2);
  width: 36px;
  height: 36px;
}

/* Fullscreen button */
.cms-editor__fullscreen-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.cms-editor__fullscreen-btn:hover {
  background: var(--color-bg-subtle);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Fullscreen editor mode */
.cms-editor.is-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: var(--color-bg);
  padding: var(--space-6);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.cms-editor.is-fullscreen .cms-editor__form {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: none;
  padding-right: 0;
}

.cms-editor.is-fullscreen .cms-form-group--editor {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.cms-editor.is-fullscreen .EasyMDEContainer {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.cms-editor.is-fullscreen .EasyMDEContainer .CodeMirror {
  flex: 1;
  height: auto !important;
  min-height: 400px;
}

.cms-editor.is-fullscreen .cms-editor-wrapper {
  flex: 1;
  display: flex;
}

.cms-editor.is-fullscreen .cms-editor-pane {
  display: flex;
  flex-direction: column;
}

.cms-editor.is-fullscreen .cms-preview-pane__content {
  flex: 1;
}

/* Fullscreen button state change */
.cms-editor.is-fullscreen .cms-editor__fullscreen-btn svg path {
  d: path("M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3");
}

/* Hide sidebar and other elements in fullscreen */
.cms-editor.is-fullscreen ~ .cms-sidebar,
body.cms-fullscreen-active .cms-sidebar {
  display: none;
}

body.cms-fullscreen-active .cms-content {
  margin-left: 0;
}

/* Fullscreen header bar */
.cms-editor.is-fullscreen::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: -1;
}

/* ============================================
   EDITOR SIDEBAR (Metadata Panel Redesign)
   ============================================ */

/* Editor form layout - vertical by default */
.cms-editor__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: 100%;
}

/* Editor layout with sidebar - only when sidebar is present */
.cms-editor__form:has(.cms-editor__sidebar) {
  flex-direction: row;
  gap: var(--space-6);
  align-items: flex-start;
}

/* Main editor area takes remaining space when sidebar present */
.cms-editor__form:has(.cms-editor__sidebar) > .cms-form-group:first-child,
.cms-editor__form:has(.cms-editor__sidebar) > .cms-editor-wrapper {
  flex: 1;
  min-width: 0;
}

/* Sidebar container */
.cms-editor__sidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: sticky;
  top: var(--space-4);
  max-height: calc(100vh - 160px);
  overflow-y: auto;
}

/* Collapsible section groups */
.cms-meta-section-group {
  border-bottom: 1px solid var(--color-border-subtle);
}

.cms-meta-section-group:last-child {
  border-bottom: none;
}

.cms-meta-section-group__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-subtle);
  border: none;
  font-weight: var(--font-medium);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.cms-meta-section-group__header:hover {
  background: var(--color-bg-muted);
  color: var(--color-text);
}

.cms-meta-section-group__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cms-meta-section-group__chevron {
  transition: transform var(--transition-base);
  opacity: 0.6;
}

.cms-meta-section-group__content {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Collapsed state */
.cms-meta-section-group.is-collapsed .cms-meta-section-group__content {
  display: none;
}

.cms-meta-section-group.is-collapsed .cms-meta-section-group__chevron {
  transform: rotate(-90deg);
}

/* Meta field styling */
.cms-meta-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.cms-meta-field__label {
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  color: var(--color-text);
}

/* Override old cms-editor__meta grid for sidebar context */
.cms-editor__sidebar .cms-editor__meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
}

/* Responsive: Stack sidebar below editor on narrow screens */
@media (max-width: 1200px) {
  .cms-editor__form {
    flex-direction: column;
  }

  .cms-editor__sidebar {
    width: 100%;
    position: static;
    max-height: none;
  }
}

/* Fullscreen mode: hide sidebar */
.cms-editor.is-fullscreen .cms-editor__sidebar {
  display: none;
}
