/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #1a1a2e;
  --panel:     #16213e;
  --surface:   #0f3460;
  --accent:    #e94560;
  --accent2:   #53d8fb;
  --text:      #eaeaea;
  --text-muted:#8892a4;
  --border:    #2a3a5c;
  --radius:    8px;
  --header-h:  54px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

/* ===== HEADER ===== */
.header {
  height: var(--header-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
}

.header__brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1px;
  flex-shrink: 0;
}

.header__controls {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.timer {
  font-family: 'Consolas', monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: 2px;
  margin-left: auto;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.timer--warning { color: #f59e0b; border-color: #f59e0b; }
.timer--danger  { color: var(--accent); border-color: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
}
.select:focus { border-color: var(--accent2); }

/* ===== WORKSPACE ===== */
.workspace {
  display: grid;
  grid-template-columns: 55fr 45fr;
  height: calc(100vh - var(--header-h));
  margin-top: var(--header-h);
  overflow: hidden;
}

/* ===== PANEL BASE ===== */
.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}
.panel--right { border-right: none; }

/* ===== PROBLEM STATEMENT ===== */
.problem-statement {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
  max-height: 38vh;
  overflow-y: auto;
}
.problem-statement__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent2);
  margin-bottom: 8px;
}
.problem-statement__desc {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  font-family: inherit;
}
.test-cases {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.test-case {
  background: var(--surface);
  border-radius: 4px;
  padding: 5px 10px;
  font-family: 'Consolas', monospace;
  font-size: 12px;
  color: var(--text-muted);
}
.test-case span { color: var(--accent2); }

/* ===== EDITOR ===== */
.code-area {
  flex: 1;
  min-height: 0;
  width: 100%;
  background: #1e1e1e;
  color: #d4d4d4;
  border: none;
  outline: none;
  resize: none;
  padding: 12px 16px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  tab-size: 4;
}

.editor-footer {
  padding: 10px 16px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ===== CHAT ===== */
.chat__messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.message-row--user { flex-direction: row; justify-content: flex-end; }

.message-icon {
  font-size: 20px;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
}

.message {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.55;
  font-size: 13px;
  word-break: break-word;
}
.message--ai {
  background: var(--panel);
  border-left: 3px solid var(--accent2);
  align-self: flex-start;
}
.message--user {
  background: var(--surface);
  align-self: flex-end;
}
.message--ai p { margin-bottom: 6px; }
.message--ai p:last-child { margin-bottom: 0; }
.message--ai code {
  background: var(--bg);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: 'Consolas', monospace;
  font-size: 12px;
  color: var(--accent2);
}
.message--ai pre {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 10px 12px;
  overflow-x: auto;
  margin: 6px 0;
}
.message--ai pre code {
  background: none;
  padding: 0;
  color: var(--text);
  font-size: 12px;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 10px 14px;
}
.typing-indicator span {
  width: 6px; height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

.chat__input-area {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.chat__input {
  flex: 1;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.5;
}
.chat__input:focus { border-color: var(--accent2); }
.chat__input::placeholder { color: var(--text-muted); }

/* ===== BUTTONS ===== */
.btn {
  border: none;
  border-radius: var(--radius);
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary  { background: var(--accent);  color: #fff; }
.btn--primary:hover:not(:disabled)  { opacity: 0.88; }
.btn--secondary { background: var(--accent2); color: var(--bg); }
.btn--secondary:hover:not(:disabled) { opacity: 0.88; }
.btn--ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn--ghost:hover:not(:disabled) { border-color: var(--text-muted); color: var(--text); }

.header__user {
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* spinner inside button */
.btn .spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.modal-overlay.modal-overlay--visible {
  display: flex;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(620px, 94vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal__title { font-size: 16px; font-weight: 700; }
.modal__close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 22px; line-height: 1;
  padding: 2px 6px; border-radius: 4px;
}
.modal__close:hover { color: var(--text); background: var(--surface); }

.modal__body {
  overflow-y: auto;
  padding: 20px 22px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal__footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* report header */
.report-header { display: flex; flex-direction: column; gap: 8px; }

.report-outcome {
  font-size: 17px;
  font-weight: 700;
}
.report-outcome--pass { color: #34d399; }
.report-outcome--fail { color: var(--accent); }

/* hiring decision badge */
.hiring-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  align-self: flex-start;
}
.hiring-badge--strong-hire    { background: rgba(52,211,153,0.15);  color: #34d399; border: 1px solid #34d399; }
.hiring-badge--weak-hire      { background: rgba(251,191,36,0.12);  color: #fbbf24; border: 1px solid #fbbf24; }
.hiring-badge--no-hire        { background: rgba(233,69,96,0.12);   color: var(--accent); border: 1px solid var(--accent); }
.hiring-badge--strong-no-hire { background: rgba(127,29,29,0.25);   color: #f87171; border: 1px solid #f87171; }

.hiring-reason {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* report sections */
.report-section-heading {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  margin-top: 2px;
}

.report-list {
  margin: 0 0 4px 18px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.report-list li {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}

/* verdict badge */
.verdict-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  align-self: flex-start;
}
.verdict-badge--pass { background: rgba(52, 211, 153, 0.15); color: #34d399; border: 1px solid #34d399; }
.verdict-badge--fail { background: rgba(233, 69, 96, 0.15);  color: var(--accent); border: 1px solid var(--accent); }

/* complexity */
.complexity-row { display: flex; gap: 10px; flex-wrap: wrap; }
.complexity-item {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.complexity-label { display: block; font-size: 11px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; letter-spacing: 0.6px; }
.complexity-value { font-size: 15px; font-family: 'Consolas', monospace; color: var(--accent2); }

/* bugs */
.bugs-section__heading {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.bug-item {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 10px 14px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bug-item__location { font-size: 11px; color: var(--text-muted); }
.bug-item__issue { font-size: 13px; }
.bug-item__fix { font-size: 12px; color: var(--accent2); }

.no-bugs {
  color: #34d399;
  font-size: 13px;
}

/* note */
.note-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
