/* ==========================================================================
   PRINTPY STUDIO — INDUSTRY-GRADE RESPONSIVE UI & DESIGN OF PRINTPY A4 CSS
   ========================================================================== */
:root {
  --bg-app: #cfcfd1;
  --bg-panel: #ffffff;
  --bg-dark: #18181b;
  --bg-darker: #09090b;
  --bg-muted: #e4e4e7;
  --border: #d4d4d8;
  --border-strong: #a1a1aa;
  --text-main: #18181b;
  --text-muted: #52525b;
}

* {
  box-sizing: border-box;
  -webkit-print-color-adjust: exact !important;
  print-color-adjust: exact !important;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
}

/* Navbar */
.navbar {
  background: var(--bg-darker);
  color: #ffffff;
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 2px solid #27272a;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  background: #ffffff;
  color: #09090b;
  font-family: Consolas, "Courier New", monospace;
  font-weight: 900;
  font-size: 15px;
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: -0.5px;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.brand-sub {
  font-size: 11px;
  color: #a1a1aa;
  display: block;
}

.nav-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-btn {
  background: #27272a;
  color: #e4e4e7;
  border: 1px solid #3f3f46;
  padding: 7px 13px;
  border-radius: 5px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-btn:hover {
  background: #3f3f46;
  color: #ffffff;
}

.nav-btn.active, .nav-btn.primary {
  background: #ffffff;
  color: #09090b;
  border-color: #ffffff;
  font-weight: 700;
}

.py-status {
  font-size: 11.5px;
  background: #27272a;
  color: #d4d4d8;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid #3f3f46;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a1a1aa;
}

.status-dot.ready {
  background: #ffffff;
  box-shadow: 0 0 6px #ffffff;
}

/* Main Container */
.app-container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 16px;
}

/* Metadata Card */
.meta-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.meta-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-card-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-main);
}

.meta-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.field-group input, .field-group select {
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  font-size: 13px;
  color: var(--text-main);
  background: #fafafa;
  font-family: inherit;
}

.field-group input:focus {
  outline: 2px solid #18181b;
  background: #ffffff;
}

/* PDF Dropzone */
.pdf-upload-panel {
  display: none;
  background: #ffffff;
  border: 2px dashed #18181b;
  border-radius: 8px;
  padding: 22px;
  margin-bottom: 16px;
  text-align: center;
}

.pdf-upload-panel.visible {
  display: block;
}

.pdf-dropzone {
  max-width: 680px;
  margin: 0 auto;
}

.pdf-dropzone h3 {
  margin: 0 0 6px 0;
  font-size: 17px;
  color: #09090b;
}

.pdf-dropzone p {
  margin: 0 0 14px 0;
  font-size: 13px;
  color: #52525b;
}

