/* ============================================================
   ELEVEN11 ADMIN — Design System
   Dark-theme admin panel CSS
   ============================================================ */

/* ------------------------------------------------------------
   1. CSS CUSTOM PROPERTIES
   ------------------------------------------------------------ */
:root {
  /* Backgrounds */
  --bg-app: #0b0b12;
  --bg-surface: #0f0f18;
  --bg-surface-hover: #16162a;
  --bg-surface-active: #1a1a34;
  --bg-elevated: #12121e;

  /* Text */
  --text-primary: #e8e8f0;
  --text-secondary: #8b8ba0;
  --text-tertiary: #5a5a70;
  --text-inverse: #0b0b12;

  /* Borders */
  --border: #1c1c30;
  --border-strong: #2a2a44;
  --border-focus: #FF8C42;

  /* Accent */
  --accent: #FF8C42;
  --accent-hover: #e07a35;
  --accent-dark: #d4702e;
  --accent-subtle: rgba(255, 140, 66, 0.1);
  --accent-secondary: #A0A0B0;

  /* Semantic */
  --success: #10b981;
  --success-subtle: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.12);
  --info: #3b82f6;
  --info-subtle: rgba(59, 130, 246, 0.12);

  /* Sidebar */
  --sidebar-bg: #08080e;
  --sidebar-hover: #0d0d16;
  --sidebar-active: rgba(255, 140, 66, 0.08);
  --sidebar-width: 256px;
  --sidebar-collapsed-width: 72px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-accent: 0 4px 20px rgba(255, 140, 66, 0.2);
  --shadow-accent-lg: 0 8px 32px rgba(255, 140, 66, 0.3);

  /* Typography */
  --font-display: 'Sora', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-logo: 'Russo One', sans-serif;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* Z-index scale */
  --z-sidebar: 100;
  --z-mobile-header: 90;
  --z-overlay: 200;
  --z-modal: 300;
  --z-toast: 400;
}

/* ------------------------------------------------------------
   2. RESET & BASE
   ------------------------------------------------------------ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--accent-hover); }

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

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--bg-surface-hover);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Selection */
::selection {
  background: rgba(255, 140, 66, 0.3);
  color: var(--text-primary);
}

/* ------------------------------------------------------------
   3. LOGIN SCREEN
   ------------------------------------------------------------ */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
  z-index: 500;
  overflow: hidden;
}
.login-screen[hidden] { display: none; }

/* Floating orbs */
.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  pointer-events: none;
}

.login-orb-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #FF8C42 0%, transparent 70%);
  top: -10%;
  left: -5%;
  animation: orb-float-1 12s ease-in-out infinite;
}

.login-orb-2 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, #A0A0B0 0%, transparent 70%);
  bottom: -8%;
  right: -3%;
  animation: orb-float-2 15s ease-in-out infinite;
}

.login-orb-3 {
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, #3b82f6 0%, transparent 70%);
  top: 50%;
  left: 60%;
  opacity: 0.2;
  animation: orb-float-3 18s ease-in-out infinite;
}

@keyframes orb-float-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(60px, 40px) scale(1.1); }
  66% { transform: translate(-30px, 80px) scale(0.95); }
}

@keyframes orb-float-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-50px, -30px) scale(1.05); }
  66% { transform: translate(40px, -60px) scale(0.9); }
}

@keyframes orb-float-3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-80px, 40px) scale(1.15); }
}

/* Login card */
.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 40px 36px;
  background: rgba(15, 15, 24, 0.7);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: scale-in 0.4s ease;
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 4px;
}

.login-logo-text {
  font-family: var(--font-logo);
  font-size: 32px;
  color: var(--text-primary);
  letter-spacing: 1px;
}

.login-logo-icon svg {
  height: 40px;
  width: auto;
}

.login-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 32px;
  font-weight: 400;
}

.login-error {
  background: var(--danger-subtle);
  color: var(--danger);
  font-size: 0.8125rem;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(239, 68, 68, 0.2);
  margin-bottom: 16px;
}

.btn-login {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow var(--transition-base), transform var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
}

.btn-login:hover {
  box-shadow: var(--shadow-accent-lg);
  transform: translateY(-1px);
}

.btn-login:active { transform: translateY(0); }

