/* ============================================
   COMPONENTS — Premium UI Components
   ============================================ */

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-5);
  font-family: var(--font-primary);
  font-size: var(--text-body-sm);
  font-weight: var(--font-semibold);
  line-height: 1;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  outline: none;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.01em;
}

.btn:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-primary-ring);
}

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

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent-gradient-btn);
  color: var(--color-900);
  box-shadow: 0 2px 12px rgba(123,189,232,0.2);
}

.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(123,189,232,0.3);
  filter: brightness(1.05);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

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

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

.btn-ghost:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
}

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

.btn-danger:hover {
  background: #DC2626;
  box-shadow: 0 4px 16px rgba(239,68,68,0.3);
}

.btn-sm {
  min-height: 34px;
  padding: 0 var(--space-3);
  font-size: var(--text-caption);
  border-radius: var(--radius-sm);
}

.btn-lg {
  min-height: 52px;
  padding: 0 var(--space-8);
  font-size: var(--text-body);
  border-radius: var(--radius-md);
}

.btn-xl {
  min-height: 58px;
  padding: 0 var(--space-10);
  font-size: 1.0625rem;
  border-radius: var(--radius-lg);
}

.btn-icon {
  min-height: 40px;
  min-width: 40px;
  padding: 0;
}

.btn-icon.btn-sm {
  min-height: 34px;
  min-width: 34px;
}

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

/* ---- INPUTS ---- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

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

.form-label {
  font-size: var(--text-body-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-input,
.form-textarea,
.form-select,
textarea.form-input,
select.form-input {
  width: 100%;
  min-height: 48px;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-primary);
  font-size: var(--text-body-sm);
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition-normal);
}

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

.form-input:hover,
.form-textarea:hover,
.form-select:hover,
textarea.form-input:hover,
select.form-input:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus,
textarea.form-input:focus,
select.form-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-ring);
  background: var(--surface);
}

.form-input.error,
.form-textarea.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-subtle);
}

.form-textarea,
textarea.form-input {
  min-height: 110px;
  resize: vertical;
  line-height: var(--leading-relaxed);
}

.form-select,
select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394A3B8' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 5.646a.5.5 0 0 1 .708 0L8 8.293l2.646-2.647a.5.5 0 0 1 .708.708l-3 3a.5.5 0 0 1-.708 0l-3-3a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  padding-right: var(--space-10);
  cursor: pointer;
}

.form-helper {
  font-size: var(--text-caption);
  color: var(--text-tertiary);
  line-height: var(--leading-normal);
}

.form-error {
  font-size: var(--text-caption);
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* ---- TOGGLE SWITCH ---- */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  transition: all var(--transition-normal);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: all var(--transition-normal);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #fff;
}

/* ---- CHIPS ---- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-primary);
  font-size: var(--text-body-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.chip:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.12);
}

.chip.active {
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
  border-color: rgba(56,189,248,0.3);
}

/* ---- SELECTABLE CARD ---- */
.selectable-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-3);
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-normal);
  text-align: center;
  position: relative;
}

.selectable-card:hover {
  background: var(--surface);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.selectable-card.selected {
  background: rgba(56,189,248,0.06);
  border-color: var(--accent-primary);
  box-shadow: 0 0 20px rgba(56,189,248,0.08);
}

.selectable-card.selected::after {
  content: '\2713';
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-primary);
  color: var(--color-900);
  border-radius: 50%;
  font-size: 11px;
  font-weight: var(--font-bold);
}

/* ---- STEPPER ---- */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
}

.stepper-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
  position: relative;
}

.stepper-item:last-child {
  flex: 0;
}

.stepper .stepper-number {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: var(--text-body-sm);
  font-weight: var(--font-bold);
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  border: 2px solid var(--border);
  transition: all var(--transition-normal);
  margin-bottom: var(--space-2);
}

.stepper .stepper-item.active .stepper-number {
  background: var(--accent-gradient-btn);
  color: var(--color-900);
  border-color: transparent;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.25);
}

.stepper .stepper-item.completed .stepper-number {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.stepper-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 var(--space-2);
  transition: background var(--transition-normal);
  margin-bottom: var(--space-6);
  border-radius: 1px;
}

.stepper-label {
  font-size: var(--text-caption);
  color: var(--text-tertiary);
  white-space: nowrap;
  font-weight: var(--font-medium);
  transition: color var(--transition-fast);
}

.stepper-item.active .stepper-label {
  color: var(--accent-primary);
}

.stepper-item.completed .stepper-label {
  color: var(--success);
}