.file-input-label {
  display: inline-block;
  background: #09090b;
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.file-input-label:hover {
  background: #27272a;
}

/* Workspace Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
  margin-bottom: 24px;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.panel-header {
  background: #18181b;
  color: #ffffff;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.panel-title {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-pill {
  background: #3f3f46;
  color: #fafafa;
  font-family: Consolas, monospace;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: none;
}

/* Action Bar & Mobile Symbol Strip */
.action-bar {
  background: #e4e4e7;
  border-bottom: 1px solid var(--border-strong);
  padding: 8px 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.btn-run {
  background: #09090b;
  color: #ffffff;
  border: 1px solid #09090b;
  padding: 8px 16px;
  border-radius: 5px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-run:hover {
  background: #27272a;
}

.btn-run:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-secondary {
  background: #ffffff;
  color: #18181b;
  border: 1px solid #71717a;
  padding: 6px 11px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-secondary:hover {
  background: #f4f4f5;
}

.symbol-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
  flex: 1;
}

.symbol-label {
  font-size: 10.5px;
  font-weight: 700;
  color: #52525b;
  margin-right: 2px;
  white-space: nowrap;
  text-transform: uppercase;
}

.sym-btn {
  background: #ffffff;
  color: #09090b;
  border: 1px solid #a1a1aa;
  border-bottom: 2px solid #71717a;
  border-radius: 4px;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.sym-btn:active, .sym-btn:hover {
  background: #18181b;
  color: #ffffff;
  border-color: #09090b;
}

/* Editor Wrapper */
.editor-wrapper {
  display: flex;
  position: relative;
  height: 430px;
  background: #fafafa;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.45;
}

.editor-gutter {
  width: 40px;
  background: #f0f0f3;
  border-right: 1px solid #d4d4d8;
  color: #71717a;
  text-align: right;
  padding: 10px 6px 10px 0;
  user-select: none;
  overflow: hidden;
  font-size: 11.5px;
  line-height: 1.45;
}

textarea.code-editor {
  flex: 1;
  border: none;
  resize: none;
  padding: 10px 12px;
  background: transparent;
  color: #09090b;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.45;
  outline: none;
  white-space: pre;
  overflow: auto;
  tab-size: 4;
  max-height: 1050px;
}

/* Terminal Output */
.terminal-toolbar {
  background: #e4e4e7;
  border-bottom: 1px solid var(--border-strong);
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.terminal-box {
  flex: 1;
  height: 430px;
  background: #f4f4f5;
  padding: 12px;
  overflow: auto;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.4;
  color: #18181b;
  white-space: pre-wrap;
  margin: 0;
}

/* ==========================================================================
   DESIGN OF PRINTPY — A4 SHEET PREVIEW & PRINT LAYOUT (BLACK, WHITE & GRAY)
   ========================================================================== */
.preview-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: #18181b;
  color: #fafafa;
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 14px;
}

.sheet-scroll-wrap {
  overflow-x: auto;
  padding-bottom: 24px;
}

.sheet {
  width: 210mm;
  margin: 0 auto;
  background: #ffffff;
  padding: 12mm 14mm;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  color: #18181b;
}

.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 2px solid #18181b;
  padding-bottom: 8px;
  margin-bottom: 12px;
  gap: 12px;
}

.doc-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #09090b;
  margin: 0;
}

.doc-subtitle {
  font-size: 11px;
  color: #52525b;
  margin-top: 2px;
  font-weight: 500;
}

.student-badge {
  background: #f4f4f5;
  border: 1px solid #a1a1aa;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11.5px;
  color: #18181b;
  white-space: nowrap;
}

.section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #e4e4e7;
  border: 1px solid #a1a1aa;
  border-left: 4px solid #18181b;
  padding: 4px 10px;
  margin: 10px 0 6px 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #18181b;
  break-after: avoid;
}

.section-tag {
  font-family: Consolas, "Courier New", monospace;
  font-size: 10px;
  font-weight: 600;
  color: #52525b;
  text-transform: none;
}

.code-container, .output-container {
  border: 1px solid #a1a1aa;
  border-radius: 3px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 10px;
  line-height: 1.24;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.code-container {
  background: #fafafa;
  padding: 6px 0;
}

.output-container {
  background: #f4f4f5;
  padding: 8px 12px;
}

.code-line {
  display: flex;
  padding: 0 10px 0 0;
}

.code-line.q-divider {
  background: #f0f0f3;
  border-top: 1px dashed #d4d4d8;
  border-bottom: 1px dashed #d4d4d8;
  margin: 1px 0;
}

.ln {
  width: 28px;
  text-align: right;
  padding-right: 8px;
  color: #a1a1aa;
  user-select: none;
  border-right: 1px solid #e4e4e7;
  margin-right: 10px;
  flex-shrink: 0;
}

.lc {
  white-space: pre-wrap;
  word-break: break-word;
  color: #18181b;
}

.kw { font-weight: 700; color: #000000; }
.cmt { color: #52525b; font-style: italic; font-weight: 600; }

.out-block {
  break-inside: avoid;
  padding: 4px 0;
  border-bottom: 1px solid #d4d4d8;
}

.out-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.out-pre {
  margin: 0;
  white-space: pre-wrap;
  color: #27272a;
}

.ans-highlight {
  display: inline-block;
  background: #e4e4e7;
  border: 1px solid #71717a;
  color: #000000;
  font-weight: 700;
  padding: 1px 6px;
  margin-top: 2px;
  border-radius: 2px;
}

/* Responsive Breakpoints */
@media (max-width: 920px) {
  .meta-grid { grid-template-columns: repeat(2, 1fr); }
  .workspace-grid { grid-template-columns: 1fr; }
  .editor-wrapper, .terminal-box { height: 320px; }
  
}

@media (max-width: 540px) {
  .meta-grid { grid-template-columns: 1fr; }
  .app-container { padding: 10px; }
  .navbar { padding: 10px 12px; }

  .action-bar {
  background: #e4e4e7;
  border-bottom: 1px solid var(--border-strong);
  padding: 8px 10px;
  display: grid;
  align-items: center;
  gap: 8px;
  z-index: 10;
  }
  .symbol-label {
    display: none;
  }


  


.nav-btn {
  padding: 5px 5px;
  font-size: 11px;
}

}

/* Print Rules */
@page {
  size: A4 portrait;
  margin: 10mm 12mm;
}

@media print {

  body {
    background: #ffffff !important;
    padding: 0 !important;
  }
  .no-print {
    display: none !important;
  }
  .app-container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .sheet-scroll-wrap {
    overflow: visible !important;
    padding: 0 !important;
  }
  .sheet {
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    display: block !important;
  }
}
