/* ================================================================
   SauerlandAI — Unified Base Design System (unified-base.css)
   Version: 1.0 | 2026-03-25

   Extends sai-theme.css with SAI Light green-branded tokens,
   layout helpers, component base styles, status badges,
   print styles, and responsive breakpoints.

   Usage: Include AFTER sai-theme.css:
     <link rel="stylesheet" href="/static/css/sai-theme.css">
     <link rel="stylesheet" href="/static/unified-base.css">
   ================================================================ */

/* ================================================================
   CSS VARIABLES — SAI Light Green Theme
   These bridge/override sai-theme tokens with the SAI Light palette.
   ================================================================ */
:root {
  /* ── SAI Light Palette ── */
  --sai-light-bg:         #EFF5EF;
  --sai-light-surface:    rgba(255,255,255,0.85);
  --sai-light-text:       #1E293B;
  --sai-light-green:      #3D8B50;
  --sai-light-green-dark: #2D6B3E;
  --sai-light-green-light:#4CAF6A;
  --sai-light-border:     rgba(0,0,0,0.08);
  --sai-light-orange:     #E8720C;

  /* ── Convenience aliases (green-branded) ── */
  --sai-brand:      var(--sai-light-green);
  --sai-brand-dark: var(--sai-light-green-dark);
  --sai-orange:     var(--sai-light-orange);

  /* ── Status Colors ── */
  --sai-status-proved:    #16a34a;
  --sai-status-proved-bg: #dcfce7;
  --sai-status-probable:     #ca8a04;
  --sai-status-probable-bg:  #fef9c3;
  --sai-status-unknown:      #64748b;
  --sai-status-unknown-bg:   #f1f5f9;
  --sai-status-false:        #dc2626;
  --sai-status-false-bg:     #fee2e2;
  --sai-status-goedel:       #7c3aed;
  --sai-status-goedel-bg:    #ede9fe;
  --sai-status-korridor:     #0891b2;
  --sai-status-korridor-bg:  #cffafe;

  /* ── Layout ── */
  --sai-container-sm:  640px;
  --sai-container-md:  768px;
  --sai-container-lg:  1024px;
  --sai-container-xl:  1280px;
  --sai-container-2xl: 1440px;

  /* ── Z-Index Scale ── */
  --sai-z-base:     1;
  --sai-z-dropdown: 100;
  --sai-z-sticky:   200;
  --sai-z-modal:    500;
  --sai-z-toast:    600;
  --sai-z-tooltip:  700;
}

/* ── Dark Mode Overrides ── */
[data-theme="dark"] {
  --sai-light-bg:         #0a0e1a;
  --sai-light-surface:    rgba(15,23,41,0.9);
  --sai-light-text:       #e2e8f0;
  --sai-light-green:      #4CAF6A;
  --sai-light-green-dark: #3D8B50;
  --sai-light-green-light:#6BCF84;
  --sai-light-border:     rgba(255,255,255,0.08);
  --sai-light-orange:     #F59E0B;

  --sai-status-proved-bg:   #052e16;
  --sai-status-probable-bg: #422006;
  --sai-status-unknown-bg:  #1e293b;
  --sai-status-false-bg:    #450a0a;
  --sai-status-goedel-bg:   #2e1065;
  --sai-status-korridor-bg: #164e63;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sai-light-bg:      #0a0e1a;
    --sai-light-surface:  rgba(15,23,41,0.9);
    --sai-light-text:    #e2e8f0;
    --sai-light-green:   #4CAF6A;
    --sai-light-border:  rgba(255,255,255,0.08);
  }
}


/* ================================================================
   TYPOGRAPHY
   ================================================================ */