/* ---- PROGRESS BAR ---- */
.progress-bar {
  width: 100%;
  height: 5px;
  background: var(--surface);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill,
.progress-bar-fill {
  height: 100%;
  background: var(--accent-gradient-btn);
  border-radius: var(--radius-full);
  transition: width 0.35s ease;
}

.progress-bar-fill.success {
  background: var(--success);
}

/* ---- TABS ---- */
.tabs {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-primary);
  font-size: var(--text-body-sm);
  font-weight: var(--font-medium);
  color: var(--text-tertiary);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

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

.tab.active {
  color: var(--text-primary);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.tab-content {
  animation: fadeIn 0.3s ease;
}

/* ---- ACCORDION ---- */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-secondary);
}

.accordion-item {
  border-bottom: 1px solid var(--border-subtle);
}

.accordion-item:last-child {
  border-bottom: none;
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-5) var(--space-6);
  font-family: var(--font-primary);
  font-size: var(--text-body);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  background: none;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.accordion-header:hover {
  background: rgba(255,255,255,0.02);
}

.accordion-icon {
  width: 18px;
  height: 18px;
  transition: transform var(--transition-normal);
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.accordion-item.open .accordion-icon {
  transform: rotate(180deg);
  color: var(--accent-primary);
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-slow);
}

.accordion-item.open .accordion-body {
  max-height: 500px;
}

.accordion-content {
  padding: 0 var(--space-6) var(--space-5);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

/* ---- TOAST ---- */
.toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  min-width: 300px;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast-icon {
  flex-shrink: 0;
  font-size: 16px;
}

.toast-message {
  flex: 1;
  font-size: var(--text-body-sm);
  color: var(--text-primary);
}

.toast-close {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  transition: all var(--transition-fast);
}

.toast-close:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}

.toast.success { border-left: 3px solid var(--success); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent-primary); }

/* ---- CARD ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-card);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

.card-clickable {
  cursor: pointer;
}

.card-clickable:hover {
  background: var(--surface-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ---- NAVBAR ---- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  display: flex;
  align-items: center;
  background: rgba(7, 11, 20, 0.8);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border-bottom: 1px solid var(--border);
  z-index: var(--z-sticky);
  padding: 0 var(--space-6);
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
}

.navbar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 1.125rem;
  font-weight: var(--font-bold);
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.navbar-logo-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient-btn);
  color: var(--color-900);
  border-radius: var(--radius-sm);
  font-weight: var(--font-extrabold);
  font-size: 16px;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.navbar-links .navbar-link,
.navbar-link {
  font-size: var(--text-body-sm);
  font-weight: var(--font-medium);
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color var(--transition-fast);
  position: relative;
}

.navbar-links .navbar-link:hover,
.navbar-link:hover {
  color: var(--text-primary);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.mobile-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 18px;
}

@media (max-width: 768px) {
  .navbar-links {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    flex-direction: column;
    background: rgba(7,11,20,0.95);
    backdrop-filter: blur(20px);
    padding: var(--space-6);
    gap: var(--space-4);
    border-bottom: 1px solid var(--border);
    z-index: var(--z-sticky);
    animation: fadeInDown 0.2s ease;
  }
  .navbar-links.open {
    display: flex;
  }
  .mobile-menu-btn {
    display: flex;
  }
  .navbar-actions .hide-mobile {
    display: none;
  }
}

/* ---- HERO SECTION ---- */
.hero-section {
  padding: calc(var(--navbar-height) + var(--space-20)) 0 var(--space-20);
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -30%;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 600px;
  background: radial-gradient(ellipse, rgba(56,189,248,0.08) 0%, rgba(129,140,248,0.04) 40%, transparent 70%);
  pointer-events: none;
  animation: orbFloat1 20s ease-in-out infinite;
}

.hero-section::after {
  content: '';
  position: absolute;
  bottom: -20%;
  right: -10%;
  width: 500px;
  height: 400px;
  background: radial-gradient(ellipse, rgba(192,132,252,0.05) 0%, transparent 70%);
  pointer-events: none;
  animation: orbFloat2 25s ease-in-out infinite;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-body-sm);
  font-weight: var(--font-medium);
  color: var(--accent-primary);
  background: rgba(56,189,248,0.06);
  border: 1px solid rgba(56,189,248,0.15);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-6);
  backdrop-filter: blur(8px);
}

.hero-title {
  font-size: var(--text-display-xl);
  font-weight: var(--font-extrabold);
  line-height: var(--leading-tight);
  margin-bottom: var(--space-5);
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
  letter-spacing: -0.03em;
}

.hero-subtitle {
  font-size: 1.0625rem;
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  max-width: 560px;
  margin: 0 auto var(--space-8);
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* ---- SECTION HELPERS ---- */
.section-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-4);
  font-size: var(--text-body-sm);
  font-weight: var(--font-semibold);
  color: var(--accent-primary);
  background: var(--accent-primary-subtle);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-4);
}

.section-title {
  font-size: var(--text-h2);
  font-weight: var(--font-bold);
  margin-bottom: var(--space-3);
  letter-spacing: -0.02em;
}

