/* =============================================================================
   CI-KIT — Portfolio Corporate Identity
   Eine einheitliche UI-Sprache für alle Apps des Portfolios.

   Stil:   luftig & rund (Basis: uhren-projekt), Indigo-Akzent.
   Themes: Dark (Default) + Light via  <html data-theme="light|dark">
   Stack:  Framework-agnostisch. Funktioniert in React (var(--accent)),
           Jinja2/HTML, Svelte, plain HTML — überall wo CSS geladen wird.

   Aufbau:  1) Tokens   2) Base/Reset   3) Komponenten   4) Utilities
   Version: 1.0.0
   ========================================================================== */

/* =============================================================================
   1) TOKENS
   ========================================================================== */

:root,
html[data-theme="dark"] {
  color-scheme: dark;            /* native Controls (Scrollbar, Inputs) dunkel */

  /* -- Flächen / Neutrale Palette ------------------------------------------ */
  --bg:           #0c0d10;
  --surface:      #17191f;
  --surface-2:    #1f222a;
  --surface-3:    #262a33;
  --border:       rgba(255, 255, 255, .08);
  --border-strong:rgba(255, 255, 255, .16);

  /* -- Text ----------------------------------------------------------------- */
  --text:         #e7e9ee;
  --muted:        #9298a3;

  /* -- Akzent (Indigo) ------------------------------------------------------ */
  --accent:        #6c8cff;
  --accent-hover:  #82a0ff;
  --accent-soft:   rgba(108, 140, 255, .16);
  --accent-contrast:#ffffff;

  /* -- Status --------------------------------------------------------------- */
  --success:      #46c08a;  --success-soft: rgba(70, 192, 138, .18);
  --danger:       #ef6b6b;  --danger-soft:  rgba(239, 107, 107, .20);
  --warning:      #e0a32b;  --warning-soft: rgba(230, 170, 40, .22);
  --info:         var(--accent); --info-soft: var(--accent-soft);

  /* -- Effekte -------------------------------------------------------------- */
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, .30);
  --shadow:       0 8px 30px rgba(0, 0, 0, .35);
  --shadow-lg:    0 16px 48px rgba(0, 0, 0, .50);
  --overlay:      rgba(0, 0, 0, .55);
  --overlay-bd:   rgba(255, 255, 255, .28);
}

html[data-theme="light"] {
  color-scheme: light;

  --bg:           #f3f4f7;
  --surface:      #ffffff;
  --surface-2:    #f5f6f9;
  --surface-3:    #eceef3;
  --border:       rgba(20, 24, 40, .10);
  --border-strong:rgba(20, 24, 40, .18);

  --text:         #1c2230;
  --muted:        #6b7280;

  --accent:        #4f6ef2;
  --accent-hover:  #3f5ee0;
  --accent-soft:   rgba(79, 110, 242, .12);
  --accent-contrast:#ffffff;

  --success:      #2f9e6e;  --success-soft: rgba(47, 158, 110, .14);
  --danger:       #e0524f;  --danger-soft:  rgba(224, 82, 79, .14);
  --warning:      #c9871a;  --warning-soft: rgba(201, 135, 26, .16);

  --shadow-sm:    0 1px 2px rgba(20, 24, 40, .06);
  --shadow:       0 6px 22px rgba(20, 24, 40, .08);
  --shadow-lg:    0 16px 48px rgba(20, 24, 40, .16);
  --overlay:      rgba(20, 24, 40, .35);
  --overlay-bd:   rgba(0, 0, 0, .18);
}