body {
  font-family: var(--sai-font-sans, 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif);
  font-size: var(--sai-text-base, 14px);
  line-height: 1.57;
  color: var(--sai-text-primary, var(--sai-light-text));
  background: var(--sai-bg-page, var(--sai-light-bg));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.text-xs   { font-size: var(--sai-text-xs, 11px); }
.text-sm   { font-size: var(--sai-text-sm, 13px); }
.text-base { font-size: var(--sai-text-base, 14px); }
.text-md   { font-size: var(--sai-text-md, 16px); }
.text-lg   { font-size: var(--sai-text-lg, 20px); }
.text-xl   { font-size: var(--sai-text-xl, 24px); }
.text-2xl  { font-size: var(--sai-text-2xl, 30px); }
.text-3xl  { font-size: var(--sai-text-3xl, 36px); }

.font-normal  { font-weight: 400; }
.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-bold    { font-weight: 700; }
.font-extra   { font-weight: 800; }

.text-primary   { color: var(--sai-text-primary); }
.text-secondary { color: var(--sai-text-secondary); }
.text-tertiary  { color: var(--sai-text-tertiary); }
.text-brand     { color: var(--sai-light-green); }
.text-danger    { color: var(--sai-status-false); }

.mono { font-family: var(--sai-font-mono, 'JetBrains Mono', 'Consolas', monospace); }


/* ================================================================
   LAYOUT HELPERS
   ================================================================ */

/* ── Container ── */
.sai-container {
  width: 100%;
  max-width: var(--sai-container-xl);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--sai-space-4, 16px);
  padding-right: var(--sai-space-4, 16px);
}
.sai-container-sm { max-width: var(--sai-container-sm); }
.sai-container-md { max-width: var(--sai-container-md); }
.sai-container-lg { max-width: var(--sai-container-lg); }
.sai-container-2xl{ max-width: var(--sai-container-2xl); }

/* ── Flexbox ── */
.flex       { display: flex; }
.flex-col   { flex-direction: column; }
.flex-row   { flex-direction: row; }
.flex-wrap  { flex-wrap: wrap; }
.flex-1     { flex: 1; }
.flex-none  { flex: none; }
.flex-grow  { flex-grow: 1; }
.flex-shrink-0 { flex-shrink: 0; }

.items-start   { align-items: flex-start; }
.items-center  { align-items: center; }
.items-end     { align-items: flex-end; }
.items-stretch { align-items: stretch; }

.justify-start   { justify-content: flex-start; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around  { justify-content: space-around; }

.self-start  { align-self: flex-start; }
.self-center { align-self: center; }
.self-end    { align-self: flex-end; }

/* ── Grid ── */
.grid       { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ── Gap ── */
.gap-1 { gap: var(--sai-space-1, 4px); }
.gap-2 { gap: var(--sai-space-2, 8px); }
.gap-3 { gap: var(--sai-space-3, 12px); }
.gap-4 { gap: var(--sai-space-4, 16px); }
.gap-5 { gap: var(--sai-space-5, 20px); }
.gap-6 { gap: var(--sai-space-6, 24px); }
.gap-8 { gap: var(--sai-space-8, 32px); }

/* ── Spacing ── */
.p-0  { padding: 0; }
.p-1  { padding: var(--sai-space-1); }
.p-2  { padding: var(--sai-space-2); }
.p-3  { padding: var(--sai-space-3); }
.p-4  { padding: var(--sai-space-4); }
.p-5  { padding: var(--sai-space-5); }
.p-6  { padding: var(--sai-space-6); }
.p-8  { padding: var(--sai-space-8); }
.px-4 { padding-left: var(--sai-space-4); padding-right: var(--sai-space-4); }
.py-2 { padding-top: var(--sai-space-2); padding-bottom: var(--sai-space-2); }
.py-4 { padding-top: var(--sai-space-4); padding-bottom: var(--sai-space-4); }

.m-0  { margin: 0; }
.m-auto { margin: auto; }
.mt-2 { margin-top: var(--sai-space-2); }
.mt-4 { margin-top: var(--sai-space-4); }
.mt-6 { margin-top: var(--sai-space-6); }
.mb-2 { margin-bottom: var(--sai-space-2); }
.mb-4 { margin-bottom: var(--sai-space-4); }
.mb-6 { margin-bottom: var(--sai-space-6); }

/* ── Sizing ── */
.w-full  { width: 100%; }
.h-full  { height: 100%; }
.min-h-screen { min-height: 100vh; }
.max-w-prose  { max-width: 65ch; }

/* ── Text Alignment ── */
.text-left   { text-align: left; }
.text-center { text-align: center; }
.text-right  { text-align: right; }

/* ── Overflow ── */
.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; }
.overflow-y-auto { overflow-y: auto; }

/* ── Position ── */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.sticky   { position: sticky; }

/* ── Display ── */
.hidden  { display: none; }
.block   { display: block; }
.inline  { display: inline; }
.inline-block { display: inline-block; }
.inline-flex  { display: inline-flex; }

/* ── Misc ── */
.rounded    { border-radius: var(--sai-radius-md, 6px); }
.rounded-lg { border-radius: var(--sai-radius-lg, 8px); }
.rounded-xl { border-radius: var(--sai-radius-xl, 12px); }
.rounded-full { border-radius: var(--sai-radius-full, 9999px); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }
.transition { transition: all var(--sai-transition, 150ms ease); }


/* ================================================================
   CARD / PANEL
   ================================================================ */
.sai-card {
  background: var(--sai-card-bg, var(--sai-light-surface));
  border: 1px solid var(--sai-card-border, var(--sai-light-border));
  border-radius: var(--sai-card-radius, var(--sai-radius-lg, 8px));
  padding: var(--sai-card-padding, var(--sai-space-5, 20px));
  box-shadow: var(--sai-card-shadow, var(--sai-shadow-sm));
  transition: box-shadow var(--sai-transition-smooth, 200ms ease);
}
.sai-card:hover {
  box-shadow: var(--sai-shadow-md);
}

.sai-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sai-space-4, 16px);
  padding-bottom: var(--sai-space-3, 12px);
  border-bottom: 1px solid var(--sai-border-light, var(--sai-light-border));
}
.sai-card-title {
  font-size: var(--sai-text-md, 16px);
  font-weight: 600;
  color: var(--sai-text-primary);
}
.sai-card-body { }
.sai-card-footer {
  margin-top: var(--sai-space-4, 16px);
  padding-top: var(--sai-space-3, 12px);
  border-top: 1px solid var(--sai-border-light, var(--sai-light-border));
}