.btn-login-spinner {
  display: none;
  animation: spin 1s linear infinite;
}

.btn-login.loading .btn-login-text { opacity: 0; }
.btn-login.loading .btn-login-spinner { display: block; }

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

/* ------------------------------------------------------------
   4. ADMIN APP LAYOUT
   ------------------------------------------------------------ */
.admin-app {
  display: flex;
  min-height: 100vh;
}
.admin-app[hidden] { display: none; }

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: width var(--transition-slow), transform var(--transition-slow);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-logo-text {
  font-family: var(--font-logo);
  font-size: 22px;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition-base);
}

.sidebar.collapsed .sidebar-logo-text {
  opacity: 0;
  width: 0;
}

.sidebar-logo-icon svg {
  height: 28px;
  width: auto;
  flex-shrink: 0;
}

/* Sidebar navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
}

.sidebar-nav-section {
  padding: 16px 20px 6px;
}

.sidebar-nav-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-nav-section-label {
  opacity: 0;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  border-left: 3px solid transparent;
  white-space: nowrap;
  position: relative;
}

.sidebar-nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--text-primary);
}

.sidebar-nav-item.active {
  background: var(--sidebar-active);
  color: var(--accent);
  border-left-color: var(--accent);
}

.sidebar-nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

.sidebar-nav-item-text {
  overflow: hidden;
  transition: opacity var(--transition-base);
}

.sidebar.collapsed .sidebar-nav-item-text {
  opacity: 0;
  width: 0;
}

.sidebar-nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
  line-height: 1.4;
}

.sidebar.collapsed .sidebar-nav-badge {
  position: absolute;
  top: 6px;
  right: 10px;
  margin: 0;
  padding: 1px 5px;
  font-size: 0.625rem;
}

/* Sidebar tooltip (collapsed state) */
.sidebar.collapsed .sidebar-nav-item[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  box-shadow: var(--shadow-md);
  z-index: 10;
}

.sidebar.collapsed .sidebar-nav-item[data-tooltip]:hover::after {
  opacity: 1;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

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

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-user-info {
  overflow: hidden;
}

.sidebar-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
}

.sidebar-footer-actions {
  display: flex;
  gap: 8px;
}

.sidebar-footer-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-footer-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.sidebar-footer-btn svg {
  width: 16px;
  height: 16px;
}

/* Sidebar backdrop (mobile) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: calc(var(--z-sidebar) - 1);
}

.sidebar-backdrop.active { display: block; }

/* ------------------------------------------------------------
   5. MOBILE HEADER
   ------------------------------------------------------------ */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  z-index: var(--z-mobile-header);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.mobile-menu-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
}

.mobile-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ------------------------------------------------------------
   6. MAIN CONTENT
   ------------------------------------------------------------ */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  overflow-y: auto;
  transition: margin-left var(--transition-slow);
}

.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-app);
  position: sticky;
  top: 0;
  z-index: 10;
}

.page-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-body {
  padding: 24px 32px 48px;
}

/* ------------------------------------------------------------
   7. CARDS
   ------------------------------------------------------------ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

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

.card-title {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: 20px; }

.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.stat-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

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

.stat-card-change {
  font-size: 0.75rem;
  margin-top: 6px;
  font-weight: 500;
}

.stat-card-change.up { color: var(--success); }
.stat-card-change.down { color: var(--danger); }

/* ------------------------------------------------------------
   8. TABLES
   ------------------------------------------------------------ */
.table-wrapper {
  overflow-x: auto;
}

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

.data-table thead th {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-strong);
  text-align: left;
  white-space: nowrap;
  user-select: none;
}

.data-table thead th.sortable {
  cursor: pointer;
  transition: color var(--transition-fast);
}

.data-table thead th.sortable:hover { color: var(--text-primary); }

.data-table thead th.sorted { color: var(--accent); }

.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--bg-surface-hover);
}

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

/* ------------------------------------------------------------
   9. FORMS
   ------------------------------------------------------------ */
.form-group {
  margin-bottom: 18px;
}

