/* ===========================  
   GLOBAL SHELL
   =========================== */

.cleanroom-shell {
  min-height: 100vh;
  padding: 32px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: radial-gradient(circle at top left, #111827 0%, #020617 40%, #02040a 100%);
}

/* Center content + max width */
.cleanroom-shell > * {
  max-width: 1320px;
  margin: 0 auto;
  width: 100%;
}

/* ===========================
   GLASS SURFACES
   =========================== */

.glass-surface {
  background: rgba(15, 23, 42, 0.75);
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.15);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(16px) saturate(140%);
}

/* Card base */
.card {
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.92), rgba(15, 23, 42, 0.86));
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(15, 23, 42, 0.95);
  position: relative;
  overflow: hidden;
}

/* Subtle hover lift */
.card:hover {
  transform: translateY(-1px);
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(55, 65, 81, 0.7);
  transition: all 180ms ease-out;
}

/* ===========================
   HERO BAR
   =========================== */

.cr-hero-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  gap: 12px;
}

.cr-hero-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.cr-hero-subtitle {
  font-size: 13px;
  color: var(--muted, #9ca3af);
  margin-top: 2px;
}

.cr-hero-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: fit-content;
}

.cr-pill {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.cr-pill-soft {
  background: radial-gradient(circle at top, rgba(106, 165, 156, 0.25), rgba(15, 23, 42, 0.9));
  color: #e5fdf4;
}

/* ===========================
   CONTROL BAR
   =========================== */

.cr-control-bar {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  padding: 14px 18px 16px;
  flex-wrap: wrap;
  position: relative; /* needed for dropdown z-index */
  z-index: 10;
}

.cr-control-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
}

.cr-control-block-wide {
  flex: 1 1 260px;
}

.cr-control-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: rgba(148, 163, 184, 0.9);
}

/* Reuse dropdown style but allow slim look */
.cr-control-input .Select-control,
.cr-control-input .Select-multi-value-wrapper {
  min-height: 34px;
}

/* ===========================
   SEGMENTED CATEGORY / DIFF
   =========================== */

.cr-segment-group {
  display: inline-flex;
  padding: 2px;
  border-radius: 999px;
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.95));
  box-shadow: 0 0 0 1px rgba(31, 41, 55, 0.9);
}

.cr-segment {
  border: none;
  outline: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  background: transparent;
  color: rgba(209, 213, 219, 0.9);
  cursor: pointer;
  transition: all 160ms ease-out;
}

.cr-segment:hover {
  background: rgba(31, 41, 55, 0.9);
}

.cr-segment-active {
  background: radial-gradient(circle at top, #6aa59c, #22c3aa);
  color: #020617;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.8),
    0 12px 30px rgba(34, 195, 170, 0.45);
}

/* ===========================
   MAIN SHELL + GRID
   =========================== */

.cr-main-shell {
  margin-top: 4px;
}

.cleanroom-layout {
  margin-top: 4px;
}

.pg-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.1fr);
  gap: 20px;
  align-items: stretch; /* both columns same height */
}

/* On smaller screens stack them */
@media (max-width: 1024px) {
  .pg-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Lesson + Summary column */
.pg-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* SQL/Python work area column */
.pg-right {
  display: flex;
  flex-direction: column;
}

/* ===========================
   LESSON / TUTORIAL + SQL CARDS
   =========================== */

.tutorial-card,
.sql-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 16px;            /* adds space so content isn't "cut off" */
  box-sizing: border-box;
}

/* Generic inner scroll pane (lesson + SQL + others) */
.sql-card .scroll-pane {
  overflow-y: visible !important;
  min-height: 0;
  padding-right: 4px;
}

/* Lesson tab body scrolls, header stays fixed */
.tutorial-card .tutorial-body {
  flex: 1;
}

/* SQL textarea + results scroll, buttons stay fixed */
.sql-card .sql-body {
  flex: 1;
}

/* Footer row: error bar directly above buttons */
.sql-footer {
  display: flex;
  flex-direction: column;   /* stack error bar, then buttons */
  align-items: stretch;
  gap: 6px;                 /* small gap between bar and buttons */
  padding-top: 4px;
}

/* Reserve a tiny strip for the error bar so layout is stable */
.sql-error-bar-wrapper {
  min-height: 18px;         /* enough for single-line error */
  margin: 0;                /* no extra spacing */
}

