/* =========================================================
   TiMaS Sandbox
   GitHub-inspiriertes Light/Dark Design
   ========================================================= */

:root {
  color-scheme: light;

  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-secondary: #f6f8fa;

  --text: #1f2328;
  --text-muted: #656d76;

  --border: #d0d7de;
  --border-muted: #d8dee4;

  --primary: #1f883d;
  --primary-hover: #1a7f37;
  --primary-text: #ffffff;

  --link: #0969da;

  --overlay: rgba(31, 35, 40, 0.55);

  --shadow:
    0 1px 0 rgba(31, 35, 40, 0.04),
    0 8px 24px rgba(140, 149, 159, 0.2);

  --radius: 6px;
  --radius-large: 12px;
}


/* =========================================================
   Dark Theme
   ========================================================= */

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

  --bg: #0d1117;
  --surface: #161b22;
  --surface-secondary: #0d1117;

  --text: #e6edf3;
  --text-muted: #8d96a0;

  --border: #30363d;
  --border-muted: #21262d;

  --primary: #238636;
  --primary-hover: #2ea043;
  --primary-text: #ffffff;

  --link: #4493f8;

  --overlay: rgba(1, 4, 9, 0.76);

  --shadow:
    0 0 transparent,
    0 8px 24px rgba(1, 4, 9, 0.55);
}


/* =========================================================
   Grundlayout
   ========================================================= */

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;

  background: var(--bg);
  color: var(--text);

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Helvetica,
    Arial,
    sans-serif,
    "Apple Color Emoji",
    "Segoe UI Emoji";

  font-size: 14px;
  line-height: 1.5;

  transition:
    background-color 180ms ease,
    color 180ms ease;
}

button,
input,
select,
textarea {
  font: inherit;
}


/* =========================================================
   Header
   ========================================================= */

.topbar {
  min-height: 64px;

  display: flex;
  align-items: center;

  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;

  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.brand-icon {
  display: grid;
  place-items: center;

  width: 32px;
  height: 32px;

  background: var(--text);
  color: var(--surface);

  border-radius: 50%;

  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    monospace;

  font-size: 12px;
  font-weight: 700;
}


/* =========================================================
   Container
   ========================================================= */

.container {
  width: min(900px, calc(100% - 32px));
  margin: 48px auto;
}

.page-header {
  padding-bottom: 24px;
  margin-bottom: 24px;

  border-bottom: 1px solid var(--border-muted);
}

.page-header h1 {
  margin: 0 0 6px;

  font-size: 32px;
  line-height: 1.2;
  font-weight: 600;
}

.page-header p {
  margin: 0;

  color: var(--text-muted);
  font-size: 16px;
}


/* =========================================================
   Card
   ========================================================= */

.card {
  overflow: hidden;

  background: var(--surface);

  border: 1px solid var(--border);
  border-radius: var(--radius-large);

  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;

  padding: 20px 24px;

  background: var(--surface-secondary);
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  margin: 0 0 4px;

  font-size: 16px;
  font-weight: 600;
}

.card-header p {
  margin: 0;

  color: var(--text-muted);
}

.card-body {
  padding: 28px 24px;
}

.status-badge {
  flex: none;

  padding: 2px 9px;

  border: 1px solid var(--border);
  border-radius: 999px;

  color: var(--text-muted);

  font-size: 12px;
  font-weight: 600;
}

code {
  padding: 2px 5px;

  background: var(--surface-secondary);

  border: 1px solid var(--border-muted);
  border-radius: 4px;

  color: var(--text);

  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    monospace;

  font-size: 12px;
}


/* =========================================================
   Buttons
   ========================================================= */

.primary-button,
.theme-switcher {
  cursor: pointer;

  border-radius: var(--radius);

  font-weight: 600;

  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    transform 80ms ease;
}

.primary-button {
  padding: 8px 16px;

  background: var(--primary);
  color: var(--primary-text);

  border: 1px solid rgba(31, 35, 40, 0.15);

  box-shadow:
    0 1px 0 rgba(31, 35, 40, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.primary-button:hover {
  background: var(--primary-hover);
}

.primary-button:active {
  transform: translateY(1px);
}

.theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  min-height: 34px;
  padding: 5px 12px;

  background: var(--surface-secondary);
  color: var(--text);

  border: 1px solid var(--border);

  box-shadow: 0 1px 0 rgba(31, 35, 40, 0.04);
}

.theme-switcher:hover {
  background: var(--border-muted);
}

.theme-switcher:active {
  transform: translateY(1px);
}

.hint {
  margin: 12px 0 0;

  color: var(--text-muted);

  font-size: 12px;
}


/* =========================================================
   Lademaske
   ========================================================= */

.loading-overlay {
  position: fixed;
  z-index: 9999;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 24px;

  background: var(--overlay);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);

  opacity: 0;
  visibility: hidden;

  transition:
    opacity 160ms ease,
    visibility 160ms ease;
}

.loading-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.loading-dialog {
  width: min(360px, 100%);

  padding: 32px 28px;

  background: var(--surface);

  border: 1px solid var(--border);
  border-radius: var(--radius-large);

  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.25);

  text-align: center;

  transform: translateY(8px) scale(0.98);

  transition: transform 180ms ease;
}

.loading-overlay.is-visible .loading-dialog {
  transform: translateY(0) scale(1);
}


/*
   wait.gif kann im Original riesig sein.
   Hier wird es nur klein dargestellt.

   object-fit verhindert Verzerrungen.
*/
.loading-image-wrapper {
  width: 84px;
  height: 84px;

  display: flex;
  align-items: center;
  justify-content: center;

  margin: 0 auto 18px;

  overflow: hidden;

  background: var(--surface-secondary);

  border: 1px solid var(--border-muted);
  border-radius: 18px;
}

.loading-image {
  display: block;

  max-width: 68px;
  max-height: 68px;

  width: auto;
  height: auto;

  object-fit: contain;
}

.loading-dialog h2 {
  margin: 0 0 5px;

  font-size: 18px;
  font-weight: 600;
}

.loading-dialog p {
  margin: 0;

  color: var(--text-muted);
}


/* =========================================================
   Ladebalken
   ========================================================= */

.loading-progress {
  position: relative;

  height: 4px;
  margin-top: 24px;

  overflow: hidden;

  background: var(--border-muted);
  border-radius: 999px;
}

.loading-progress-bar {
  position: absolute;
  top: 0;
  bottom: 0;

  width: 45%;

  background: var(--primary);
  border-radius: inherit;

  animation: loading-progress 1.15s ease-in-out infinite;
}

@keyframes loading-progress {
  0% {
    left: -45%;
  }

  50% {
    left: 55%;
  }

  100% {
    left: 100%;
  }
}


/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 600px) {
  .container {
    margin-top: 28px;
  }

  .card-header {
    padding: 18px;
  }

  .card-body {
    padding: 22px 18px;
  }

  .theme-switcher {
    padding-inline: 9px;
  }

  #themeText {
    display: none;
  }
}