:root {
  /* -- Typografie (theme-unabhängig) --------------------------------------- */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --fs-xs:  0.6875rem;  /* 11px — Mikro-Labels, Badges            */
  --fs-sm:  0.8125rem;  /* 13px — Hilfstext, Buttons, Inputs      */
  --fs-md:  0.875rem;   /* 14px — Body (Default)                  */
  --fs-lg:  0.9375rem;  /* 15px — Card-Titel (h2)                 */
  --fs-xl:  1.125rem;   /* 18px — Seiten-/Brand-Titel (h1)        */
  --fs-2xl: 1.375rem;   /* 22px — Hero                            */
  --fs-3xl: 1.75rem;    /* 28px — Display                         */

  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;

  --lh-tight: 1.25;
  --lh-base:  1.5;

  /* -- Spacing (8px-Basis) ------------------------------------------------- */
  --space-1: 0.25rem;  /*  4px */
  --space-2: 0.5rem;   /*  8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.5rem;   /* 24px */
  --space-6: 2rem;     /* 32px */
  --space-7: 2.5rem;   /* 40px */

  /* -- Radius (rund/luftig) ------------------------------------------------- */
  --radius-xs:   6px;
  --radius-sm:   8px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   18px;   /* Cards */
  --radius-pill: 999px;

  /* -- Bewegung ------------------------------------------------------------- */
  --transition-fast:  .12s ease;
  --transition:       .15s ease;
  --transition-theme: .25s ease;

  /* -- Layout --------------------------------------------------------------- */
  --sidebar-width: 300px;
  --container-max: 1200px;

  /* -- Ebenen --------------------------------------------------------------- */
  --z-dropdown: 100;
  --z-modal:    200;
  --z-toast:    300;

  /* -- Kategorische Palette (für Charts, Tags, Kategorien) ------------------ */
  --cat-red:    #ef4444;
  --cat-orange: #f97316;
  --cat-amber:  #eab308;
  --cat-green:  #22c55e;
  --cat-cyan:   #06b6d4;
  --cat-blue:   #3b82f6;
  --cat-violet: #8b5cf6;
  --cat-gray:   #6b7280;
}

/* =============================================================================
   2) BASE / RESET
   ========================================================================== */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--bg);
  transition: background var(--transition-theme), color var(--transition-theme);
}

h1, h2, h3, h4 { margin: 0; font-weight: var(--fw-semibold); line-height: var(--lh-tight); }
h1 { font-size: var(--fs-xl);  font-weight: var(--fw-bold); letter-spacing: .2px; }
h2 { font-size: var(--fs-lg);  margin-bottom: var(--space-4); letter-spacing: .2px; }
h3 { font-size: var(--fs-sm);  color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: var(--space-5) 0 var(--space-1); }

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

code, kbd, pre { font-family: var(--font-mono); font-size: .9em; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: var(--radius-pill); border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Helfer-Klassen, die quer in beiden Referenzprojekten vorkamen */
.muted  { color: var(--muted); font-size: var(--fs-sm); }
.right  { text-align: right; }
.center { text-align: center; }
.ok     { color: var(--success); font-size: var(--fs-sm); }

/* =============================================================================
   3) KOMPONENTEN
   ========================================================================== */

/* -- Card ------------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: var(--space-5); }
.card-flush { padding: 0; overflow: hidden; }

/* -- Buttons --------------------------------------------------------------- */
/* Doppelt selektiert: canonical .btn (React) UND bare <button> (Jinja/HTML). */
.btn,
button:not(.unstyled) {
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), transform .05s, filter var(--transition);
}
.btn:hover,
button:not(.unstyled):hover { background: var(--surface-3); }
.btn:active,
button:not(.unstyled):active { transform: translateY(1px); }
.btn:disabled,
button:not(.unstyled):disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary, button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.btn-primary:hover, button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost, button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.btn-ghost:hover, button.ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-accent-soft, button.ghost-accent {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}
.btn-accent-soft:hover, button.ghost-accent:hover { filter: brightness(1.1); }

.btn-danger, button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover, button.danger:hover { filter: brightness(1.08); }

.btn-sm, button.sm { padding: var(--space-1) var(--space-3); font-size: var(--fs-xs); }
.btn-lg, button.lg { padding: var(--space-3) var(--space-5); font-size: var(--fs-md); }

.btn-icon, button.icon {
  border: none;
  background: none;
  color: inherit;
  opacity: .7;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}
.btn-icon:hover, button.icon:hover { opacity: 1; background: rgba(127,127,127,.15); }
.btn-icon:disabled, button.icon:disabled { opacity: .25; }