.form-group label,
.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="url"],
input[type="search"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus,
input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 140, 66, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

.form-textarea,
textarea {
  resize: vertical;
  min-height: 100px;
}

.form-select,
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238b8ba0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Error state */
.form-group.error .form-input,
.form-group.error input,
.form-group.error textarea,
.form-group.error select {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.form-error-message {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 4px;
}

/* Checkbox / toggle */
.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.form-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* ------------------------------------------------------------
   10. BUTTONS
   ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Primary */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  border-color: transparent;
}

.btn-primary:hover {
  box-shadow: var(--shadow-accent);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

/* Secondary */
.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-strong);
}

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

/* Danger */
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: var(--danger-subtle);
  border-color: var(--danger);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  padding: 8px 12px;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

/* Sizes */
.btn-sm { padding: 6px 12px; font-size: 0.75rem; }
.btn-lg { padding: 14px 24px; font-size: 0.9375rem; }

/* Disabled */
.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Loading */
.btn.loading { position: relative; color: transparent; }

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Icon button */
.btn-icon {
  padding: 8px;
  width: 36px;
  height: 36px;
}

.btn-icon.btn-sm { width: 28px; height: 28px; padding: 4px; }
.btn-icon.btn-lg { width: 44px; height: 44px; padding: 10px; }

/* ------------------------------------------------------------
   11. BADGES / PILLS
   ------------------------------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1.4;
  white-space: nowrap;
}

.badge-new {
  background: var(--info-subtle);
  color: var(--info);
}

.badge-in-progress {
  background: var(--warning-subtle);
  color: var(--warning);
}

.badge-responded {
  background: var(--success-subtle);
  color: var(--success);
}

.badge-archived {
  background: rgba(90, 90, 112, 0.15);
  color: var(--text-tertiary);
}

.badge-accent {
  background: var(--accent-subtle);
  color: var(--accent);
}

/* ------------------------------------------------------------
   12. MODALS
   ------------------------------------------------------------ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: 20px;
  animation: fade-in 0.2s ease;
}
.modal-overlay[hidden] {
  display: none;
}

.modal-content {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slide-up-fade 0.3s ease;
}

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

.modal-title {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ------------------------------------------------------------
   13. TOAST NOTIFICATIONS
   ------------------------------------------------------------ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  min-width: 320px;
  max-width: 420px;
  background: rgba(15, 15, 24, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border-left: 3px solid var(--border-strong);
  animation: slide-in-right 0.3s ease;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-info { border-left-color: var(--info); }

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }

.toast-body { flex: 1; }

.toast-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px;
  transition: color var(--transition-fast);
}

.toast-close:hover { color: var(--text-primary); }

.toast.dismissing { animation: slide-out-right 0.3s ease forwards; }

/* ------------------------------------------------------------
   14. EMAIL PAGE — Split Pane
   ------------------------------------------------------------ */
.email-layout {
  display: flex;
  height: calc(100vh - 80px);
}