.sai-panel {
  background: var(--sai-bg-surface, var(--sai-light-surface));
  border: 1px solid var(--sai-border-light, var(--sai-light-border));
  border-radius: var(--sai-radius-xl, 12px);
  padding: var(--sai-space-6, 24px);
  box-shadow: var(--sai-shadow-md);
}

.sai-glass {
  background: var(--sai-light-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--sai-radius-xl, 12px);
}
[data-theme="dark"] .sai-glass {
  border-color: rgba(255,255,255,0.06);
}


/* ================================================================
   BUTTONS
   ================================================================ */
.sai-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sai-space-2, 8px);
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--sai-btn-radius, var(--sai-radius-md, 6px));
  font-family: var(--sai-font-sans);
  font-size: var(--sai-text-sm, 13px);
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: all var(--sai-transition, 150ms ease);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.sai-btn:focus-visible {
  outline: 2px solid var(--sai-border-focus, var(--sai-light-green));
  outline-offset: 2px;
}
.sai-btn:disabled, .sai-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary — SAI Green */
.sai-btn-primary {
  background: var(--sai-light-green);
  color: #FFFFFF;
  border-color: var(--sai-light-green);
  box-shadow: 0 1px 3px rgba(61,139,80,0.2);
}
.sai-btn-primary:hover {
  background: var(--sai-light-green-dark);
  border-color: var(--sai-light-green-dark);
  box-shadow: 0 2px 8px rgba(61,139,80,0.3);
  transform: translateY(-1px);
}
.sai-btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(61,139,80,0.2);
}

/* Secondary — Ghost */
.sai-btn-secondary {
  background: transparent;
  color: var(--sai-text-primary);
  border-color: var(--sai-border-default, var(--sai-light-border));
}
.sai-btn-secondary:hover {
  background: var(--sai-bg-hover, rgba(0,0,0,0.04));
  border-color: var(--sai-border-medium);
}

/* Danger */
.sai-btn-danger {
  background: var(--sai-status-false);
  color: #FFFFFF;
  border-color: var(--sai-status-false);
}
.sai-btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  box-shadow: 0 2px 8px rgba(220,38,38,0.3);
}

