/* ─────────────────────────────────────────────────────────
   RESET & BASE
───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f0e0d;
  --bg1:       #1a1814;
  --bg2:       #252018;
  --border:    #2a2620;
  --border2:   #3a3530;
  --text:      #e8e2d9;
  --text2:     #c8c0b0;
  --text3:     #8a8070;
  --text4:     #5a5040;
  --amber:     #b45309;
  --amber-bg:  #1a1508;
  --amber-bd:  #3a2c08;
  --green:     #4a8040;
  --green-bg:  #101e10;
  --green-bd:  #1a3018;
  --font-body: 'Crimson Pro', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --panel-tutor: 420px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  overflow: hidden;
}

/* ─────────────────────────────────────────────────────────
   LAYOUT SPLIT
───────────────────────────────────────────────────────── */
#layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ── TUTOR PANEL ── */
#tutor-panel {
  width: var(--panel-tutor);
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 24px 20px 48px;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
#tutor-panel::-webkit-scrollbar { width: 5px; }
#tutor-panel::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── PDF PANEL ── */
#pdf-panel {
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg1);
}

#pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

#pdf-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

#pdf-canvas-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  background: #0c0b0a;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
#pdf-canvas-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
#pdf-canvas-wrap::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

#pdf-placeholder {
  text-align: center;
  padding: 80px 40px;
  border: 1px dashed var(--border2);
  border-radius: 4px;
  width: 100%;
  max-width: 480px;
  margin: auto;
}

#pdf-canvas {
  display: block;
  box-shadow: 0 4px 32px rgba(0,0,0,0.6);
  border-radius: 2px;
}

#pdf-goto-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.pdf-goto-input {
  background: var(--bg2);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 3px;
  width: 64px;
  text-align: center;
}
.pdf-goto-input:focus { outline: none; border-color: var(--amber); }
.pdf-goto-input::-webkit-inner-spin-button { opacity: 0; }

/* ─────────────────────────────────────────────────────────
   VIEWS
───────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ─────────────────────────────────────────────────────────
   HOME
───────────────────────────────────────────────────────── */
.home-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
  margin-bottom: 24px;
}
.home-header h1 {
  font-family: var(--font-body);
  font-size: 28px;
  font-weight: 600;
  color: #f0e8d8;
  line-height: 1.2;
  margin: 8px 0 4px;
}
.home-header .subtitle {
  color: var(--text3);
  font-size: 15px;
  font-style: italic;
}

#progress-dots {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.dot-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border2);
  transition: background .2s;
}
.dot.done { background: currentColor; }

/* ─────────────────────────────────────────────────────────
   DAY CARDS (home list)
───────────────────────────────────────────────────────── */
#day-list { display: flex; flex-direction: column; gap: 2px; }

