/*
 * NEXTGEN VIRTUAL ACADEMY — SQL PRACTICE LAB
 * SQL-specific styles only. Keep layout.css loaded before this file.
 */

/* SQL page containment */
.sql-page,
.sql-page .sql-workspace-grid,
.sql-page .sql-workspace {
  min-width: 0;
  max-width: 100%;
}

.sql-module-label,
.sql-section-label {
  display: block;
  margin: 0 0 6px;
  color: #2563eb;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  line-height: 1.4;
}

/* Progress */
.sql-progress-card {
  width: 100%;
  min-width: 0;
  margin-bottom: 18px;
  padding: 20px 22px;
  overflow: hidden;
  box-sizing: border-box;
}

.sql-progress-header,
.sql-score-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-width: 0;
}

.sql-progress-header > div,
.sql-score-content > div:first-child { min-width: 0; }
.sql-progress-header h2 { margin: 0; color: #0f172a; font-size: 16px; font-weight: 700; }
.sql-progress-header p { margin: 4px 0 0; color: #64748b; font-size: 12px; line-height: 1.5; }
#sqlProgressText { flex: 0 0 auto; color: #2563eb; font-size: 18px; font-weight: 700; }
.sql-progress-track { width: 100%; height: 7px; margin-top: 16px; overflow: hidden; border-radius: 20px; background: #e2e8f0; }
.sql-progress-fill { width: 0%; max-width: 100%; height: 100%; border-radius: inherit; background: #2563eb; transition: width .3s ease; }

/* Workspace */
.sql-workspace-grid {
  display: grid;
  grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
  gap: 18px;
  width: 100%;
  min-width: 0;
  margin-bottom: 18px;
  align-items: start;
}

.sql-workspace-grid > *,
.sql-workspace { min-width: 0; box-sizing: border-box; }

.sql-workspace { width: 100%; overflow: hidden; }

/* Database explorer */
.sql-database-explorer {
  width: 100%;
  min-width: 0;
  min-height: 480px;
  padding: 18px;
  align-self: start;
  overflow: hidden;
  border: 1px solid #1e293b;
  border-radius: 12px;
  background: #0f172a;
  color: #fff;
  box-shadow: 0 6px 18px rgb(15 23 42 / 10%);
  box-sizing: border-box;
}

.sql-panel-title { margin-bottom: 16px; }
.sql-panel-title h2 { margin: 0; color: #fff; font-size: 14px; font-weight: 700; }
.sql-panel-title p { margin: 5px 0 0; color: #94a3b8; font-size: 10px; }

.sql-database-name {
  width: 100%;
  margin-bottom: 12px;
  padding: 11px 12px;
  overflow: hidden;
  border-radius: 7px;
  background: #1e293b;
  color: #f8fafc;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-sizing: border-box;
}

.sql-table-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  margin-bottom: 8px;
  padding: 11px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #1e293b;
  color: #e2e8f0;
  font: inherit;
  text-align: left;
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
  box-sizing: border-box;
}
.sql-table-item:hover { border-color: #334155; background: #26364c; transform: translateX(2px); }
.sql-table-item.active { background: #2563eb; color: #fff; }
.sql-table-item > span:first-child { flex: 0 0 auto; font-size: 14px; }
.sql-table-item > span:last-child { min-width: 0; overflow: hidden; }
.sql-table-item strong,
.sql-table-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sql-table-item strong { font-size: 11px; }
.sql-table-item small { margin-top: 2px; color: #94a3b8; font-size: 9px; }
.sql-table-item.active small { color: #dbeafe; }

.sql-explorer-note { margin-top: 25px; padding: 12px; border: 1px solid #334155; border-radius: 8px; background: #111c2e; }
.sql-explorer-note strong { display: block; color: #93c5fd; font-size: 10px; }
.sql-explorer-note p { margin: 6px 0 0; color: #94a3b8; font-size: 9px; line-height: 1.5; overflow-wrap: anywhere; }

/* Framed SQL sections */
.sql-card,
.sql-challenge-card,
.sql-learning-card {
  width: 100%;
  min-width: 0;
  margin-bottom: 18px;
  padding: 20px 22px;
  overflow: hidden;
  box-sizing: border-box;
}

.sql-card:last-child { margin-bottom: 0; }
.sql-challenge-card { margin-top: 2px; border-top: 3px solid #16a34a; }
.sql-learning-card { margin-top: 2px; margin-bottom: 20px; }

.sql-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
  min-width: 0;
  margin: 0 0 16px;
}

.sql-card-header > div { min-width: 0; }
.sql-card-header h2 { margin: 0; color: #0f172a; font-size: 16px; font-weight: 700; }
.sql-card-header p { margin: 4px 0 0; color: #64748b; font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }

/* Schema, editor and query results */
.schema-box {
  min-height: 74px;
  margin-top: 2px;
  padding: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid #dbeafe;
  border-left: 4px solid #2563eb;
  border-radius: 8px;
  background: #eff6ff;
  color: #334155;
  font-size: 11px;
  line-height: 1.6;
  box-sizing: border-box;
}

.schema-table,
.result-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.schema-table { margin-top: 12px; }
.schema-table th,
.schema-table td { padding: 9px 10px; border-bottom: 1px solid #e2e8f0; text-align: left; }
.schema-table th { background: #f8fafc; color: #334155; font-weight: 700; }
.schema-table td { color: #475569; }

.sql-editor {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 145px;
  padding: 15px;
  border: 1px solid #1e293b;
  border-radius: 8px;
  outline: 0;
  background: #0f172a;
  color: #f8fafc;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.6;
  resize: vertical;
  transition: border-color .2s ease, box-shadow .2s ease;
  box-sizing: border-box;
}
.sql-editor:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgb(37 99 235 / 12%); }

.sql-button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; min-width: 0; margin-top: 12px; }
#queryStatus,
#challengeResult { width: 100%; min-width: 0; margin-top: 12px; }

.status,
.challenge-success,
.challenge-failed { width: 100%; padding: 11px 13px; border-radius: 7px; font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; box-sizing: border-box; }
.status.success,
.challenge-success { border-left: 4px solid #16a34a; background: #f0fdf4; color: #166534; }
.status.error,
.challenge-failed { border-left: 4px solid #dc2626; background: #fef2f2; color: #991b1b; }
.status.info { border-left: 4px solid #2563eb; background: #eff6ff; color: #1e40af; }

.sql-query-result,
.sql-table-data { width: 100%; min-width: 0; margin-top: 15px; overflow-x: auto; overflow-y: hidden; box-sizing: border-box; }
.sql-query-result { border-radius: 8px; }
.result-table { min-width: 500px; }
.result-table th,
.result-table td { padding: 9px 10px; border: 1px solid #e2e8f0; color: #475569; text-align: left; white-space: nowrap; }
.result-table th { background: #eff6ff; color: #1e3a8a; font-weight: 700; }
.result-table tbody tr:nth-child(even) { background: #f8fafc; }
.result-table tbody tr:hover { background: #f1f5f9; }

/* Challenge */
.sql-challenge-number,
.sql-track-count { flex: 0 0 auto; margin-top: 1px; padding: 6px 10px; font-size: 9px; font-weight: 700; white-space: nowrap; }
.sql-challenge-number { border-radius: 6px; background: #16a34a; color: #fff; letter-spacing: .4px; }
.sql-challenge-question { margin: 2px 0 14px; padding: 13px 15px; border: 1px solid #dbeafe; border-left: 4px solid #2563eb; border-radius: 8px; background: #f8fbff; box-sizing: border-box; }
.sql-challenge-question strong { display: block; margin-bottom: 5px; color: #2563eb; font-size: 10px; letter-spacing: .7px; text-transform: uppercase; }
.sql-challenge-question p { margin: 0; color: #334155; font-size: 12px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }

/* Score */
.sql-score-card { width: 100%; min-width: 0; margin-bottom: 18px; padding: 20px 22px; overflow: hidden; box-sizing: border-box; }
.sql-score-content h2 { margin: 0 0 4px; color: #0f172a; font-size: 16px; }
.sql-score-content p { margin: 0; color: #64748b; font-size: 11px; line-height: 1.5; }
.sql-score { flex: 0 0 auto; min-width: 100px; color: #2563eb; font-size: 28px; font-weight: 700; text-align: center; }

/* Learning track */
.sql-track-count { border-radius: 20px; background: #eff6ff; color: #2563eb; }
.sql-learning-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; min-width: 0; }
.sql-learning-item { display: flex; align-items: flex-start; gap: 11px; min-width: 0; padding: 13px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease; box-sizing: border-box; }
.sql-learning-item:hover { border-color: #bfdbfe; box-shadow: 0 4px 12px rgb(37 99 235 / 7%); transform: translateY(-1px); }
.sql-learning-number { display: flex; align-items: center; justify-content: center; flex: 0 0 28px; width: 28px; height: 28px; border-radius: 7px; background: #eff6ff; color: #2563eb; font-size: 9px; font-weight: 700; }
.sql-learning-item > div { min-width: 0; }
.sql-learning-item strong { display: block; color: #0f172a; font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.sql-learning-item p { margin: 3px 0 0; color: #64748b; font-size: 9px; line-height: 1.5; overflow-wrap: anywhere; }

/* Generated SQL text stays within its own scrollable region. */
.sql-workspace pre,
.sql-card pre { max-width: 100%; overflow-x: auto; }

@media (max-width: 1100px) {
  .sql-workspace-grid { grid-template-columns: 210px minmax(0, 1fr); gap: 14px; }
  .sql-database-explorer { padding: 15px; }
  .sql-learning-grid { grid-template-columns: 1fr; }
}

@media (max-width: 950px) {
  .sql-workspace-grid { grid-template-columns: 1fr; gap: 16px; }
  .sql-database-explorer { min-height: auto; }
}

@media (max-width: 600px) {
  .sql-progress-card,
  .sql-score-card,
  .sql-card,
  .sql-challenge-card,
  .sql-learning-card { padding: 16px; }
  .sql-progress-header,
  .sql-card-header,
  .sql-score-content { flex-direction: column; align-items: flex-start; gap: 10px; }
  .sql-button-row { flex-direction: column; align-items: stretch; }
  .sql-button-row .btn { width: 100%; }
  .sql-editor { min-height: 125px; font-size: 11px; }
  .sql-score { align-self: flex-start; text-align: left; }
  .result-table { min-width: 600px; }
}

@media (max-width: 420px) {
  .sql-database-explorer { padding: 13px; }
  .sql-learning-item { padding: 11px; }
  .sql-learning-number { flex-basis: 25px; width: 25px; height: 25px; }
}