.section-subtitle {
  font-size: var(--text-body);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

/* ---- FOOTER ---- */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: var(--space-12) 0 var(--space-8);
}

.footer-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-8);
  padding-bottom: var(--space-8);
  flex-wrap: wrap;
}

.footer-brand p {
  margin-top: var(--space-3);
  font-size: var(--text-body-sm);
  max-width: 300px;
}

.footer-links {
  display: flex;
  gap: var(--space-6);
}

.footer-link {
  font-size: var(--text-body-sm);
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: var(--space-6);
  border-top: 1px solid var(--border-subtle);
}

@media (max-width: 768px) {
  .footer-inner {
    flex-direction: column;
    gap: var(--space-6);
  }
  .footer-links {
    flex-wrap: wrap;
    gap: var(--space-4);
  }
}

/* ---- LOADING OVERLAY (fullscreen) ---- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7,11,20,0.92);
  backdrop-filter: blur(12px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.loading-content {
  text-align: center;
  max-width: 360px;
  padding: var(--space-8);
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(56,189,248,0.15);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}

/* ---- REPEATABLE ROW ---- */
.repeatable-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.repeatable-row .form-input {
  flex: 1;
  min-height: 44px;
}

/* ---- COLOR SWATCHES ---- */
.color-swatch {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 3px solid transparent;
  transition: all var(--transition-fast);
  position: relative;
}

.color-swatch:hover {
  transform: scale(1.12);
}

.color-swatch.selected {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--text-primary);
  transform: scale(1.08);
}

.color-swatch.selected::after {
  content: '\2713';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

/* ---- BADGE ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-caption);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-default { background: var(--surface); color: var(--text-secondary); }
.badge-primary { background: var(--accent-primary-subtle); color: var(--accent-primary); }
.badge-success { background: var(--success-subtle); color: var(--success); }
.badge-warning { background: var(--warning-subtle); color: var(--warning); }
.badge-danger { background: var(--danger-subtle); color: var(--danger); }

/* ---- SKELETON LOADER ---- */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ---- TOOLTIP ---- */
.tooltip-wrapper {
  position: relative;
  display: inline-flex;
}

.tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-caption);
  color: var(--text-primary);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  z-index: var(--z-tooltip);
  pointer-events: none;
  box-shadow: var(--shadow-md);
}

.tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--surface-hover);
}

.tooltip-wrapper:hover .tooltip {
  opacity: 1;
  visibility: visible;
}

/* ---- MODAL ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal-backdrop);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  animation: fadeIn 0.2s ease;
}

.modal-backdrop.active {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: scaleIn 0.25s ease;
}

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

.modal-title {
  font-size: var(--text-h3);
  font-weight: var(--font-semibold);
}

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

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

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
}

/* ---- EMPTY STATE ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-6);
  text-align: center;
}

.empty-state-icon {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
  color: var(--text-tertiary);
}

/* ---- ADMIN TABLE ---- */
.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table thead tr {
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-caption);
  color: var(--text-tertiary);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-table td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-body-sm);
  border-bottom: 1px solid var(--border-subtle);
}

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

.admin-table tbody tr:hover {
  background: rgba(255,255,255,0.02);
}

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

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

.admin-sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: var(--space-6);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.admin-main {
  flex: 1;
  padding: var(--space-8);
  overflow-y: auto;
  background: var(--bg-primary);
}

.admin-nav {
  list-style: none;
  padding: 0;
  margin: var(--space-6) 0 0 0;
}

.admin-nav li {
  margin-bottom: var(--space-1);
}

.admin-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--text-body-sm);
  font-weight: var(--font-medium);
  transition: all var(--transition-fast);
}

.admin-nav a:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
}

.admin-nav a.active {
  background: rgba(56,189,248,0.08);
  color: var(--accent-primary);
}

.stat-card {
  padding: var(--space-6);
}

.stat-value {
  font-size: 2rem;
  font-weight: var(--font-extrabold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: var(--text-body-sm);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

@media (max-width: 768px) {
  .admin-layout {
    flex-direction: column;
  }
  .admin-sidebar {
    width: 100%;
    height: auto;
    position: relative;
    padding: var(--space-4);
  }
  .admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin-top: var(--space-3);
  }
  .admin-nav li {
    margin-bottom: 0;
  }
  .admin-main {
    padding: var(--space-4);
  }
}

/* ---- SIDEBAR (generic) ---- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sticky);
  transition: transform var(--transition-normal);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5);
  border-bottom: 1px solid var(--border);
  min-height: var(--navbar-height);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  font-size: var(--text-body-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

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

.sidebar-link.active {
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
}

/* ---- PREVIEW FRAME ---- */
.preview-frame-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.preview-frame-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.preview-frame-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.preview-frame-dot.red { background: #EF4444; }
.preview-frame-dot.yellow { background: #F59E0B; }
.preview-frame-dot.green { background: #22C55E; }