.email-list-pane {
  width: 380px;
  min-width: 300px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.email-list-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.email-list-search {
  flex: 1;
}

.email-list {
  flex: 1;
  overflow-y: auto;
}

.email-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.email-item:hover { background: var(--bg-surface-hover); }
.email-item.active { background: var(--sidebar-active); }

.email-item.unread .email-item-subject { font-weight: 700; color: var(--text-primary); }
.email-item.read .email-item-subject { font-weight: 400; color: var(--text-secondary); }

.email-item-checkbox {
  margin-top: 2px;
  flex-shrink: 0;
}

.email-item-content {
  flex: 1;
  min-width: 0;
}

.email-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.email-item-sender {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-item-date {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

.email-item-subject {
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.email-item-preview {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-item-star {
  flex-shrink: 0;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: color var(--transition-fast);
}

.email-item-star.starred { color: var(--warning); }
.email-item-star:hover { color: var(--warning); }

/* Reading pane */
.email-reading-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.email-reading-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.email-reading-subject {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.email-reading-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.email-reading-body {
  padding: 24px;
  flex: 1;
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text-primary);
}

.email-reply-bar {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}

.email-empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 0.875rem;
}

/* Compose modal (floating) */
.compose-modal {
  position: fixed;
  bottom: 0;
  right: 24px;
  width: 520px;
  max-height: 70vh;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: var(--z-modal);
  animation: slide-up-fade 0.3s ease;
}

.compose-modal.minimized { max-height: 48px; overflow: hidden; }

.compose-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  cursor: pointer;
}

.compose-header-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.compose-header-actions {
  display: flex;
  gap: 4px;
}

.compose-body { padding: 16px; flex: 1; overflow-y: auto; }

.compose-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ------------------------------------------------------------
   15. SEO / BLOG PAGE
   ------------------------------------------------------------ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 12px 20px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-display);
}

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

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Article form */
.article-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.article-form-main { grid-column: 1; }
.article-form-sidebar { grid-column: 2; }

.article-preview {
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-height: 300px;
}

/* Sitemap code block */
.code-block {
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.code-block .tag { color: var(--accent); }
.code-block .attr { color: var(--info); }
.code-block .string { color: var(--success); }

/* ------------------------------------------------------------
   16. ANIMATIONS
   ------------------------------------------------------------ */
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slide-up-fade {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slide-out-right {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

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

/* Stagger delay utility classes */
.stagger-1 { animation-delay: 0ms; }
.stagger-2 { animation-delay: 80ms; }
.stagger-3 { animation-delay: 160ms; }
.stagger-4 { animation-delay: 240ms; }
.stagger-5 { animation-delay: 320ms; }
.stagger-6 { animation-delay: 400ms; }
.stagger-7 { animation-delay: 480ms; }
.stagger-8 { animation-delay: 560ms; }

/* Animation utility */
.animate-slide-up {
  animation: slide-up-fade 0.4s ease both;
}

.animate-fade {
  animation: fade-in 0.3s ease both;
}

.animate-scale {
  animation: scale-in 0.3s ease both;
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-surface-hover) 25%,
    var(--border) 50%,
    var(--bg-surface-hover) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  width: 100%;
}

.skeleton-text.short { width: 60%; }
.skeleton-text.medium { width: 80%; }

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}

.skeleton-card {
  height: 120px;
  border-radius: var(--radius-lg);
}

/* ------------------------------------------------------------
   17. UTILITY CLASSES
   ------------------------------------------------------------ */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

.font-display { font-family: var(--font-display); }
.font-mono { font-family: var(--font-mono); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }

.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }

.p-sm { padding: 8px; }
.p-md { padding: 16px; }
.p-lg { padding: 24px; }

.w-full { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

.hidden { display: none !important; }

/* Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
}

.empty-state-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state-text {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  max-width: 360px;
}

/* ------------------------------------------------------------
   18. RESPONSIVE — MOBILE (< 768px)
   ------------------------------------------------------------ */
@media (max-width: 767px) {
  .mobile-header {
    display: flex;
  }

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

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

  .main-content {
    margin-left: 0;
    padding-top: 56px;
  }

  .sidebar.collapsed ~ .main-content {
    margin-left: 0;
  }

  .page-header {
    padding: 20px 16px 16px;
    flex-direction: column;
    align-items: flex-start;
  }

  .page-body {
    padding: 16px;
  }

  .page-title {
    font-size: 1.25rem;
  }

  /* Email: stack panes */
  .email-layout {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 56px);
  }

  .email-list-pane {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 50vh;
  }

  .email-reading-pane {
    min-height: 50vh;
  }

  /* Compose modal full-width on mobile */
  .compose-modal {
    right: 0;
    left: 0;
    width: 100%;
    max-height: 80vh;
  }

  /* Article form single column */
  .article-form {
    grid-template-columns: 1fr;
  }

  .article-form-sidebar { grid-column: 1; }

  /* Stats grid */
  .stats-grid {
    grid-template-columns: 1fr;
  }

  /* Toast */
  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .toast {
    min-width: 0;
    max-width: 100%;
  }

  /* Modal */
  .modal-content {
    max-width: 100%;
    margin: 0 8px;
  }

  .modal-body { padding: 16px; }
  .modal-header { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; }

  /* Login */
  .login-card {
    margin: 0 16px;
    padding: 32px 24px;
  }
}

/* Tablet breakpoint */
@media (min-width: 768px) and (max-width: 1024px) {
  .email-list-pane {
    width: 300px;
    min-width: 260px;
  }

  .page-header {
    padding: 24px;
  }

  .page-body {
    padding: 20px 24px;
  }
}