.day-card {
  display: block;
  background: var(--bg1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border2);
  border-radius: 4px;
  padding: 16px 18px;
  cursor: pointer;
  transition: border-left-color .15s;
  text-decoration: none;
  color: inherit;
}
.day-card:hover { border-left-color: var(--accent, #7c3aed); }
.day-card.done { border-left-color: var(--accent, #7c3aed); }

.day-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}
.day-card-arrow { color: var(--text4); font-size: 18px; margin-top: 4px; }

.day-card-title { font-size: 18px; font-weight: 600; color: #e8e0d0; line-height: 1.2; }
.day-card-subtitle { font-size: 13px; color: var(--text3); font-style: italic; margin-top: 2px; }

.day-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.day-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg2);
  color: var(--text3);
  padding: 2px 7px;
  border-radius: 2px;
  letter-spacing: .02em;
}

/* ─────────────────────────────────────────────────────────
   DAY VIEW
───────────────────────────────────────────────────────── */
.day-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.day-title { font-size: 17px; font-weight: 600; color: #e8e0d0; }
.day-subtitle-sm { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; }

.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .05em;
  color: var(--text4);
  padding: 10px 18px 10px 0;
  transition: color .15s, border-color .15s;
}
.tab-btn.active { color: var(--accent, #7c3aed); border-bottom-color: var(--accent, #7c3aed); }

/* ─────────────────────────────────────────────────────────
   CARDS
───────────────────────────────────────────────────────── */
.card {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 18px;
  margin-bottom: 12px;
}

.summary-pre {
  white-space: pre-wrap;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text2);
  margin-bottom: 16px;
}

/* ─────────────────────────────────────────────────────────
   QUESTIONS
───────────────────────────────────────────────────────── */
.q-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .12em;
  margin-bottom: 10px;
}
.q-text {
  font-size: 16px;
  line-height: 1.65;
  color: #d8d0c0;
  margin-bottom: 14px;
}

.q-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.btn-hint, .btn-ans {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text3);
  padding: 5px 12px;
  border-radius: 2px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .04em;
  transition: background .15s, color .15s;
}
.btn-hint.open { background: #2a2010; color: #9a8060; border-color: #3a3020; }
.btn-ans.open  { background: var(--green-bg); color: var(--green); border-color: var(--green-bd); }

.hint-box {
  margin-top: 12px;
  background: #1e1a0e;
  border: 1px solid #3a3010;
  border-radius: 3px;
  padding: 14px;
}
.hint-label { font-family: var(--font-mono); font-size: 10px; color: #8a7020; letter-spacing: .1em; margin-bottom: 6px; }
.hint-text  { font-size: 15px; color: #b8a860; line-height: 1.6; }

.ans-box {
  margin-top: 12px;
  background: var(--green-bg);
  border: 1px solid var(--green-bd);
  border-radius: 3px;
  padding: 14px;
}
.ans-label { font-family: var(--font-mono); font-size: 10px; color: #4a8040; letter-spacing: .1em; margin-bottom: 6px; }
.ans-text  { white-space: pre-wrap; font-family: var(--font-body); font-size: 15px; color: #88b878; line-height: 1.75; }

/* ─────────────────────────────────────────────────────────
   EXERCISES
───────────────────────────────────────────────────────── */
.ex-list-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text4);
  letter-spacing: .12em;
  margin-bottom: 16px;
}
.ex-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--bg2);
}
.ex-item:last-child { border-bottom: none; }

.ex-checkbox {
  width: 20px; height: 20px;
  border-radius: 2px;
  border: 1px solid var(--border2);
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: background .15s, border-color .15s;
}
.ex-checkbox.done { border-color: var(--accent,#7c3aed); color: var(--accent,#7c3aed); }

.ex-num {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  margin-bottom: 3px;
}
.ex-text { font-size: 15px; color: var(--text2); line-height: 1.55; }

/* ─────────────────────────────────────────────────────────
   EXAM
───────────────────────────────────────────────────────── */
#exam-list { display: flex; flex-direction: column; gap: 10px; }

.exam-item { margin-bottom: 0; }
.exam-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.exam-n { font-family: var(--font-mono); font-size: 10px; color: var(--amber); letter-spacing: .12em; }
.exam-tags { display: flex; gap: 7px; }
.exam-topic { font-family: var(--font-mono); font-size: 10px; background: var(--bg2); color: var(--text3); padding: 2px 8px; border-radius: 2px; }
.exam-dif   { font-family: var(--font-mono); font-size: 10px; padding: 2px 8px; border-radius: 2px; }
.exam-dif.hard   { background: #1e1010; color: #c06060; }
.exam-dif.medium { background: #1e1a0e; color: #8a7020; }

.exam-q { font-size: 16px; line-height: 1.65; color: #d8d0c0; margin-bottom: 14px; }

.btn-exam-hint {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text4);
  padding: 5px 12px;
  border-radius: 2px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .04em;
  transition: all .15s;
}
.btn-exam-hint.open { background: #1e1010; color: #c06060; border-color: #4a2020; }

.exam-hint-box {
  margin-top: 12px;
  background: var(--amber-bg);
  border: 1px solid var(--amber-bd);
  border-radius: 3px;
  padding: 14px;
  font-size: 15px;
  color: #a89040;
  line-height: 1.65;
}

.exam-footer {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
  font-size: 16px;
  color: var(--text4);
  font-style: italic;
  text-align: center;
}

/* ─────────────────────────────────────────────────────────
   NOTICE
───────────────────────────────────────────────────────── */
.notice {
  border-radius: 4px;
  padding: 13px 16px;
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 18px;
}
.notice.warning {
  background: var(--amber-bg);
  border: 1px solid var(--amber-bd);
  color: #a89040;
  font-style: italic;
}

/* ─────────────────────────────────────────────────────────
   BUTTONS SHARED
───────────────────────────────────────────────────────── */
.btn-back {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text3);
  padding: 6px 13px;
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .05em;
  flex-shrink: 0;
}
.btn-back:hover { border-color: var(--text3); color: var(--text); }

.btn-mark {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text3);
  padding: 9px 18px;
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .05em;
  transition: all .15s;
}
.btn-mark.done { background: #1a2e1a; border-color: #2d5a2d; color: #5a9a5a; }

.pdf-btn {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text3);
  padding: 4px 10px;
  border-radius: 2px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .03em;
  transition: color .15s, border-color .15s;
}
.pdf-btn:hover { color: var(--text); border-color: var(--text3); }

.upload-label { cursor: pointer; }

/* ─────────────────────────────────────────────────────────
   UTILITY
───────────────────────────────────────────────────────── */
.mono { font-family: var(--font-mono); }
.label-sm { font-size: 11px; letter-spacing: .05em; }

/* ─────────────────────────────────────────────────────────
   RESPONSIVE: mobile stack
───────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  :root { --panel-tutor: 100vw; }
  #layout { flex-direction: column; overflow: auto; height: auto; }
  #tutor-panel { width: 100%; height: auto; overflow: visible; border-right: none; border-bottom: 1px solid var(--border); }
  #pdf-panel { height: 70vh; }
  body { overflow: auto; }
}


/* ─────────────────────────────────────────────────────────
   TEMA CLARO / ESCURO + PAINÉIS REDIMENSIONÁVEIS
───────────────────────────────────────────────────────── */
body[data-theme="light"] {
  --bg:        #f7f2ea;
  --bg1:       #fffaf2;
  --bg2:       #efe5d8;
  --border:    #dfd1bf;
  --border2:   #c9b8a3;
  --text:      #1f1a16;
  --text2:     #3a3128;
  --text3:     #6a5c4e;
  --text4:     #8a7860;
  --amber-bg:  #fff4dc;
  --amber-bd:  #e2bc74;
  --green-bg:  #eaf6ea;
  --green-bd:  #b9d9b2;
}

body[data-theme="light"] .home-header h1,
body[data-theme="light"] .day-card-title,
body[data-theme="light"] .day-title {
  color: #231a13;
}

body[data-theme="light"] .q-text,
body[data-theme="light"] .exam-q {
  color: #342920;
}

body[data-theme="light"] #pdf-canvas-wrap {
  background: #eee5da;
}

body[data-theme="light"] .pdf-page-canvas {
  box-shadow: 0 4px 24px rgba(50, 35, 20, 0.18);
}

#app-topbar {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

#layout {
  height: calc(100vh - 42px);
}

#tutor-panel {
  width: var(--panel-tutor);
  min-width: 300px;
  max-width: 72vw;
}

#panel-resizer {
  width: 7px;
  flex: 0 0 7px;
  cursor: col-resize;
  background: var(--border);
  border-left: 1px solid var(--border2);
  border-right: 1px solid var(--border2);
}

#panel-resizer:hover,
body.resizing #panel-resizer {
  background: var(--amber);
}

body.resizing {
  cursor: col-resize;
  user-select: none;
}

#pdf-pages {
  width: 100%;
  align-items: center;
  flex-direction: column;
  gap: 22px;
}

.pdf-page-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  width: max-content;
  max-width: 100%;
}

.pdf-page-label {
  color: var(--text3);
  align-self: flex-start;
}

.pdf-page-canvas {
  display: block;
  max-width: none;
  box-shadow: 0 4px 32px rgba(0,0,0,0.6);
  border-radius: 2px;
  background: white;
}

.pdf-loading {
  color: var(--text3);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 28px;
}

/* O canvas antigo não é mais usado, mas mantemos oculto caso exista em algum cache. */
#pdf-canvas {
  display: none !important;
}

@media (max-width: 760px) {
  #app-topbar {
    justify-content: center;
  }

  #layout {
    height: auto;
  }

  #panel-resizer {
    display: none;
  }

  #tutor-panel {
    min-width: 100%;
    max-width: 100%;
  }

  #pdf-pages {
    align-items: flex-start;
  }
}
