/*
 * SimulCorp Theme System - Core Foundation
 * Defines CSS custom properties (variables) that themes can override
 * This file is ALWAYS loaded, provides defaults
 */

:root {
  /* ============================================
     DEFAULT THEME (Current SimulCorp Look)
     ============================================ */

  /* Primary Colors */
  --theme-primary: #0d6efd;
  --theme-secondary: #6c757d;
  --theme-success: #198754;
  --theme-danger: #dc3545;
  --theme-warning: #ffc107;
  --theme-info: #0dcaf0;

  /* Surface Colors */
  --theme-background: #ffffff;
  --theme-surface: #f8f9fa;
  --theme-surface-elevated: #ffffff;

  /* Text Colors */
  --theme-text: #212529;
  --theme-text-secondary: #6c757d;
  --theme-text-muted: #adb5bd;
  --theme-text-on-primary: #ffffff;

  /* Border & Divider Colors */
  --theme-border: #dee2e6;
  --theme-divider: rgba(0, 0, 0, 0.1);

  /* Typography */
  --theme-font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --theme-font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --theme-font-mono: "Courier New", Consolas, Monaco, monospace;

  /* Font Sizes */
  --theme-font-size-xs: 0.75rem;
  --theme-font-size-sm: 0.875rem;
  --theme-font-size-base: 1rem;
  --theme-font-size-lg: 1.125rem;
  --theme-font-size-xl: 1.25rem;

  /* Layout & Spacing */
  --theme-border-radius: 0.375rem;
  --theme-border-radius-sm: 0.25rem;
  --theme-border-radius-lg: 0.5rem;

  /* Shadows */
  --theme-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --theme-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  --theme-shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);

  /* Transitions */
  --theme-transition-fast: 0.15s ease-in-out;
  --theme-transition-base: 0.3s ease-in-out;
  --theme-transition-slow: 0.5s ease-in-out;
}

/* ============================================
   APPLY THEME VARIABLES TO COMPONENTS
   ============================================ */

/* Body & Background */
body {
  background-color: var(--theme-background);
  color: var(--theme-text);
  font-family: var(--theme-font-body);
}

/* Typography */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--theme-font-heading);
  color: var(--theme-text);
}

/* Cards */
.card {
  background-color: var(--theme-surface-elevated);
  border-color: var(--theme-border);
  border-radius: var(--theme-border-radius);
  box-shadow: var(--theme-shadow-sm);
  transition: box-shadow var(--theme-transition-base);
}

.card:hover {
  box-shadow: var(--theme-shadow);
}

.card-header {
  background-color: var(--theme-surface);
  border-bottom-color: var(--theme-border);
}

.card-footer {
  background-color: var(--theme-surface);
  border-top-color: var(--theme-border);
}

/* Buttons */
.btn-primary {
  background-color: var(--theme-primary);
  border-color: var(--theme-primary);
  color: var(--theme-text-on-primary);
  transition: all var(--theme-transition-fast);
}

.btn-primary:hover {
  background-color: var(--theme-primary);
  border-color: var(--theme-primary);
  filter: brightness(0.9);
}

.btn-secondary {
  background-color: var(--theme-secondary);
  border-color: var(--theme-secondary);
  color: var(--theme-text-on-primary);
}

/* Forms */
.form-control,
.form-select {
  background-color: var(--theme-surface-elevated);
  border-color: var(--theme-border);
  color: var(--theme-text);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Tables */
.table {
  color: var(--theme-text);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: var(--theme-surface);
}

.table-hover > tbody > tr:hover > * {
  background-color: var(--theme-surface);
}

/* Badges */
.badge {
  font-family: var(--theme-font-body);
}

/* Alerts */
.alert {
  border-radius: var(--theme-border-radius);
}

/* Modals */
.modal-content {
  background-color: var(--theme-surface-elevated);
  border-color: var(--theme-border);
}

.modal-header {
  border-bottom-color: var(--theme-border);
}

.modal-footer {
  border-top-color: var(--theme-border);
}

/* Code blocks */
code,
pre {
  font-family: var(--theme-font-mono);
}

/* ============================================
   PRINT STYLESHEET (CRITICAL FOR THEMES)
   ============================================ */

@media print {
  body[data-theme] {
    --theme-background: #ffffff !important;
    --theme-surface: #ffffff !important;
    --theme-text: #000000 !important;
    --theme-border: #000000 !important;
  }

  /* Remove decorations */
  body[data-theme] .card::before,
  body[data-theme] .card::after,
  body[data-theme]::before,
  body[data-theme]::after {
    display: none !important;
  }

  /* Disable animations */
  body[data-theme] * {
    animation: none !important;
  }
}

/* ============================================
   ACCESSIBILITY: RESPECT USER PREFERENCES
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  body[data-theme] * {
    animation: none !important;
    transition: none !important;
  }
}