/* Ghost — no border */
.sai-btn-ghost {
  background: transparent;
  color: var(--sai-text-secondary);
  border-color: transparent;
}
.sai-btn-ghost:hover {
  background: var(--sai-bg-hover);
  color: var(--sai-text-primary);
}

/* Link style */
.sai-btn-link {
  background: transparent;
  color: var(--sai-text-link, var(--sai-light-green));
  border-color: transparent;
  padding-left: 0;
  padding-right: 0;
}
.sai-btn-link:hover {
  color: var(--sai-text-link-hover, var(--sai-light-green-dark));
  text-decoration: underline;
}

/* Sizes */
.sai-btn-sm {
  padding: 4px 10px;
  font-size: var(--sai-text-xs, 11px);
  border-radius: var(--sai-radius-sm, 4px);
}
.sai-btn-lg {
  padding: 12px 24px;
  font-size: var(--sai-text-base, 14px);
  border-radius: var(--sai-radius-lg, 8px);
}

/* Icon-only */
.sai-btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--sai-radius-md, 6px);
}
.sai-btn-icon.sai-btn-sm { width: 28px; height: 28px; }
.sai-btn-icon.sai-btn-lg { width: 44px; height: 44px; }


/* ================================================================
   FORM INPUTS
   ================================================================ */
.sai-input,
.sai-select,
.sai-textarea {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-family: var(--sai-font-sans);
  font-size: var(--sai-text-base, 14px);
  line-height: 1.5;
  color: var(--sai-text-primary);
  background: var(--sai-input-bg, var(--sai-bg-surface, #fff));
  border: 1px solid var(--sai-input-border, var(--sai-border-default));
  border-radius: var(--sai-input-radius, var(--sai-radius-md, 6px));
  transition: border-color var(--sai-transition), box-shadow var(--sai-transition);
  outline: none;
}
.sai-input:focus,
.sai-select:focus,
.sai-textarea:focus {
  border-color: var(--sai-input-focus-border, var(--sai-light-green));
  box-shadow: 0 0 0 3px rgba(61,139,80,0.15);
}
.sai-input::placeholder,
.sai-textarea::placeholder {
  color: var(--sai-text-tertiary);
}
.sai-input:disabled,
.sai-select:disabled,
.sai-textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--sai-bg-surface-sunken, #f0f0f0);
}
.sai-textarea {
  min-height: 80px;
  resize: vertical;
}

.sai-label {
  display: block;
  font-size: var(--sai-text-xs, 11px);
  font-weight: 700;
  color: var(--sai-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.sai-form-group {
  margin-bottom: var(--sai-space-5, 20px);
}
.sai-form-hint {
  font-size: var(--sai-text-xs, 11px);
  color: var(--sai-text-tertiary);
  margin-top: 4px;
}
.sai-form-error {
  font-size: var(--sai-text-xs, 11px);
  color: var(--sai-status-false);
  margin-top: 4px;
}

/* Checkbox / Radio */
.sai-checkbox,
.sai-radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--sai-text-sm, 13px);
  color: var(--sai-text-primary);
  cursor: pointer;
}
.sai-checkbox input,
.sai-radio input {
  width: 16px;
  height: 16px;
  accent-color: var(--sai-light-green);
}


/* ================================================================
   TABLE
   ================================================================ */
.sai-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--sai-text-sm, 13px);
}
.sai-table thead {
  background: var(--sai-bg-surface-alt, var(--sai-light-bg));
  position: sticky;
  top: 0;
  z-index: 1;
}
.sai-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: var(--sai-text-xs, 11px);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sai-text-secondary);
  border-bottom: 2px solid var(--sai-border-default, var(--sai-light-border));
  white-space: nowrap;
}
.sai-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--sai-border-light, var(--sai-light-border));
  color: var(--sai-text-primary);
  vertical-align: middle;
}
.sai-table tbody tr:hover {
  background: var(--sai-bg-hover, rgba(0,0,0,0.02));
}
.sai-table tbody tr:last-child td {
  border-bottom: none;
}

