/*
 * ============================================================
 *  DERRICK — Design Tokens (Doom 95 Theme)
 *  
 *  Windows 95 chrome meets DOOM's fiery HUD.
 *  All design decisions encoded as CSS custom properties.
 * ============================================================
 */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600;700&family=Press+Start+2P&display=swap');

:root {
  /* ============================
   * COLOR TOKENS
   * ============================ */

  /* -- Core Dark Surfaces -- */
  --doom-black:        #1A1A1A;
  --doom-charcoal:     #2D2D2D;
  --doom-gunmetal:     #3A3A3A;
  --doom-steel:        #4A4A4A;

  /* -- Win95 Chrome -- */
  --win95-surface:     #C0C0C0;
  --win95-light:       #DFDFDF;
  --win95-dark:        #808080;
  --win95-darker:      #404040;
  --win95-white:       #FFFFFF;
  --win95-bg:          #008080;

  /* -- DOOM Accents -- */
  --doom-red:          #B22222;
  --doom-blood:        #8B0000;
  --doom-fire:         #FF4500;
  --doom-amber:        #DAA520;
  --doom-green:        #00FF41;
  --doom-green-dim:    #00AA2A;
  --doom-blue:         #4169E1;
  --doom-title-blue:   #000080;
  --doom-title-blue-end: #1084D0;

  /* -- Text -- */
  --text-primary:      #E0E0E0;
  --text-secondary:    #A0A0A0;
  --text-on-chrome:    #000000;
  --text-hud:          #00FF41;
  --text-danger:       #FF4444;
  --text-warning:      #FFD700;

  /* -- Semantic Status -- */
  --status-running:    #00FF41;
  --status-complete:   #00AA2A;
  --status-failed:     #B22222;
  --status-pending:    #DAA520;
  --status-disabled:   #555555;
  --status-cancelled:  #808080;

  /* ============================
   * TYPOGRAPHY TOKENS
   * ============================ */

  --font-system:       'IBM Plex Sans', 'MS Sans Serif', 'Segoe UI', Tahoma, sans-serif;
  --font-mono:         'IBM Plex Mono', 'Fixedsys', 'Courier New', monospace;
  --font-pixel:        'Press Start 2P', cursive;

  --text-xxl:          24px;
  --text-xl:           20px;
  --text-lg:           16px;
  --text-base:         14px;
  --text-sm:           12px;
  --text-xs:           11px;
  --text-pixel-lg:     14px;
  --text-pixel-sm:     10px;

  --leading-tight:     1.2;
  --leading-normal:    1.4;
  --leading-pixel:     1.0;

  /* ============================
   * BEVEL SYSTEM (Win95 Borders)
   * ============================ */

  --bevel-raised:
    inset -1px -1px 0 0 var(--win95-dark),
    inset  1px  1px 0 0 var(--win95-light),
    inset -2px -2px 0 0 var(--win95-darker),
    inset  2px  2px 0 0 var(--win95-white);

  --bevel-sunken:
    inset -1px -1px 0 0 var(--win95-light),
    inset  1px  1px 0 0 var(--win95-dark),
    inset -2px -2px 0 0 var(--win95-white),
    inset  2px  2px 0 0 var(--win95-darker);

  --bevel-pressed:
    inset -1px -1px 0 0 var(--win95-light),
    inset  1px  1px 0 0 var(--win95-darker);

  --bevel-groove:
    inset  1px  1px 0 0 var(--win95-light),
    inset -1px -1px 0 0 var(--win95-dark);

  /* ============================
   * SPACING
   * ============================ */

  --space-1:  2px;
  --space-2:  4px;
  --space-3:  8px;
  --space-4:  12px;
  --space-5:  16px;
  --space-6:  24px;
  --space-7:  32px;
  --space-8:  48px;

  /* ============================
   * BORDERS & RADIUS
   * ============================ */

  --radius-none:  0px;

  /* ============================
   * TRANSITIONS
   * ============================ */

  --transition-fast:  100ms ease;
  --transition-base:  200ms ease;
  --transition-slow:  400ms ease;

  /* ============================
   * BREAKPOINTS (as reference)
   * ============================ */

  --bp-sm:   640px;
  --bp-md:   768px;
  --bp-lg:  1024px;
  --bp-xl:  1440px;

  /* ============================
   * CHART COLORS
   * ============================ */

  --chart-primary:   #00FF41;
  --chart-secondary: #4169E1;
  --chart-danger:    #B22222;
  --chart-warning:   #DAA520;
  --chart-grid:      rgba(255, 255, 255, 0.08);
  --chart-axis:      #A0A0A0;
}

