/*
 * main.css — global reset, CSS custom properties, and shared styles.
 *
 * Fonts: drop font files into public/fonts/ and uncomment the @font-face
 * blocks below. Falls back to system fonts if files are not present.
 *
 * @font-face {
 *   font-family: 'Clash Grotesk';
 *   src: url('/fonts/ClashGrotesk-Variable.woff2') format('woff2');
 *   font-weight: 200 700;
 *   font-display: swap;
 * }
 *
 * @font-face {
 *   font-family: 'IBM Plex Mono';
 *   src: url('/fonts/IBMPlexMono-Regular.woff2') format('woff2');
 *   font-weight: 400;
 *   font-display: swap;
 * }
 */

/* ─── Reset ────────────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ─── Brand tokens (theme-independent) ─────────────────────────────────────── */

:root {
  --red5-black:     #0c0c0c;
  --red5-red:       #db1f26;
  --red5-gray:      #6c757d;
  --red5-lightgray: #d2d4d6;
  --red5-offwhite:  #f5f5f5;

  --font-sans: 'Clash Grotesk', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', 'Fira Code', monospace;
}

/* ─── Light theme (default) ─────────────────────────────────────────────────── */

:root {
  --bg:              #ffffff;
  --bg-secondary:    #f5f5f5;
  --bg-card:         #ffffff;
  --bg-panel:        #f0f0f0;

  --text:            #0c0c0c;
  --text-secondary:  #6c757d;
  --text-muted:      #9ca3af;

  --border:          #d2d4d6;
  --border-subtle:   #e8e8e8;

  --accent:          #db1f26;
  --accent-hover:    #b91c1c;
  --link:            #db1f26;

  --btn-primary-bg:     #0c0c0c;
  --btn-primary-text:   #ffffff;
  --btn-primary-hover:  #333333;

  --btn-danger-bg:      #db1f26;
  --btn-danger-text:    #ffffff;
  --btn-danger-hover:   #b91c1c;

  --btn-ghost-border:   #d2d4d6;
  --btn-ghost-text:     #6c757d;
  --btn-ghost-hover-border: #9ca3af;
  --btn-ghost-hover-text:   #0c0c0c;

  --log-bg:          #f8f8f8;
  --log-border:      #e0e0e0;
  --log-text:        #374151;
  --log-success:     #065f46;
  --log-error:       #dc2626;

  --status-idle-bg:         #f0f0f0;
  --status-idle-text:       #6c757d;
  --status-connecting-bg:   #fef3c7;
  --status-connecting-text: #d97706;
  --status-connected-bg:    #d1fae5;
  --status-connected-text:  #065f46;
  --status-error-bg:        #fee2e2;
  --status-error-text:      #dc2626;

  --input-bg:       #ffffff;
  --input-border:   #d2d4d6;
  --input-text:     #0c0c0c;
  --input-focus:    #db1f26;
  --input-placeholder: #9ca3af;
}

/* ─── Dark theme ────────────────────────────────────────────────────────────── */

[data-theme='dark'] {
  --bg:              #0f172a;
  --bg-secondary:    #1e293b;
  --bg-card:         #1e293b;
  --bg-panel:        #1e293b;

  --text:            #e2e8f0;
  --text-secondary:  #94a3b8;
  --text-muted:      #64748b;

  --border:          #334155;
  --border-subtle:   #1e293b;

  --accent:          #db1f26;
  --accent-hover:    #ef4444;
  --link:            #f87171;

  --btn-primary-bg:     #db1f26;
  --btn-primary-text:   #ffffff;
  --btn-primary-hover:  #b91c1c;

  --btn-danger-bg:      #dc2626;
  --btn-danger-text:    #ffffff;
  --btn-danger-hover:   #ef4444;

  --btn-ghost-border:   #334155;
  --btn-ghost-text:     #94a3b8;
  --btn-ghost-hover-border: #64748b;
  --btn-ghost-hover-text:   #e2e8f0;

  --log-bg:          #0f172a;
  --log-border:      #1e293b;
  --log-text:        #94a3b8;
  --log-success:     #4ade80;
  --log-error:       #f87171;

  --status-idle-bg:         #1e293b;
  --status-idle-text:       #64748b;
  --status-connecting-bg:   #1c3149;
  --status-connecting-text: #38bdf8;
  --status-connected-bg:    #14291f;
  --status-connected-text:  #4ade80;
  --status-error-bg:        #2c1a1a;
  --status-error-text:      #f87171;

  --input-bg:        #1e293b;
  --input-border:    #334155;
  --input-text:      #f1f5f9;
  --input-focus:     #db1f26;
  --input-placeholder: #475569;
}

/* ─── Base ──────────────────────────────────────────────────────────────────── */

html {
  font-family: var(--font-sans);
  font-size: 100%;
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s, color 0.2s;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

/* ─── Shared layout ─────────────────────────────────────────────────────────── */

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

.page__heading {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.page__subheading,
.page__description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.breadcrumb a {
  color: var(--link);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

/* ─── Buttons ───────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1.2rem;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn--primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}

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

.btn--primary:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn--danger {
  background: var(--btn-danger-bg);
  color: var(--btn-danger-text);
}

.btn--danger:hover {
  background: var(--btn-danger-hover);
}

.btn--danger:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn--ghost {
  background: transparent;
  border: 1px solid var(--btn-ghost-border);
  color: var(--btn-ghost-text);
  border-radius: 999px;
}

.btn--ghost:hover {
  border-color: var(--btn-ghost-hover-border);
  color: var(--btn-ghost-hover-text);
}

/* ─── Status badges ─────────────────────────────────────────────────────────── */

.status {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}

.status--idle       { background: var(--status-idle-bg);       color: var(--status-idle-text); }
.status--connecting { background: var(--status-connecting-bg); color: var(--status-connecting-text); }
.status--connected  { background: var(--status-connected-bg);  color: var(--status-connected-text); }
.status--error      { background: var(--status-error-bg);      color: var(--status-error-text); }

/* ─── Log panel ─────────────────────────────────────────────────────────────── */

.log {
  background: var(--log-bg);
  border: 1px solid var(--log-border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.7;
  min-height: 240px;
  max-height: 480px;
  overflow-y: auto;
  color: var(--log-text);
}

.log__line--info    { color: var(--log-text); }
.log__line--success { color: var(--log-success); }
.log__line--error   { color: var(--log-error); }
