/* =============================================================
   SeeDS — main.css
   Base styles: reset, layout shell, dark theme, canvas, tooltip.
   ============================================================= */

/* --- Reset & Base ------------------------------------------ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Core palette */
  --bg:            #0a0a10;
  --bg-surface:    #111118;
  --bg-raised:     #181825;
  --bg-hover:      #222240;
  --bg-active:     #2a2a50;

  /* Borders */
  --border:        rgba(255,255,255,0.06);
  --border-light:  rgba(255,255,255,0.12);
  --border-active: rgba(255,255,255,0.20);

  /* Text */
  --text:          #e8ecf8;
  --text-muted:    #8890aa;
  --text-dim:      #4a4f6a;

  /* Accent */
  --accent:        #5b8ff7;
  --accent-glow:   rgba(91,142,247,0.20);
  --accent-dim:    rgba(91,142,247,0.10);
  --accent-hover:  #85b5ff;

  /* Semantic */
  --error:         #ff3b3b;
  --error-dim:     rgba(255,59,59,0.12);
  --warn:          #ffb84d;
  --warn-dim:      rgba(255,184,77,0.12);
  --success:       #4fce7a;
  --success-dim:   rgba(79,206,122,0.12);
  --info:          #5b8ff7;
  --info-dim:      rgba(91,142,247,0.12);

  /* Layout */
  --toolbar-h:     52px;
  --playbar-h:     56px;
  --editor-w:      420px;   /* permanent left panel width */

  /* Radii */
  --radius:        6px;
  --radius-sm:     4px;
  --radius-lg:     10px;
  --radius-xl:     14px;

  /* Shadows */
  --shadow-sm:     0 1px 4px rgba(0,0,0,0.4);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.6);
  --shadow-glow:   0 0 20px var(--accent-glow);

  /* Typography */
  --font-sans:    -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', monospace;

  /* Transitions */
  --transition:      180ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* =============================================================
   APP LAYOUT SHELL
   toolbar (top, full width)
   app-shell (middle, two columns)
   playback-bar (bottom, full width)
   ============================================================= */

#toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--toolbar-h);
  z-index: 20;
}

#playback-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--playbar-h);
  z-index: 20;
}

/* Two-column shell sits between toolbar and playbar */
#app-shell {
  position: fixed;
  top: var(--toolbar-h);
  left: 0;
  right: 0;
  bottom: var(--playbar-h);
  display: flex;
  flex-direction: row;
  overflow: hidden;
}


/* --- Left column: permanent code editor -------------------- */
#code-panel {
  width: var(--editor-w);
  min-width: var(--editor-w);
  max-width: var(--editor-w);
  height: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: rgba(10, 10, 16, 0.98);
  border-right: 1px solid var(--border);
  z-index: 10;
  overflow: hidden;
}


/* --- Right column: canvas area ----------------------------- */
#canvas-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

#seeds-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}


/* --- Status bar (inside canvas-area) ----------------------- */
#status-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 28px;
  z-index: 9;
  pointer-events: none;
}


/* --- Error panel (floating over canvas) -------------------- */
#error-panel {
  position: absolute;
  top: 40px;
  right: 12px;
  width: 260px;
  max-height: calc(100% - 52px);
  z-index: 10;
  transition: opacity var(--transition), transform var(--transition);
}


/* --- Shared button base ------------------------------------ */
button {
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition),
              transform 100ms ease;
}

button:active:not(:disabled) {
  transform: scale(0.96);
}

button:disabled {
  opacity: 0.30;
  cursor: not-allowed;
  transform: none !important;
}

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


/* --- Info Tooltip ------------------------------------------ */
.info-tooltip {
  position: fixed;
  z-index: 100;
  background: rgba(24, 24, 37, 0.92);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  min-width: 170px;
  max-width: 240px;
  box-shadow: var(--shadow-lg), 0 0 30px rgba(0,0,0,0.3);
  pointer-events: none;
  font-size: 13px;
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  animation: tooltipIn 180ms ease-out;
}

@keyframes tooltipIn {
  from { opacity: 0; transform: translateY(4px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.info-tooltip__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 3px 0;
}

.info-tooltip__row + .info-tooltip__row {
  border-top: 1px solid rgba(255,255,255,0.04);
  margin-top: 2px;
  padding-top: 5px;
}

.info-tooltip__label {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.info-tooltip__value {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: right;
  word-break: break-all;
}

.info-tooltip__error {
  margin-top: 8px;
  padding: 5px 10px;
  background: var(--error-dim);
  border: 1px solid rgba(255,59,59,0.25);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}


/* --- Scrollbar styling ------------------------------------- */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
  transition: background var(--transition);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }


/* =============================================================
   FULLSCREEN MODE — hides UI panels, canvas takes over
   Applied via: body.fullscreen-mode (toggled by fullscreen button)
   ============================================================= */

body.fullscreen-mode #toolbar,
body.fullscreen-mode #status-bar,
body.fullscreen-mode #code-panel,
body.fullscreen-mode #panel-divider,
body.fullscreen-mode #error-panel,
body.fullscreen-mode #error-badge,
body.fullscreen-mode #playback-bar,
body.fullscreen-mode #floating-error-panel {
  display: none !important;
}

body.fullscreen-mode #seeds-canvas {
  position: fixed;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  z-index: 0;
}

