/* ==========================================================================
   ET+ AI Tutor — Code Lab Stylesheet
   Code editor, output panel, toolbar, and challenge card
   ========================================================================== */

/* ---------------------------------------------------------------------------
   Layout
   --------------------------------------------------------------------------- */

.codelab-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

.codelab-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.codelab-main {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.codelab-editor-col {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.codelab-sidebar {
  display: flex;
  flex-direction: column;
  width: 340px;
  min-width: 260px;
  max-width: 420px;
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  flex-shrink: 0;
}

/* ---------------------------------------------------------------------------
   Toolbar
   --------------------------------------------------------------------------- */

.cl-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cl-toolbar__group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cl-toolbar__select {
  appearance: none;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--space-2) var(--space-4) var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%238fa3bf' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

.cl-toolbar__select:hover,
.cl-toolbar__select:focus {
  border-color: var(--accent);
}

.cl-toolbar__btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.cl-toolbar__btn:hover {
  background: var(--surface3);
  color: var(--text);
  border-color: var(--border2);
}

.cl-toolbar__btn--run {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
  font-weight: 600;
}

.cl-toolbar__btn--run:hover {
  background: #0d9668;
  border-color: #0d9668;
  color: #fff;
}

.cl-toolbar__btn--clear {
  color: var(--error);
  border-color: rgba(239, 68, 68, 0.3);
}

.cl-toolbar__btn--clear:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: var(--error);
  color: var(--error);
}

.cl-lang-indicator {
  font-size: var(--text-xs);
  color: var(--text3);
  font-family: var(--font-mono);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---------------------------------------------------------------------------
   Editor Area
   --------------------------------------------------------------------------- */

.cl-editor-wrap {
  display: flex;
  flex: 1;
  min-height: 0;
  background: var(--bg2);
  position: relative;
  overflow: hidden;
}

.cl-line-numbers {
  display: block;
  width: 44px;
  flex-shrink: 0;
  padding: var(--space-3) var(--space-2);
  background: var(--bg3);
  border-right: 1px solid var(--border);
  color: var(--text3);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  text-align: right;
  white-space: pre;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.cl-editor {
  flex: 1;
  display: block;
  width: 100%;
  height: 100%;
  padding: var(--space-3);
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.6;
  border: none;
  outline: none;
  resize: none;
  tab-size: 2;
  -moz-tab-size: 2;
  white-space: pre;
  overflow: auto;
  caret-color: var(--accent);
}

.cl-editor::placeholder {
  color: var(--text3);
  opacity: 0.6;
}

.cl-editor::selection {
  background: rgba(59, 130, 246, 0.3);
}

.cl-editor::-moz-selection {
  background: rgba(59, 130, 246, 0.3);
}

/* ---------------------------------------------------------------------------
   Output Panel
   --------------------------------------------------------------------------- */

.cl-output {
  display: flex;
  flex-direction: column;
  height: 180px;
  min-height: 100px;
  border-top: 1px solid var(--border);
  background: var(--bg3);
  flex-shrink: 0;
}

.cl-output__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-1) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.cl-output__title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cl-output__content {
  flex: 1;
  padding: var(--space-3);
  overflow-y: auto;
  overflow-x: auto;
}

.cl-output__pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text2);
}

.cl-output--success {
  color: var(--success);
}

.cl-output--error {
  color: var(--error);
}

.cl-output--info {
  color: var(--info);
}

.cl-output--default {
  color: var(--text3);
}

/* ---------------------------------------------------------------------------
   Challenge Card
   --------------------------------------------------------------------------- */

.cl-challenge {
  display: none;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.cl-challenge__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.cl-challenge__icon {
  font-size: 20px;
}

.cl-challenge__title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-display);
  margin: 0;
}

.cl-challenge__desc {
  font-size: var(--text-sm);
  color: var(--text2);
  line-height: 1.6;
  margin: 0 0 var(--space-3) 0;
}

.cl-challenge__tests {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.cl-challenge__test {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--space-2) var(--space-3);
}

.cl-challenge__test-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}

.cl-challenge__test-row {
  font-size: var(--text-sm);
  color: var(--text2);
  margin-bottom: 2px;
}

.cl-challenge__test-key {
  color: var(--text3);
  font-weight: 500;
}

.cl-challenge__test-row code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}

.cl-challenge__hint {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--space-2) var(--space-3);
}

.cl-challenge__hint summary {
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--warning);
  user-select: none;
  -webkit-user-select: none;
}

.cl-challenge__hint p {
  font-size: var(--text-sm);
  color: var(--text2);
  margin: var(--space-2) 0 0 0;
  line-height: 1.5;
}

/* ---------------------------------------------------------------------------
   Sidebar: ask AI section
   --------------------------------------------------------------------------- */

.cl-ai-section {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.cl-ai-section__title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cl-ai-section__desc {
  font-size: var(--text-sm);
  color: var(--text3);
  line-height: 1.5;
}

.cl-ai-section__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s ease;
}

.cl-ai-section__btn:hover {
  background: #2563eb;
}

/* Sample challenges list */
.cl-samples {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  border-top: 1px solid var(--border);
}

.cl-samples__title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cl-samples__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text2);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  width: 100%;
  font-family: var(--font-body);
}

.cl-samples__item:hover {
  background: var(--surface2);
  border-color: var(--border2);
  color: var(--text);
}

/* ---------------------------------------------------------------------------
   Navbar (reuses whiteboard navbar pattern)
   --------------------------------------------------------------------------- */

.cl-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: rgba(22, 31, 48, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.cl-navbar__logo {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cl-navbar__logo .plus {
  color: var(--accent);
}

.cl-navbar__logo .ai {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.cl-navbar__title {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text2);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cl-navbar__back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.cl-navbar__back:hover {
  background: var(--surface3);
  color: var(--text);
  border-color: var(--border2);
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .codelab-main {
    flex-direction: column;
  }

  .codelab-sidebar {
    width: 100%;
    max-width: none;
    min-width: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    height: auto;
    max-height: 280px;
    overflow-y: auto;
  }
}

@media (max-width: 640px) {
  .cl-toolbar {
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-2);
  }

  .cl-toolbar__btn {
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
  }

  .cl-line-numbers {
    width: 32px;
    font-size: 12px;
    padding: var(--space-2) var(--space-1);
  }

  .cl-editor {
    font-size: 13px;
    padding: var(--space-2);
  }

  .cl-output {
    height: 140px;
    min-height: 80px;
  }

  .cl-navbar__title {
    display: none;
  }
}