/* Buttons row: side by side, centered */
.button-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Optional: keep button widths consistent */
.button-row .btn {
  min-width: 110px;
}


/* ===========================
   WORK AREA
   =========================== */

.button-row .btn {
  min-width: 110px;
}

/* Give primary button a glow */
.btn.btn-primary {
  box-shadow:
    0 0 0 1px rgba(34, 197, 167, 0.6),
    0 0 24px rgba(34, 197, 167, 0.5);
  transition: box-shadow 160ms ease-out, transform 160ms ease-out;
}

.btn.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow:
    0 0 0 1px rgba(34, 197, 167, 0.8),
    0 0 32px rgba(34, 197, 167, 0.8);
}

/* ===========================
   TABS
   =========================== */

.tabs-clean .tab {
  border-radius: 999px 999px 0 0;
}

/* extra emphasis on selected tab */
.tabs-clean > .tab--selected {
  box-shadow: inset 0 -2px 0 #6aa59c;
}

/* ===========================
   FUTURISTIC SCROLLBARS
   =========================== */

/* Firefox */
html,
body,
.cleanroom-shell {
  scrollbar-width: thin;
  scrollbar-color: #6aa59c transparent;
}

/* WebKit (Chrome/Edge/Safari) */
html::-webkit-scrollbar,
body::-webkit-scrollbar,
.cleanroom-shell ::-webkit-scrollbar,
.scroll-pane::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
.cleanroom-shell ::-webkit-scrollbar-track,
.scroll-pane::-webkit-scrollbar-track {
  background: transparent;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
.cleanroom-shell ::-webkit-scrollbar-thumb,
.scroll-pane::-webkit-scrollbar-thumb {
  background: linear-gradient(#1f2933, #6aa59c);
  border-radius: 999px;
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
.cleanroom-shell ::-webkit-scrollbar-thumb:hover,
.scroll-pane::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(#111827, #8ff5d1);
}



/* ==========================================
   Dropdown menu (challenge) – glassy & on top
   ========================================== */

.cr-challenge-dropdown .Select-menu-outer {
  z-index: 50 !important;
  background: radial-gradient(
    circle at top left,
    rgba(15, 23, 42, 0.95),
    rgba(15, 23, 42, 0.90)
  );
  backdrop-filter: blur(18px);
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  margin-top: 6px;
}

/* Individual menu options */
.cr-challenge-dropdown .Select-option {
  padding: 10px 14px;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: #d6e3f0;
}

/* Remove border on last item */
.cr-challenge-dropdown .Select-option:last-child {
  border-bottom: none;
}

/* Hover effect */
.cr-challenge-dropdown .Select-option.is-focused {
  background: rgba(106, 165, 156, 0.28);
  color: white;
}

/* Selected option */
.cr-challenge-dropdown .Select-option.is-selected {
  background: rgba(106, 165, 156, 0.55);
  color: white;
}

/* Value displayed when dropdown is closed */
.cr-challenge-dropdown .Select-value-label {
  font-size: 13px;
  letter-spacing: 0.02em;
}

/* =========================================================
   MOBILE: clean 2×2 grid (Category | Platform / Difficulty | Challenge)
   ========================================================= */
@media (max-width: 768px) {

  /* Maintain your 2×2 grid */
  .cr-control-bar.glass-surface {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 12px 14px;
    overflow: visible !important; /* allow dropdown popup to be visible */
  }

  .cr-control-bar.glass-surface .cr-control-block,
  .cr-control-bar.glass-surface .cr-control-block.cr-control-block-wide {
    flex: none !important;
    width: 100% !important;
  }

  /* -------------------------------
     MOBILE-ONLY DROPDOWN FIX
     ------------------------------- */

/* =========================================================
   MOBILE: make dropdown columns narrower ONLY
   ========================================================= */
@media (max-width: 768px) {

  /* platform + challenge control blocks */
  .cr-control-block:has(#cr_platform),
  .cr-control-block:has(#cr_challenge) {
    max-width: 150px !important;     /* adjust to taste */
    width: 100%;
  }

  /* ensure the dropdown fits inside that width */
  .cr-control-input .Select,
  .cr-control-input .Select-control,
  .cr-control-input .Select-multi-value-wrapper {
    width: 100% !important;
    box-sizing: border-box;
  }
}

/* ============================
   MOBILE — shrink dropdowns ONLY
   ============================ */
@media (max-width: 768px) {

  /* shrink dropdown wrapper */
  .cr-small-dd {
    width: 80px !important;     /* adjust: try 120px / 130px / 150px */
  }

  /* shrink the visible Select area */
  .cr-small-dd .Select-control,
  .cr-small-dd .Select {
    width: 100% !important;
    max-width: 140px !important;
    box-sizing: border-box;
  }
}



  /* Make labels smaller */
  .cr-control-label {
    font-size: 11px;
    margin-bottom: 4px;
  }

  .cr-control-input {
    font-size: 12px;
  }
}


/* ===========================================
   MOBILE LAYOUT TWEAKS FOR TUTORIAL + SQL
   =========================================== */

  
  /* cards use natural height; no need to force equal height on mobile */
  .tutorial-card,
  .sql-card {
    height: auto;
    min-height: 0;
  }

  /* inner scroll areas slightly shorter so keyboard doesn't cover everything */
  .tutorial-card .tutorial-body,
  .sql-card .sql-body {
    max-height: 55vh;
  }

  /* buttons stay in view; tweak alignment on small screens */
  .button-row {
    justify-content: flex-start;
  }


/* ===========================
   SQL TEXTAREA HEIGHT OVERRIDE
   =========================== */
#cr_sql_input {
    min-height: 320px !important;   /* starting height */
    height: 300px !important;       /* visual height */
    flex: none !important;          /* don't shrink */
}


/* Buttons row in Try SQL area */
.button-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.button-row .btn {
  min-width: 110px;
}

/* ===========================
   CLEANROOM TABLE THEME
   =========================== */

/* Outer DataTable shell */
.dash-table-container .dash-spreadsheet-container {
  background: var(--card);
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.20);
  overflow-y: visible !important;
  overflow-x: auto !important;


}

/* Inner table */
.dash-table-container .dash-spreadsheet-inner table {
  width: 100%;
  border-collapse: collapse;
}

/* HEADER CELLS: keep strong line after header */
.dash-table-container th {
  background: linear-gradient(90deg, #111827, #020617);
  color: #e5f2ff;
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.40) !important; /* strong */
  border-left: none !important;
  border-right: none !important;
}

/* BODY CELLS: no vertical lines + VERY faint horizontal line */
.dash-table-container td {
  color: #e5e7eb !important;
  background-color: rgba(15, 23, 42, 0.96) !important;
  padding: 6px 12px;

  /* kill verticals */
  border-left: none !important;
  border-right: none !important;

  /* ultra-faint horizontal line */
  border-top: none !important;
  border-bottom: 1px solid rgba(148, 163, 184, 0.03) !important;
}

/* Remove bottom border from the last row so it feels softer */
.dash-table-container tbody tr:last-child td {
  border-bottom: none !important;
}

/* Optional: very subtle zebra striping */
.dash-table-container tbody tr:nth-child(even) td {
  background-color: rgba(15, 23, 42, 0.90) !important;
}

/* Hover: tiny darkening, no glow */
.dash-table-container tbody tr:hover td {
  background-color: rgba(31, 41, 55, 0.98) !important;
}

/* Remove harsh white selection highlight from Dash inline styles */
.dash-table-container td[style*="background-color: rgb(248"],
.dash-table-container td[style*="background-color: rgb(255"] {
  background-color: rgba(17, 24, 39, 0.98) !important;
  border-left: none !important;
  border-right: none !important;
  border-bottom: 1px solid rgba(148, 163, 184, 0.03) !important;
}

/* Optional subtle left accent for selected row (you can remove this if you don't want it) */
.dash-table-container td[style*="background-color: rgb(248"]:first-child,
.dash-table-container td[style*="background-color: rgb(255"]:first-child {
  box-shadow: inset 2px 0 0 #6aa59c;
}

.tab-active {
    border-bottom: 2px solid #6AA59C;
    box-shadow: 0 0 6px #6AA59C;
}
.filter-pill.selected {
    background: #6AA59C22; /* light mint tint */
    box-shadow: 0 0 12px #6AA59C55;
    border: 1px solid #6AA59C;
}
@keyframes successPulse {
  0% { box-shadow: 0 0 0px #6AA59C; }
  100% { box-shadow: 0 0 20px #6AA59C; }
}

.success-glow {
  animation: successPulse 0.8s ease-out;
}
/* Make the whole SQL card a bit tighter on mobile */
@media (max-width: 768px) {
  .sql-card,
  .tutorial-card {
    padding: 12px;
  }

  #cr_sql_input {
    min-height: 260px !important;  /* still big, but not overwhelming */
    height: 260px !important;
  }
}

/* MAIN CLEANROOM PANELS WRAPPER */
.cr-panels-row {
    display: flex;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto 24px;
    gap: 20px;
    align-items: flex-start;
    box-sizing: border-box;
}

/* EACH PANEL */
.cr-panel {
    flex: 1 1 0;
    min-width: 0;
}

/* MOBILE: STACK VERTICALLY */
@media (max-width: 768px) {
    .cr-panels-row {
        flex-direction: column;
        gap: 16px;
    }

    .cr-panel {
        width: 100%;
    }
}
/* ===============================================
   MOBILE ONLY — affects screens ≤ 768px
   =============================================== */
@media (max-width: 768px) {
    /* Stack instead of side-by-side */
    .cr-main-grid,
    .pg-grid.responsive-grid {
        grid-template-columns: 1fr !important;
        row-gap: 20px;
    }

    /* Optional: Work area first (recommended) */

    .cr-main-tutorial {
        order: 1;
    }

    .cr-main-work {
        order: 2;
    }

    /* Allow smooth shrinking */
    .cr-main-panel {
        width: 100%;
        min-width: 0;
    }

    /* Reduce card padding on mobile */
    .cr-main-panel .card {
        padding: 14px !important;
    }
}

@media (max-width: 768px) {
    /* Let tutorial + work cards grow with content */
    .cr-main-panel,
    .cr-main-panel .card {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    /* In case any inner flex is forcing stretch */
    .cr-main-panel .card > div {
        max-height: none !important;
    }

    /* For code blocks / long text not to push sideways */
    .cr-main-panel pre,
    .cr-main-panel code {
        white-space: pre-wrap;
        word-break: break-word;
    }
}
/* Keep Overview / Syntax side-by-side on mobile */
@media (max-width: 768px) {

    /* Tabs container */
    .tutorial-card .tabs-clean {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        width: 100%;
        padding: 0;
        margin: 0;
    }

    /* Dash wraps the Tab components in an extra div */
    .tutorial-card .tabs-clean > div {
        display: flex !important;
        flex-direction: row !important;
        width: 100%;
    }

    /* Each individual tab */
    .tutorial-card .tabs-clean .tab {
        flex: 1 1 0 !important;    /* equal width */
        max-width: 50%;
        text-align: center;
        white-space: nowrap;
        padding: 10px 0;
    }
}
/* ===========================================
   Mobile layout for Expected Output / Table
   =========================================== */
@media (max-width: 768px) {

    /* Make tab headers horizontal instead of stacked */
    .result-tabs {
        display: flex !important;
        flex-direction: row !important;
    }

    .result-tabs > div {
        display: flex !important;
        flex-direction: row !important;
        width: 100%;
    }

    /* Each tab takes 50% width */
    .result-tabs .tab {
        flex: 1 1 0 !important;
        max-width: 50%;
        text-align: center;
        padding: 10px 0 !important;
        white-space: nowrap;
    }
}

/* Add spacing between the title and table */
#cr_expected_wrap,
#cr_table_wrap {
    margin-top: 12px;
}
/* =========================================================
   MOBILE — shrink Previous + Next buttons like dropdown
   ========================================================= */
@media (max-width: 768px) {

  :root {
    --nav-btn-width: 10px;    /* ← CHANGE THIS */
    --nav-btn-height: 34px;   /* ← CHANGE THIS */
    --nav-btn-font: 15px;     /* ← icon size */
  }

  /* Target both buttons */
  .cr-nav-btn,
  #prev-btn,
  #next-btn,
  #cr_prev,
  #cr_next {
    width: var(--nav-btn-width) !important;
    height: var(--nav-btn-height) !important;

    min-width: var(--nav-btn-width) !important;
    min-height: var(--nav-btn-height) !important;

    display: flex !important;
    justify-content: center !important;
    align-items: center !important;

    font-size: var(--nav-btn-font) !important;
    padding: 0 !important;
    line-height: 1 !important;

    border-radius: 12px !important;
    border: 1px solid var(--border) !important;
    background: var(--card) !important;
    color: var(--text) !important;
  }
}

/* ===========================================
   PHONE VIEW (≈ the screenshot you like)
   Lock filters + text inside the card
   =========================================== */
@media (max-width: 430px) {

  /* Slightly tighter padding so nothing spills out */
  .cleanroom-shell {
    padding: 16px 10px 28px;
  }

  /* 2×2 grid: Category | Platform / Difficulty | Challenge  */
  .cr-control-bar.glass-surface {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 10px;
    row-gap: 12px;
    width: 100% !important;
    box-sizing: border-box;
  }

  .cr-control-block,
  .cr-control-block-wide {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Category / Difficulty pill groups fill their half and wrap nicely */
  .cr-segment-group {
    width: 100%;
    box-sizing: border-box;
  }

  .cr-segment {
    flex: 1 1 0;
    font-size: 11px;          /* a bit smaller so text doesn’t spill */
    padding: 6px 6px;
    white-space: normal;      /* allow wrapping inside the pill */
  }

  /* Dropdowns resize with screen (no fixed tiny width) */
  .cr-control-input .Select,
  .cr-control-input .Select-control,
  .cr-control-input .Select-multi-value-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    font-size: 12px;
    min-height: 32px;
  }

  /* Kill any older "small dropdown" overrides */
  .cr-small-dd,
  .cr-small-dd .Select,
  .cr-small-dd .Select-control {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Tutorial title + body a bit tighter like your screenshot */
  .tutorial-card .cr-hero-title {
    font-size: 18px;
  }

  .tutorial-card {
    padding: 12px;
  }
}
/* ===========================================
   PHONE SYNTAX – keep code inside the card
   =========================================== */
@media (max-width: 430px) {

  /* Make lesson code blocks shrink + wrap on small screens */
  .tutorial-card pre,
  .tutorial-card code {
    font-size: 11px;          /* slightly smaller font on phones */
    white-space: pre-wrap;    /* allow wrapping instead of long single line */
    word-break: break-word;   /* break long identifiers/words if needed */
  }

  /* In case your code sits inside a wrapper div, keep scroll inside card */
  .tutorial-card .code-block,
  .tutorial-card .syntax-snippet,
  .tutorial-card .syntax-body {
    max-width: 100%;
    overflow-x: auto;         /* if it *must* scroll, scroll inside card */
  }
}
/* ===========================================
   Make Syntax behave like Overview on mobile
   =========================================== */
@media (max-width: 430px) {

  /* Let the card show full content (avoid clipping) */
  .tutorial-card {
    overflow: visible !important;
  }

  /* Make code wrap just like Overview text */
  .tutorial-card pre,
  .tutorial-card code {
    white-space: pre-wrap !important;    /* allows wrapping */
    word-break: break-word !important;   /* breaks long tokens */
    font-size: 11px !important;          /* matches phone-friendly sizing */
    width: 100% !important;              /* stays inside the card */
    max-width: 100% !important;
  }

  .tutorial-card pre {
    overflow-x: visible !important;
  }
}
/* ======================================================
   BUTTON ROW — All 3 buttons in one line
   ====================================================== */
.button-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-top: 10px;
}

/* Previous / Next buttons — HALF SIZE */
.button-row .nav-btn {
    min-width: 55px !important;   /* small */
    height: 36px !important;
    padding: 4px 6px !important;
    font-size: 13px !important;
    border-radius: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
}

/* Check Answer stays big + glowy */
.button-row .btn-primary {
    min-width: 150px;
    height: 40px;
    font-size: 15px;
    border-radius: 12px;
}

/* ======================================================
   MOBILE: Make navigation buttons EVEN SMALLER
   ====================================================== */
@media (max-width: 430px) {
    .button-row .nav-btn {
        min-width: 44px !important;
        height: 32px !important;
        font-size: 12px !important;
        padding: 2px 4px !important;
    }

    .button-row {
        gap: 8px !important;
    }
}