/* ============================
 * REDUCED MOTION
 * ============================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================
 * ANIMATIONS
 * ============================ */
@keyframes pulse-glow {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

@keyframes doom-flicker {
  0%, 91%, 94%, 97%, 100% { opacity: 1; }
  92%                      { opacity: 0.8; }
  95%                      { opacity: 0.9; }
}

@keyframes blink-cursor {
  0%, 49%  { border-right-color: var(--doom-green); }
  50%, 100% { border-right-color: transparent; }
}

/* ============================
 * BASE RESET
 * ============================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  font-family: var(--font-system);
  color: var(--text-primary);
  background: var(--doom-black);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  background: var(--doom-black);
}

/* ============================
 * SCROLLBAR (Win95 Style)
 * ============================ */
::-webkit-scrollbar {
  width: 16px;
  height: 16px;
}

::-webkit-scrollbar-track {
  background: var(--doom-charcoal);
}

::-webkit-scrollbar-thumb {
  background: var(--win95-surface);
  box-shadow:
    inset -1px -1px 0 0 var(--win95-dark),
    inset  1px  1px 0 0 var(--win95-light),
    inset -2px -2px 0 0 var(--win95-darker),
    inset  2px  2px 0 0 var(--win95-white);
}

::-webkit-scrollbar-button {
  background: var(--win95-surface);
  box-shadow:
    inset -1px -1px 0 0 var(--win95-dark),
    inset  1px  1px 0 0 var(--win95-light),
    inset -2px -2px 0 0 var(--win95-darker),
    inset  2px  2px 0 0 var(--win95-white);
  display: block;
  height: 16px;
  width: 16px;
}

/* ============================
 * UTILITY CLASSES
 * ============================ */
.font-system { font-family: var(--font-system); }
.font-mono   { font-family: var(--font-mono); }
.font-pixel  { font-family: var(--font-pixel); }

.text-xxl      { font-size: var(--text-xxl); }
.text-xl       { font-size: var(--text-xl); }
.text-lg       { font-size: var(--text-lg); }
.text-base     { font-size: var(--text-base); }
.text-sm       { font-size: var(--text-sm); }
.text-xs       { font-size: var(--text-xs); }
.text-pixel-lg { font-size: var(--text-pixel-lg); font-family: var(--font-pixel); line-height: var(--leading-pixel); }
.text-pixel-sm { font-size: var(--text-pixel-sm); font-family: var(--font-pixel); line-height: var(--leading-pixel); }

.text-hud     { color: var(--text-hud); }
.text-danger  { color: var(--text-danger); }
.text-warning { color: var(--text-warning); }
.text-muted   { color: var(--text-secondary); }

/* ============================
 * WIN95 COMPONENT CLASSES
 * ============================ */

/* -- Window -- */
.win95-window {
  background: var(--win95-surface);
  box-shadow: var(--bevel-raised);
  display: flex;
  flex-direction: column;
}

.win95-titlebar {
  background: linear-gradient(90deg, var(--doom-title-blue), var(--doom-title-blue-end));
  color: var(--win95-white);
  font-family: var(--font-system);
  font-weight: 700;
  font-size: var(--text-sm);
  padding: 3px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.win95-titlebar-text {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.win95-titlebar-controls {
  display: flex;
  gap: 2px;
}

.win95-titlebar-btn {
  width: 16px;
  height: 14px;
  background: var(--win95-surface);
  box-shadow: var(--bevel-raised);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-family: var(--font-system);
  font-weight: 700;
  color: var(--text-on-chrome);
  padding: 0;
  line-height: 1;
}

.win95-titlebar-btn:active {
  box-shadow: var(--bevel-pressed);
}

/* -- Menu Bar -- */
.win95-menubar {
  background: var(--win95-surface);
  padding: 2px 0;
  font-family: var(--font-system);
  font-size: var(--text-sm);
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--win95-dark);
}

.win95-menubar-item {
  padding: 2px 8px;
  cursor: pointer;
  color: var(--text-on-chrome);
  user-select: none;
}

.win95-menubar-item:hover {
  background: var(--doom-title-blue);
  color: var(--win95-white);
}

/* -- Content Panel (sunken dark area) -- */
.win95-panel {
  background: var(--doom-charcoal);
  box-shadow: var(--bevel-sunken);
  padding: var(--space-3);
  color: var(--text-primary);
}

/* -- Status Bar -- */
.win95-statusbar {
  background: var(--win95-surface);
  padding: 2px 4px;
  font-family: var(--font-system);
  font-size: var(--text-xs);
  color: var(--text-on-chrome);
  display: flex;
  gap: 2px;
}

.win95-statusbar-section {
  box-shadow: var(--bevel-sunken);
  padding: 1px 6px;
  flex: 1;
}

.win95-statusbar-section:first-child {
  flex: 3;
}

/* -- Button -- */
.btn-win95 {
  background: var(--win95-surface);
  color: var(--text-on-chrome);
  border: none;
  box-shadow: var(--bevel-raised);
  padding: 4px 16px;
  font-family: var(--font-system);
  font-size: var(--text-sm);
  cursor: pointer;
  min-width: 75px;
  text-align: center;
  white-space: nowrap;
}

.btn-win95:hover {
  background: #CACACA;
}

.btn-win95:active {
  box-shadow: var(--bevel-pressed);
  padding: 5px 15px 3px 17px;
}

.btn-win95:focus-visible {
  outline: 1px dotted #000;
  outline-offset: -4px;
}

.btn-win95:disabled {
  color: var(--win95-dark);
  text-shadow: 1px 1px 0 var(--win95-white);
  cursor: not-allowed;
}

.btn-win95.btn-danger {
  color: var(--doom-red);
}

.btn-win95.btn-small {
  min-width: auto;
  padding: 2px 8px;
  font-size: var(--text-xs);
}

/* -- Input Field -- */
.input-win95 {
  background: var(--doom-black);
  color: var(--text-primary);
  border: none;
  box-shadow: var(--bevel-sunken);
  padding: 4px 6px;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  outline: none;
  width: 100%;
}

.input-win95:focus {
  outline: 1px dotted var(--doom-green);
  outline-offset: -1px;
}

.input-win95::placeholder {
  color: var(--doom-steel);
}

/* -- Tabs -- */
.win95-tabs {
  display: flex;
  padding: 0 var(--space-2);
  position: relative;
  bottom: -2px;
  z-index: 1;
}

.win95-tab {
  background: var(--win95-surface);
  padding: 4px 16px;
  font-family: var(--font-system);
  font-size: var(--text-sm);
  cursor: pointer;
  border: none;
  box-shadow:
    inset -1px  0   0 0 var(--win95-dark),
    inset  1px  1px 0 0 var(--win95-light),
    inset -2px  0   0 0 var(--win95-darker),
    inset  2px  2px 0 0 var(--win95-white);
  color: var(--text-on-chrome);
  position: relative;
}

.win95-tab.active {
  background: var(--win95-surface);
  padding-bottom: 6px;
  margin-bottom: -2px;
  z-index: 2;
}

.win95-tab-content {
  background: var(--win95-surface);
  box-shadow: var(--bevel-raised);
  padding: var(--space-5);
}

/* -- Status Badges -- */
.badge {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border: 1px solid;
  display: inline-block;
}

.badge-running {
  color: var(--status-running);
  border-color: var(--status-running);
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.5);
  animation: pulse-glow 2s ease-in-out infinite;
}

.badge-complete {
  color: var(--status-complete);
  border-color: var(--status-complete);
}

.badge-failed {
  color: var(--status-failed);
  border-color: var(--status-failed);
  text-shadow: 0 0 6px rgba(178, 34, 34, 0.5);
}

.badge-pending {
  color: var(--status-pending);
  border-color: var(--status-pending);
}

.badge-disabled {
  color: var(--status-disabled);
  border-color: var(--status-disabled);
}

.badge-cancelled {
  color: var(--status-cancelled);
  border-color: var(--status-cancelled);
}

/* -- Data Table -- */
.table-doom {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.table-doom thead {
  background: var(--doom-gunmetal);
  color: var(--text-primary);
  text-transform: uppercase;
  font-size: var(--text-xs);
  letter-spacing: 1px;
}

.table-doom th {
  padding: 6px 12px;
  text-align: left;
  border-bottom: 2px solid var(--doom-green-dim);
  font-weight: 600;
}

.table-doom td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--doom-steel);
  color: var(--text-secondary);
}

