/* ============================================================
   STATECH MES — Premium Design System v24.0
   Enterprise-Grade CSS: Tokens + Premium Utility Classes
   ============================================================ */

/* ═══ DESIGN TOKENS ═══
 * v33.0: Alle --st-* leiten auf brand-core.css-Vars weiter,
 * damit das Theme-System im Design-Studio auch statech-theme-basierte
 * Seiten brandet. Fallbacks bleiben fuer Legacy-Vorvisualisierung.
 */
:root {
  /* Surfaces → Brand-Tokens */
  --st-surface: var(--brand-surface, #ffffff);
  --st-surface-hover: var(--brand-surface-alt, #f9fafb);
  --st-surface-active: var(--brand-surface-alt, #f3f4f6);
  --st-canvas: var(--brand-bg, #f8fafc);

  /* Text → Brand-Tokens */
  --st-text-primary: var(--brand-text, #1f2937);
  --st-text-secondary: var(--brand-text-muted, #4b5563);
  --st-text-muted: var(--brand-text-subtle, var(--brand-text-muted, #9ca3af));

  /* Borders → Brand-Tokens */
  --st-border: var(--brand-border, #e5e7eb);
  --st-border-light: var(--brand-border, #f3f4f6);

  /* Brand → direct Brand-Tokens */
  --st-primary: var(--brand-primary-600, #3b82f6);
  --st-primary-light: var(--brand-primary-100, #dbeafe);
  --st-primary-dark: var(--brand-primary-700, #2563eb);

  /* Accent: v33 aus brand-accent */
  --st-accent: var(--brand-accent-500, #14b8a6);
  --st-accent-light: var(--brand-accent-50, #ccfbf1);

  /* Sekundaer: aus brand-accent */
  --st-secondary: var(--brand-accent-500, #f97316);
  --st-secondary-light: var(--brand-accent-50, #fff7ed);

  /* Erweiterte Palette */
  --st-coral: #f43f5e;
  --st-coral-light: #fff1f2;
  --st-indigo: #6366f1;
  --st-indigo-light: #eef2ff;
  --st-emerald: #10b981;
  --st-emerald-light: #d1fae5;
  --st-amber: #f59e0b;
  --st-amber-light: #fef3c7;

  /* Semantic Colors → Brand-Tokens */
  --st-success: var(--brand-success, #16a34a);
  --st-success-light: var(--brand-success-50, #dcfce7);
  --st-warning: var(--brand-warning, #f97316);
  --st-warning-light: var(--brand-warning-50, #ffedd5);
  --st-danger: var(--brand-error, #dc2626);
  --st-danger-light: var(--brand-error-50, #fee2e2);
  --st-info: var(--brand-primary-500, #0ea5e9);
  --st-info-light: var(--brand-primary-50, #e0f2fe);

  /* Shadows */
  --st-shadow-xs: 0 1px 2px rgba(0,0,0,.04);
  --st-shadow-sm: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
  --st-shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --st-shadow-lg: 0 10px 25px -5px rgba(0,0,0,.08), 0 8px 10px -6px rgba(0,0,0,.04);
  --st-shadow-xl: 0 20px 50px -12px rgba(0,0,0,.15);

  /* Radii */
  --st-radius-sm: 0.5rem;
  --st-radius-md: 0.75rem;
  --st-radius-lg: 1rem;
  --st-radius-xl: 1.25rem;
  --st-radius-2xl: 1.5rem;

  /* Fonts — v33 brand fallback */
  --st-font: var(--brand-font, 'DM Sans', -apple-system, sans-serif);
  --st-font-mono: var(--brand-font-mono, 'JetBrains Mono', 'Fira Code', monospace);

  /* Overlay */
  --st-overlay: rgba(15, 23, 42, 0.5);
  --st-backdrop-blur: blur(4px);

  /* Easing */
  --st-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --st-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ═══ DARK MODE ═══ */
[data-theme="dark"] {
  --st-surface: #1e293b;
  --st-surface-hover: #334155;
  --st-surface-active: #475569;
  --st-canvas: #0f172a;
  --st-text-primary: #f1f5f9;
  --st-text-secondary: #cbd5e1;
  --st-text-muted: #64748b;
  --st-border: #334155;
  --st-border-light: #1e293b;
  --st-primary: #3b82f6;
  --st-primary-light: #1e3a5f;
  --st-accent: #2dd4bf;
  --st-accent-light: #042f2e;
  --st-secondary: #fb923c;
  --st-secondary-light: #431407;
  --st-overlay: rgba(0,0,0,.6);
  --st-shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --st-shadow-md: 0 4px 6px rgba(0,0,0,.4);
  --st-shadow-lg: 0 10px 25px rgba(0,0,0,.5);
}

/* ═══ PAGE BACKGROUND ═══ */
.st-page {
  background: linear-gradient(135deg, #f8fafc 0%, #f0fdfa 40%, #eef2ff 70%, #f8fafc 100%);
  color: var(--st-text-primary);
  font-family: var(--st-font);
  min-height: 100vh;
}
[data-theme="dark"] .st-page { background: linear-gradient(135deg, #0f172a 0%, #0d2b2a 40%, #1e1b4b 70%, #0f172a 100%); }
[v-cloak] { display: none; }
.mono { font-family: var(--st-font-mono); }

/* ═══ PREMIUM CARD ═══ */
.st-card {
  background: var(--st-surface);
  border-radius: var(--st-radius-2xl);
  border: 1px solid rgba(0,0,0,.05);
  box-shadow: var(--st-shadow-sm), 0 0 0 1px rgba(0,0,0,.02);
  transition: all .3s var(--st-ease);
}
.st-card:hover {
  box-shadow: var(--st-shadow-lg), 0 0 0 1px rgba(59,130,246,.08);
  transform: translateY(-2px);
}
.st-card-flat { composes: st-card; }
.st-card-flat:hover { transform: none; }

/* ═══ KPI CARD ═══ */
.st-kpi {
  background: var(--st-surface);
  border-radius: var(--st-radius-2xl);
  border: 1px solid rgba(0,0,0,.06);
  box-shadow: var(--st-shadow-sm);
  position: relative;
  overflow: hidden;
  padding: 1.25rem;
  transition: all .3s var(--st-ease);
}
.st-kpi:hover { box-shadow: var(--st-shadow-md); transform: translateY(-1px); }
.st-kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--st-radius-2xl) var(--st-radius-2xl) 0 0;
  background: linear-gradient(90deg, var(--st-primary), var(--st-accent));
}
.st-kpi.kpi-blue::before { background: linear-gradient(90deg, #3b82f6, #14b8a6); }
.st-kpi.kpi-green::before { background: linear-gradient(90deg, #10b981, #14b8a6); }
.st-kpi.kpi-yellow::before { background: linear-gradient(90deg, #f59e0b, #f97316); }
.st-kpi.kpi-red::before { background: linear-gradient(90deg, #f43f5e, #dc2626); }
.st-kpi.kpi-violet::before { background: linear-gradient(90deg, #6366f1, #8b5cf6); }
.st-kpi.kpi-orange::before { background: linear-gradient(90deg, #f97316, #f43f5e); }
.st-kpi.kpi-amber::before { background: linear-gradient(90deg, #f59e0b, #d97706); }
.st-kpi.kpi-cyan::before { background: linear-gradient(90deg, #06b6d4, #14b8a6); }
.st-kpi.kpi-teal::before { background: linear-gradient(90deg, #14b8a6, #10b981); }
.st-kpi.kpi-coral::before { background: linear-gradient(90deg, #f43f5e, #f97316); }
.st-kpi.kpi-indigo::before { background: linear-gradient(90deg, #6366f1, #3b82f6); }
.st-kpi-value { font-family: var(--st-font-mono); font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.st-kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--st-text-muted); }

/* ═══ BUTTONS ═══ */
.st-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.625rem 1.25rem; font-size: 0.875rem; font-weight: 600;
  border-radius: var(--st-radius-lg); transition: all .2s var(--st-ease);
  cursor: pointer; border: none; outline: none; white-space: nowrap;
}
.st-btn-primary {
  background: linear-gradient(135deg, #3b82f6, #14b8a6);
  color: white; box-shadow: 0 2px 8px rgba(59,130,246,.3);
}
.st-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(20,184,166,.35); }
.st-btn-accent {
  background: linear-gradient(135deg, #14b8a6, #10b981);
  color: white; box-shadow: 0 2px 8px rgba(20,184,166,.3);
}
.st-btn-accent:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(20,184,166,.4); }
.st-btn-warning {
  background: linear-gradient(135deg, #f97316, #f59e0b);
  color: white; box-shadow: 0 2px 8px rgba(249,115,22,.3);
}
.st-btn-warning:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(249,115,22,.4); }
.st-btn-secondary {
  background: var(--st-surface); color: var(--st-text-primary);
  border: 1.5px solid var(--st-border);
}
.st-btn-secondary:hover { background: var(--st-surface-hover); border-color: #cbd5e1; }
.st-btn-danger {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: white; box-shadow: 0 2px 8px rgba(220,38,38,.3);
}
.st-btn-danger:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(220,38,38,.4); }
.st-btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; border-radius: var(--st-radius-md); }
.st-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ═══ INPUTS ═══ */
.st-input, .st-select, .st-textarea {
  width: 100%; border: 1.5px solid var(--st-border);
  border-radius: var(--st-radius-lg); padding: 0.625rem 0.875rem;
  font-size: 0.875rem; font-family: var(--st-font);
  background: var(--st-surface); color: var(--st-text-primary);
  transition: all .2s var(--st-ease); outline: none;
}
.st-input:focus, .st-select:focus, .st-textarea:focus {
  border-color: var(--st-primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.st-textarea { min-height: 100px; resize: vertical; }

/* ═══ BADGES ═══ */
.st-badge {
  display: inline-flex; align-items: center; padding: 2px 10px;
  border-radius: 9999px; font-size: 11px; font-weight: 600; letter-spacing: .02em;
}
.st-badge-green { background: #dcfce7; color: #166534; }
.st-badge-blue { background: #dbeafe; color: #1e40af; }
.st-badge-red { background: #fee2e2; color: #991b1b; }
.st-badge-yellow { background: #fef3c7; color: #92400e; }
.st-badge-orange { background: #ffedd5; color: #9a3412; }
.st-badge-violet { background: #ede9fe; color: #5b21b6; }
.st-badge-gray { background: #f3f4f6; color: #4b5563; }
.st-badge-amber { background: #fef3c7; color: #78350f; }
.st-badge-cyan { background: #cffafe; color: #155e75; }
.st-badge-emerald { background: #d1fae5; color: #065f46; }
.st-badge-teal { background: #ccfbf1; color: #115e59; }
.st-badge-coral { background: #fff1f2; color: #9f1239; }
.st-badge-indigo { background: #eef2ff; color: #3730a3; }

/* ═══ TABS ═══ */
.st-tab {
  padding: 0.625rem 1rem; font-size: 0.875rem; font-weight: 500;
  border-bottom: 2px solid transparent; color: var(--st-text-muted);
  transition: all .2s var(--st-ease); cursor: pointer; white-space: nowrap;
}
.st-tab:hover { color: var(--st-text-secondary); border-color: #d1d5db; }
.st-tab-active, .st-tab.active {
  color: var(--st-primary); border-color: var(--st-primary);
  background: linear-gradient(to top, rgba(37,99,235,.06), transparent);
  font-weight: 600;
}

/* ═══ TABLES ═══ */
.st-table { width: 100%; font-size: 0.875rem; border-collapse: collapse; }
.st-table thead th {
  background: #f8fafc; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: #64748b; padding: 0.75rem 1rem; text-align: left;
  border-bottom: 1px solid var(--st-border);
}
.st-table tbody td { padding: 0.75rem 1rem; border-bottom: 1px solid #f1f5f9; }
.st-table tbody tr { transition: background .15s; }
.st-table tbody tr:hover { background: rgba(59,130,246,.03); }
.st-table-dark thead th {
  background: #334155; color: #e2e8f0; border-bottom: 1px solid #475569;
}

/* ═══ MODALS ═══ */
.st-modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: var(--st-overlay);
  -webkit-backdrop-filter: var(--st-backdrop-blur);
  backdrop-filter: var(--st-backdrop-blur);
}
.st-modal {
  background: var(--st-surface);
  border-radius: var(--st-radius-2xl);
  box-shadow: var(--st-shadow-xl);
  width: 100%; max-width: 32rem; margin: 1rem;
  padding: 1.5rem; animation: st-fadeIn .2s var(--st-ease);
}
.st-modal-lg { max-width: 48rem; }
.st-modal-title { font-size: 1.125rem; font-weight: 700; color: var(--st-text-primary); margin-bottom: 1rem; }

/* ═══ HEADER ═══ */
.st-header {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem;
}
.st-header-icon {
  width: 3rem; height: 3rem; border-radius: var(--st-radius-xl);
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #3b82f6, #14b8a6);
  color: white; font-size: 1.25rem; flex-shrink: 0;
}
.st-header-title { font-size: 1.375rem; font-weight: 700; color: var(--st-text-primary); }
.st-header-subtitle { font-size: 0.875rem; color: var(--st-text-muted); margin-top: 0.125rem; }

/* ═══ FILTER BAR ═══ */
.st-filter-bar {
  display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  background: var(--st-surface); border-radius: var(--st-radius-2xl);
  border: 1px solid rgba(0,0,0,.06); box-shadow: var(--st-shadow-xs);
  padding: 1rem;
}

/* ═══ EMPTY STATE ═══ */
.st-empty {
  display: flex; flex-direction: column; align-items: center;
  padding: 3rem 1rem; color: var(--st-text-muted); text-align: center;
}
.st-empty-icon { font-size: 2.5rem; margin-bottom: 1rem; opacity: .4; }
.st-empty-text { font-size: 0.9375rem; font-weight: 500; }
.st-empty-hint { font-size: 0.8125rem; margin-top: 0.25rem; }

/* ═══ TOAST ═══ */
.st-toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 100;
  padding: 0.875rem 1.25rem; border-radius: var(--st-radius-lg);
  font-size: 0.875rem; font-weight: 500; box-shadow: var(--st-shadow-lg);
  animation: st-slideIn .3s var(--st-ease);
}
.st-toast-success { background: #059669; color: white; }
.st-toast-error { background: #dc2626; color: white; }
.st-toast-warning { background: #d97706; color: white; }

/* ═══ ANIMATIONS ═══ */
@keyframes st-fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes st-slideIn { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }
@keyframes st-countUp { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
@keyframes st-pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
@keyframes st-ring-fill { from { stroke-dashoffset: var(--st-ring-circumference, 283); } to { stroke-dashoffset: var(--st-ring-offset, 0); } }
@keyframes st-spin { to { transform: rotate(360deg); } }

.st-animate-in { animation: st-fadeIn .4s var(--st-ease); }
.st-count-up { animation: st-countUp .5s var(--st-ease); }
.st-pulse-dot { animation: st-pulse 2s ease-in-out infinite; }
.st-ring-animated { animation: st-ring-fill 1s ease-out forwards; }
.st-spin { animation: st-spin 1s linear infinite; }

/* ═══ UTILITY ═══ */
.st-text-primary { color: var(--st-text-primary); }
.st-text-secondary { color: var(--st-text-secondary); }
.st-text-muted { color: var(--st-text-muted); }
.st-bg-surface { background: var(--st-surface); }
.st-glass { background: rgba(255,255,255,.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.st-divider { height: 1px; background: var(--st-border); margin: 1rem 0; }
.st-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