/* -- Pill (Toggle / Tag-Button) -------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-pill);
  padding: var(--space-2) var(--space-4);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.pill:hover { background: var(--surface-3); }
.pill.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

/* -- Formfelder ------------------------------------------------------------ */
.input, .select, .textarea,
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]),
select, textarea {
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  transition: border-color var(--transition), background var(--transition);
}
textarea { line-height: var(--lh-base); resize: vertical; }
.input:focus, .select:focus, .textarea:focus,
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); }

input[type="color"] { padding: 2px; width: 42px; height: 34px; cursor: pointer; border: 1px solid var(--border); border-radius: var(--radius-xs); background: var(--surface-2); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }

.field-label { display: block; font-size: var(--fs-sm); color: var(--muted); margin-bottom: var(--space-1); font-weight: var(--fw-medium); }

/* -- Badge & Chip ---------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  padding: 2px var(--space-2);
  border-radius: var(--radius-xs);
  background: var(--surface-3);
  color: var(--text);
  line-height: 1.4;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-warning { background: var(--warning-soft);  color: var(--warning); }
.badge-accent  { background: var(--accent-soft);   color: var(--accent); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.chip:hover { background: var(--surface-3); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

.swatch { display: inline-block; width: 22px; height: 22px; border-radius: var(--radius-xs); border: 1px solid var(--border); vertical-align: middle; }

/* -- Tabelle --------------------------------------------------------------- */
.table, table { width: 100%; border-collapse: collapse; }
.table th, .table td, table th, table td {
  text-align: left;
  padding: var(--space-2);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-md);
  vertical-align: middle;
}
.table th, table th {
  color: var(--muted);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.table tbody tr:last-child td, table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover, table.hoverable tbody tr:hover { background: var(--surface-2); }

/* -- List (Nav / Sidebar items) ------------------------------------------- */
.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.list-item {
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background var(--transition-fast);
}
.list-item:hover { background: var(--surface-3); }
.list-item.active { background: var(--accent-soft); color: var(--accent); font-weight: var(--fw-semibold); }

/* -- Modal ----------------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-4);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-5);
  width: 440px;
  max-width: 100%;
  max-height: 90vh;
  overflow: auto;
}
.modal-lg { width: 720px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }

/* -- Toast ----------------------------------------------------------------- */
.toast {
  position: fixed; bottom: var(--space-5); right: var(--space-5);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-sm);
  z-index: var(--z-toast);
  animation: ci-fade-in .2s ease;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-danger  { border-left: 3px solid var(--danger); }

/* -- Feedback (Spinner, Empty) -------------------------------------------- */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ci-spin .7s linear infinite;
}
.empty-state { padding: var(--space-7) var(--space-5); text-align: center; color: var(--muted); font-size: var(--fs-sm); }

/* -- Brand-Mark (Gradient-Dot + Titel) ------------------------------------ */
.brand { display: flex; align-items: center; gap: var(--space-3); }
.brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--cat-violet));
  box-shadow: 0 0 14px var(--accent-soft);
}
.brand .sub { font-size: var(--fs-sm); color: var(--muted); }

/* -- Layout-Bausteine ------------------------------------------------------ */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: var(--space-5) var(--space-5); }
.row     { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.actions { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; margin-top: var(--space-4); }

@keyframes ci-spin    { to { transform: rotate(360deg); } }
@keyframes ci-fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* =============================================================================
   4) UTILITIES (sparsam — die meiste Gestaltung läuft über Komponenten)
   ========================================================================== */

.text-xs { font-size: var(--fs-xs); }  .text-sm { font-size: var(--fs-sm); }
.text-lg { font-size: var(--fs-lg); }  .text-muted { color: var(--muted); }
.fw-medium { font-weight: var(--fw-medium); } .fw-semibold { font-weight: var(--fw-semibold); } .fw-bold { font-weight: var(--fw-bold); }

.flex { display: flex; } .flex-col { flex-direction: column; } .items-center { align-items: center; }
.justify-between { justify-content: space-between; } .gap-2 { gap: var(--space-2); } .gap-4 { gap: var(--space-4); }
.flex-1 { flex: 1; } .mt-4 { margin-top: var(--space-4); } .mt-5 { margin-top: var(--space-5); }

/* Respektiert das System-Setting „Bewegung reduzieren" (a11y). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ddd; }
  .no-print { display: none !important; }
}