/* Compact variant */
.sai-table-compact th,
.sai-table-compact td {
  padding: 6px 10px;
}

/* Striped variant */
.sai-table-striped tbody tr:nth-child(even) {
  background: var(--sai-bg-surface-alt, rgba(0,0,0,0.02));
}


/* ================================================================
   STATUS BADGES
   Maps to SauerlandAI verification status codes:
   PROVED, PROBABLE, KORRIDOR, UNKNOWN, FALSE, GOEDEL
   ================================================================ */
.sai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--sai-radius-full, 9999px);
  font-size: var(--sai-text-xs, 11px);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.sai-badge-proved,
.sai-badge-success {
  background: var(--sai-status-proved-bg);
  color: var(--sai-status-proved);
}
.sai-badge-probable,
.sai-badge-warning {
  background: var(--sai-status-probable-bg);
  color: var(--sai-status-probable);
}
.sai-badge-unknown,
.sai-badge-neutral {
  background: var(--sai-status-unknown-bg);
  color: var(--sai-status-unknown);
}
.sai-badge-false,
.sai-badge-error,
.sai-badge-danger {
  background: var(--sai-status-false-bg);
  color: var(--sai-status-false);
}
.sai-badge-goedel {
  background: var(--sai-status-goedel-bg);
  color: var(--sai-status-goedel);
}
.sai-badge-korridor {
  background: var(--sai-status-korridor-bg);
  color: var(--sai-status-korridor);
}

/* Small dot indicator */
.sai-badge-dot::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Pill (larger) variant */
.sai-badge-lg {
  padding: 4px 12px;
  font-size: var(--sai-text-sm, 13px);
}


/* ================================================================
   ALERTS / CALLOUTS
   ================================================================ */
.sai-alert {
  padding: var(--sai-space-3, 12px) var(--sai-space-4, 16px);
  border-radius: var(--sai-radius-lg, 8px);
  border-left: 3px solid;
  font-size: var(--sai-text-sm, 13px);
  line-height: 1.5;
}
.sai-alert-success {
  background: var(--sai-success-bg, var(--sai-status-proved-bg));
  border-color: var(--sai-success-border, var(--sai-status-proved));
  color: var(--sai-success-text, var(--sai-status-proved));
}
.sai-alert-warning {
  background: var(--sai-warning-bg, var(--sai-status-probable-bg));
  border-color: var(--sai-warning-border, var(--sai-status-probable));
  color: var(--sai-warning-text, var(--sai-status-probable));
}
.sai-alert-error {
  background: var(--sai-error-bg, var(--sai-status-false-bg));
  border-color: var(--sai-error-border, var(--sai-status-false));
  color: var(--sai-error-text, var(--sai-status-false));
}
.sai-alert-info {
  background: var(--sai-info-bg, #eff6ff);
  border-color: var(--sai-info-border, #2563eb);
  color: var(--sai-info-text, #1d4ed8);
}


/* ================================================================
   DIVIDER
   ================================================================ */
.sai-divider {
  border: none;
  border-top: 1px solid var(--sai-border-light, var(--sai-light-border));
  margin: var(--sai-space-4, 16px) 0;
}


/* ================================================================
   RESPONSIVE BREAKPOINTS
   ================================================================ */
@media (max-width: 640px) {
  .sm-hidden   { display: none; }
  .sm-flex-col { flex-direction: column; }
  .sm-w-full   { width: 100%; }
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 { grid-template-columns: 1fr; }
}

@media (min-width: 641px) and (max-width: 768px) {
  .md-grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-3,
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .lg-grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-cols-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1025px) {
  .xl-grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
}


/* ================================================================
   PRINT STYLES
   ================================================================ */
@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  .sai-topbar,
  .sai-sidebar,
  .sai-btn,
  .no-print {
    display: none !important;
  }

  .sai-card {
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }

  .sai-table {
    border-collapse: collapse;
  }
  .sai-table th,
  .sai-table td {
    border: 1px solid #ccc;
  }

  .sai-badge {
    border: 1px solid currentColor;
  }

  @page {
    margin: 2cm;
  }
}