body.fullscreen-mode #visualizer-area {
  position: fixed;
  inset: 0;
  z-index: 1;
}

body.fullscreen-mode #app-layout {
  position: fixed;
  inset: 0;
}

body.fullscreen-mode #status-bar {
  display: none !important;
}

/* Exit fullscreen button */
.fullscreen-exit-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  padding: 8px 16px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: background 180ms ease;
}

.fullscreen-exit-btn:hover {
  background: rgba(0,0,0,0.8);
}


/* =============================================================
   LIGHT THEME — overrides everything above
   Applied via: body.light-theme  (toggled by 'T' key)
   ============================================================= */

body.light-theme {
  --bg:            #f4f4f9;
  --bg-surface:    #ffffff;
  --bg-raised:     #eaeaef;
  --bg-hover:      #dddde8;
  --bg-active:     #cccce0;

  --border:        rgba(0,0,0,0.08);
  --border-light:  rgba(0,0,0,0.14);
  --border-active: rgba(0,0,0,0.22);

  --text:          #1a1a2e;
  --text-muted:    #5a5a7a;
  --text-dim:      #5a5a7a;

  --shadow-sm:     0 1px 4px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.12);
}

/* Light toolbar background */
body.light-theme .toolbar {
  background: rgba(255,255,255,0.92);
  border-bottom: 1px solid var(--border);
}

body.light-theme .toolbar__tabs-wrap::after {
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.92));
}

/* Light code panel — styles live in code-panel.css */
body.light-theme #code-panel {
  background: rgba(255,255,255,0.96);
  border-right: 1px solid var(--border);
}

/* Light playback bar */
body.light-theme .playback-bar {
  background: rgba(255,255,255,0.92);
  border-top: 1px solid var(--border);
}

body.light-theme .playback-bar__btn,
body.light-theme .playback-bar__speed-btn {
  background: #fff;
}

body.light-theme .playback-bar__btn:hover:not(:disabled),
body.light-theme .playback-bar__speed-btn:hover {
  background: var(--bg-hover);
}

/* Light status bar */
body.light-theme .status-bar {
  background: rgba(255,255,255,0.7);
  border-bottom: 1px solid var(--border);
}

/* Light error panel */
body.light-theme .error-panel {
  background: rgba(255,255,255,0.94);
}

body.light-theme .error-panel__item {
  background: rgba(255,59,59,0.04);
}

body.light-theme .error-panel__item:hover {
  background: rgba(255,59,59,0.08);
}

body.light-theme .error-panel__item-node {
  background: var(--bg-raised);
  color: var(--text-dim);
}

/* Light tooltip */
body.light-theme .info-tooltip {
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--border-light);
}

body.light-theme .info-tooltip__row + .info-tooltip__row {
  border-top: 1px solid rgba(0,0,0,0.06);
}

body.light-theme .info-tooltip__label {
  color: var(--text-dim);
}

body.light-theme .info-tooltip__value {
  color: var(--text);
}

/* Light scrollbar */
body.light-theme ::-webkit-scrollbar-thumb {
  background: var(--border-light);
}

body.light-theme ::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}


/* --- Selection --------------------------------------------- */
::selection {
  background: var(--accent-glow);
  color: var(--accent-hover);
}


/* --- Loading overlay --------------------------------------- */
.app-loading {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 150ms ease, visibility 150ms ease;
}

.app-loading--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.app-loading__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-raised);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.app-loading__text {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* --- Status bar styles -------------------------------------- */
.status-bar {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 100%;
  gap: 12px;
  background: rgba(10, 10, 16, 0.6);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.status-bar__item {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-bar__item + .status-bar__item::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-dim);
  margin-right: 8px;
}

.status-bar__value {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.status-bar__badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-bar__badge--linked_list      { background: rgba(79,206,122,0.15); color: var(--success); }
.status-bar__badge--binary_tree      { background: rgba(91,142,247,0.15); color: var(--info); }
.status-bar__badge--stack            { background: rgba(255,184,77,0.15); color: var(--warn); }
.status-bar__badge--queue            { background: rgba(79,206,122,0.15); color: var(--success); }
.status-bar__badge--graph            { background: rgba(255,59,59,0.15); color: var(--error); }
.status-bar__badge--hash_table       { background: rgba(91,142,247,0.15); color: var(--info); }
.status-bar__badge--heap             { background: rgba(255,184,77,0.15); color: var(--warn); }
.status-bar__badge--avl_tree         { background: rgba(79,206,122,0.15); color: var(--success); }
.status-bar__badge--array            { background: rgba(91,142,247,0.15); color: var(--info); }
.status-bar__badge--sort_race        { background: rgba(255,184,77,0.15); color: var(--warn); }
.status-bar__badge--doubly_list      { background: rgba(79,206,122,0.15); color: var(--success); }
.status-bar__badge--circular_list    { background: rgba(255,59,59,0.15); color: var(--error); }
.status-bar__badge--circular_queue   { background: rgba(79,206,122,0.15); color: var(--success); }
.status-bar__badge--dequeue          { background: rgba(91,142,247,0.15); color: var(--info); }

.status-bar__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-bar__fps {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.status-bar__indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px rgba(79,206,122,0.4);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}