@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:wght@400;700&family=Manrope:wght@400;500;600;700&display=swap');

:root {
  --bg: #f5f1ea;
  --bg-card: #FFFFFF;
  --bg-card-hover: #f0ece4;
  --bg-input: #FFFFFF;
  --border: rgba(16,20,23,.12);
  --border-strong: rgba(16,20,23,.2);
  --ink: #101417;
  --text: #101417;
  --text-secondary: #5f6b73;
  --text-muted: #8a9199;
  --petrol: #0E2433;
  --petrol-light: rgba(14,36,51,.08);
  --gold: #b59a55;
  --gold-light: rgba(181,154,85,.12);
  --green: #4a7c5c;
  --green-light: #edf5f0;
  --yellow: #b59a55;
  --red: #a04040;
  --red-light: #faf0f0;
  --orange: #c17b3a;
  --radius: 18px;
  --radius-sm: 10px;
  --nav-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --shadow: 0 10px 30px rgba(0,0,0,.08);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  font-family: 'Manrope', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#root { height: 100%; display: flex; flex-direction: column; }

.page {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px calc(var(--nav-height) + var(--safe-bottom) + 20px);
  -webkit-overflow-scrolling: touch;
}

.page-title {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 26px;
  font-weight: 400;
  margin-bottom: 20px;
  letter-spacing: -0.2px;
  color: var(--petrol);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: -16px;
  margin-bottom: 20px;
  letter-spacing: 0.2px;
}

/* Bottom nav */
.bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--nav-height);
  padding-bottom: var(--safe-bottom);
  background: var(--petrol);
  border-top: 1px solid rgba(181,154,85,.28);
  flex-shrink: 0;
  z-index: 50;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 12px;
  border: none;
  background: none;
  color: rgba(255,255,255,.45);
  font-size: 10px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s;
  letter-spacing: 0.3px;
}
.nav-item.active { color: var(--gold); }
.nav-item svg { width: 21px; height: 21px; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}

/* Forms */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.form-select, .form-input, .form-textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-select:focus, .form-input:focus, .form-textarea:focus {
  border-color: var(--petrol);
  box-shadow: 0 0 0 3px var(--petrol-light);
}
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238a9199' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Buttons */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.2px;
}
.btn-primary { background: var(--petrol); color: #FFF; }
.btn-primary:active { background: #1a3a4d; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:active { background: var(--bg-card-hover); }
.btn-danger { background: var(--red-light); color: var(--red); border: 1px solid rgba(160,64,64,0.2); }
.btn-small { padding: 8px 14px; font-size: 13px; width: auto; }

/* Chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.chip.active {
  background: var(--petrol);
  border-color: var(--petrol);
  color: #FFF;
}

/* Status */
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-nao_estudado { background: var(--text-muted); }
.status-em_andamento { background: var(--gold); }
.status-revisar { background: var(--orange); }
.status-consolidado { background: var(--green); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 24px; }
.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-value {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.5px;
  color: var(--petrol);
}
.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

/* Sections */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 18px;
  font-weight: 400;
  color: var(--petrol);
}

/* Expandable */
.expand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s;
}
.expand-header:active { background: var(--bg-card-hover); }
.expand-title { font-size: 14px; font-weight: 500; flex: 1; text-align: left; color: var(--petrol); }
.expand-arrow { color: var(--text-muted); font-size: 11px; transition: transform 0.2s; }
.expand-arrow.open { transform: rotate(180deg); }
.expand-body { padding: 0 4px; margin-bottom: 8px; }

/* Topic rows */
.topic-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.topic-row:last-child { border-bottom: none; }
.topic-info { flex: 1; min-width: 0; }
.topic-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.topic-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.topic-pct {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 15px;
  font-weight: 400;
  white-space: nowrap;
}

/* Session cards */
.session-card { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.session-info { flex: 1; min-width: 0; }
.session-disc {
  font-size: 11px;
  color: var(--gold);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.session-topic {
  font-size: 14px;
  font-weight: 500;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--petrol);
}
.session-details { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.session-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; font-weight: 500; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14,36,51,0.35);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-content {
  background: var(--bg-card);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px 16px calc(16px + var(--safe-bottom));
  animation: slideUp 0.25s ease-out;
  box-shadow: 0 -4px 24px rgba(0,0,0,.1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle { width: 36px; height: 4px; background: var(--border-strong); border-radius: 2px; margin: 0 auto 16px; }
.modal-title {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 20px;
  font-weight: 400;
  margin-bottom: 20px;
  color: var(--petrol);
}

/* Empty / loading */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state p { font-size: 14px; line-height: 1.5; }
.loading { display: flex; align-items: center; justify-content: center; padding: 48px; color: var(--text-muted); font-size: 14px; }

/* Toast */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--petrol);
  color: var(--gold);
  padding: 10px 24px;
  border: 1px solid rgba(181,154,85,.28);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  animation: fadeInOut 2s ease-in-out;
  pointer-events: none;
  box-shadow: var(--shadow);
}
@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* Filter bar */
.filter-bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 16px; scrollbar-width: none; }
.filter-bar::-webkit-scrollbar { display: none; }

/* Big action */
.big-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px;
  background: var(--petrol);
  color: var(--gold);
  border: 1px solid rgba(181,154,85,.28);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 24px;
  transition: background 0.2s;
  box-shadow: var(--shadow);
  letter-spacing: 0.3px;
}
.big-action:active { background: #1a3a4d; }
.big-action svg { width: 18px; height: 18px; }

/* Bloco label */
.bloco-label {
  font-size: 10px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 20px 0 10px;
  font-weight: 700;
}

/* Delete */
.delete-confirm { display: flex; gap: 8px; margin-top: 12px; }