.table-doom tbody tr:hover {
  background: rgba(0, 255, 65, 0.05);
  cursor: pointer;
}

.table-doom tbody tr.row-failed {
  background: rgba(178, 34, 34, 0.1);
}

.table-doom tbody tr.row-running {
  background: rgba(0, 255, 65, 0.08);
}

/* -- Progress Bar (DOOM Health Bar) -- */
.progress-doom {
  height: 20px;
  background: var(--doom-black);
  box-shadow: var(--bevel-sunken);
  position: relative;
  overflow: hidden;
}

.progress-doom-fill {
  height: 100%;
  transition: width var(--transition-base);
}

.progress-doom-fill.healthy  { background: var(--doom-green); }
.progress-doom-fill.warning  { background: var(--doom-amber); }
.progress-doom-fill.critical { background: var(--doom-red); }

.progress-doom-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-primary);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
  z-index: 1;
}

/* -- Group Box (Win95 fieldset) -- */
.win95-groupbox {
  border: 2px groove var(--win95-surface);
  padding: var(--space-5);
  padding-top: var(--space-3);
  position: relative;
}

.win95-groupbox-label {
  position: absolute;
  top: -8px;
  left: 10px;
  background: var(--win95-surface);
  padding: 0 4px;
  font-family: var(--font-system);
  font-size: var(--text-sm);
  color: var(--text-on-chrome);
}

/* -- CRT Scanline Overlay -- */
.crt-overlay::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* -- HUD Stat Counter -- */
.hud-stat {
  background: var(--doom-charcoal);
  box-shadow: var(--bevel-sunken);
  padding: var(--space-4);
  text-align: center;
}

.hud-stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-xxl);
  font-weight: 700;
  color: var(--doom-green);
  text-shadow: 0 0 10px rgba(0, 255, 65, 0.3);
  line-height: var(--leading-tight);
}

.hud-stat-label {
  font-family: var(--font-system);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: var(--space-2);
}

/* -- Sidebar Navigation -- */
.win95-sidebar {
  background: var(--win95-surface);
  box-shadow: var(--bevel-raised);
  padding: var(--space-2);
}

.win95-sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 4px 8px;
  font-family: var(--font-system);
  font-size: var(--text-sm);
  color: var(--text-on-chrome);
  cursor: pointer;
  user-select: none;
}

.win95-sidebar-item:hover {
  background: var(--doom-title-blue);
  color: var(--win95-white);
}

.win95-sidebar-item.active {
  background: var(--doom-title-blue);
  color: var(--win95-white);
}

/* -- Dialog Box -- */
.win95-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
}

.win95-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 999;
}
