/* ============================================================
   Scriptorium — Estilos Principais
   Paleta: Azul-marinho + Dourado + Branco (estética católica)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,600;1,400&family=Inter:wght@400;500;600&display=swap');

:root {
  --navy:      #1a1a2e;
  --navy-mid:  #16213e;
  --navy-light:#0f3460;
  --gold:      #c9a227;
  --gold-light:#e8c547;
  --cream:     #faf8f0;
  --white:     #ffffff;
  --gray-100:  #f5f5f5;
  --gray-200:  #e8e8e8;
  --gray-500:  #9e9e9e;
  --gray-700:  #555;
  --success:   #2e7d32;
  --error:     #c62828;
  --warning:   #f57c00;
  --sidebar-w: 240px;
  --radius:    8px;
  --shadow:    0 2px 12px rgba(0,0,0,.10);
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--gray-100);
  color: #333;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: var(--white);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-logo {
  padding: 24px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-logo h1 {
  font-family: 'EB Garamond', serif;
  font-size: 1.5rem;
  color: var(--gold);
  letter-spacing: 1px;
}

.sidebar-logo small {
  font-size: .7rem;
  color: rgba(255,255,255,.45);
  display: block;
  margin-top: 2px;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: .72rem;
  color: rgba(255,255,255,.5);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gray-500);
  flex-shrink: 0;
}

.status-dot.online { background: #4caf50; }
.status-dot.offline { background: var(--error); }

nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: .875rem;
  transition: all .15s;
  border-left: 3px solid transparent;
}

nav a:hover { background: rgba(255,255,255,.07); color: var(--white); }
nav a.active {
  background: rgba(201,162,39,.12);
  color: var(--gold);
  border-left-color: var(--gold);
}

nav a svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: .7rem;
  color: rgba(255,255,255,.3);
}

/* ─── Main ─────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.topbar h2 {
  font-family: 'EB Garamond', serif;
  font-size: 1.25rem;
  color: var(--navy);
}

.topbar-actions { display: flex; gap: 10px; align-items: center; }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

/* ─── Cards / Sections ─────────────────────────────────────── */
.section { display: none; }
.section.active { display: block; }

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-title {
  font-family: 'EB Garamond', serif;
  font-size: 1.1rem;
  color: var(--navy);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-200);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  text-align: center;
  border-top: 3px solid var(--gold);
}

.stat-card .stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: .75rem;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ─── Formulários ───────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: inherit;
  transition: border-color .15s;
  background: var(--white);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
}

textarea { resize: vertical; min-height: 100px; }

/* ─── Botões ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--gold);
  color: var(--navy);
}
.btn-primary:hover { background: var(--gold-light); }

.btn-secondary {
  background: var(--navy);
  color: var(--white);
}
.btn-secondary:hover { background: var(--navy-light); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--gold);
  color: var(--gold);
}
.btn-outline:hover { background: rgba(201,162,39,.1); }

.btn-danger {
  background: var(--error);
  color: var(--white);
}

.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ─── Progress ───────────────────────────────────────────────── */
.progress-wrap {
  background: var(--gray-200);
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--navy-light), var(--gold));
  border-radius: 20px;
  transition: width .4s;
  width: 0%;
}

.step-indicator {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.step {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: .75rem;
  background: var(--gray-200);
  color: var(--gray-500);
}

.step.active { background: var(--navy); color: var(--white); }
.step.done { background: var(--success); color: var(--white); }

/* ─── Tabela ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

th {
  background: var(--navy);
  color: var(--white);
  padding: 10px 14px;
  text-align: left;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .5px;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}

tr:hover td { background: var(--cream); }

/* ─── Badge ───────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
}

.badge-created   { background: #e8f5e9; color: var(--success); }
.badge-skipped   { background: #fff3e0; color: var(--warning); }
.badge-error     { background: #ffebee; color: var(--error); }
.badge-active    { background: #e3f2fd; color: #1565c0; }
.badge-inactive  { background: var(--gray-200); color: var(--gray-500); }

/* ─── Preview de Nota ────────────────────────────────────────── */
.note-preview {
  background: var(--cream);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 18px;
  font-family: 'EB Garamond', serif;
  font-size: .95rem;
  line-height: 1.7;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ─── Activity Feed ──────────────────────────────────────────── */
.activity-list { list-style: none; }

.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-200);
  font-size: .875rem;
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(201,162,39,.15);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold);
  flex-shrink: 0;
  font-size: .9rem;
}

.activity-text { flex: 1; }
.activity-text strong { display: block; color: var(--navy); }
.activity-text small { color: var(--gray-500); }

/* ─── Upload Dropzone ────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  color: var(--gray-500);
}

.dropzone:hover, .dropzone.drag-over {
  border-color: var(--gold);
  background: rgba(201,162,39,.05);
  color: var(--navy);
}

.dropzone svg { margin-bottom: 10px; opacity: .5; }
.dropzone p { font-size: .9rem; }
.dropzone small { font-size: .75rem; }

/* ─── Alert ───────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success { background: #e8f5e9; color: var(--success); border-left: 4px solid var(--success); }
.alert-error   { background: #ffebee; color: var(--error);   border-left: 4px solid var(--error); }
.alert-info    { background: #e3f2fd; color: #1565c0;        border-left: 4px solid #1565c0; }
.alert-warning { background: #fff3e0; color: var(--warning); border-left: 4px solid var(--warning); }

/* ─── Toggle ────────────────────────────────────────────────── */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.toggle {
  width: 40px; height: 22px;
  background: var(--gray-200);
  border-radius: 20px;
  position: relative;
  transition: background .2s;
}

.toggle.on { background: var(--gold); }

.toggle::after {
  content: '';
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 3px; left: 3px;
  transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.toggle.on::after { left: 21px; }

/* ─── Loader ─────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--gray-200);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsivo ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 60px; }
  .sidebar-logo h1, .sidebar-logo small, nav a span, .sidebar-footer { display: none; }
  nav a { justify-content: center; }
}

/* ─── Modal Navegador de Canal ───────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%;
  max-width: 820px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}
.modal-header h3 {
  font-family: 'EB Garamond', serif;
  font-size: 1.2rem;
  color: var(--navy);
  margin: 0;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--gray-500);
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background .15s;
}
.modal-close:hover { background: var(--gray-100); color: var(--navy); }

.modal-body {
  overflow-y: auto;
  padding: 18px 22px;
  flex: 1;
}

/* Grade de vídeos */
.cb-videos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.cb-video-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.cb-video-card:hover {
  border-color: var(--gold);
  box-shadow: 0 4px 14px rgba(0,0,0,.1);
  transform: translateY(-2px);
}

.cb-thumb-wrap {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--gray-100);
  overflow: hidden;
}
.cb-thumb-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.cb-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.0);
  color: white;
  font-size: 2rem;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.cb-video-card:hover .cb-play-overlay {
  opacity: 1;
  background: rgba(0,0,0,.35);
}

.cb-video-info {
  padding: 10px 12px;
}
.cb-video-title {
  font-size: .82rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cb-video-date {
  font-size: .75rem;
  color: var(--gray-500);
  margin-top: 4px;
}

#cb-loading {
  text-align: center;
  padding: 32px 0;
  color: var(--gray-500);
}
#cb-error {
  color: var(--error);
  padding: 12px;
  background: #fff0f0;
  border-radius: var(--radius);
  font-size: .875rem;
}

/* ─── Calendário Visual Mensal ───────────────────────────────── */
.cal-grid-wrap {
  margin-top: 10px;
  overflow-x: auto;
}

.cal-header-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 4px;
}
.cal-header-row div {
  text-align: center;
  font-size: .72rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 4px 0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cal-cell {
  min-height: 68px;
  border-radius: 6px;
  border: 2px solid transparent;
  padding: 5px 6px 4px;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cal-cell:hover { transform: scale(1.04); box-shadow: 0 3px 10px rgba(0,0,0,.12); z-index: 2; }
.cal-cell-empty { background: transparent \!important; cursor: default; }
.cal-cell-empty:hover { transform: none; box-shadow: none; }

.cal-today { box-shadow: 0 0 0 2px currentColor; }
.cal-solene { font-weight: 700; }
.cal-cell.selected { box-shadow: 0 0 0 3px var(--navy) \!important; }

.cal-day-num {
  font-size: .82rem;
  font-weight: 700;
  line-height: 1;
}
.cal-cele {
  font-size: .63rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}
.cal-cor-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  align-self: flex-end;
  margin-top: auto;
}

/* ─── Liturgia das Horas ─────────────────────────────────────── */
.horas-section {
  padding: 12px 16px;
  margin-bottom: 6px;
  border-radius: var(--radius);
  background: var(--gray-100);
}
.horas-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-500);
  margin-bottom: 6px;
}
.horas-text {
  font-family: 'EB Garamond', serif;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--navy);
}

/* ─── Novenas ────────────────────────────────────────────────── */
.novena-card {
  background: var(--cream);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid var(--gray-200);
}
.novena-nome {
  font-weight: 700;
  font-family: 'EB Garamond', serif;
  font-size: 1.05rem;
  color: var(--navy);
}
.novena-meta {
  font-size: .78rem;
  color: var(--gray-500);
  margin-top: 2px;
}
.novena-intencao {
  font-size: .82rem;
  font-style: italic;
  color: var(--gray-600, #555);
  margin-top: 4px;
}
.novena-progress {
  display: flex;
  gap: 4px;
  align-items: center;
}
.novena-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--gray-200);
  border: 1.5px solid var(--gray-300);
  transition: background .2s;
}
.novena-dot.done {
  background: var(--gold);
  border-color: var(--gold);
}

.novena-cat-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.novena-cat-card:hover {
  border-color: var(--gold);
  box-shadow: 0 3px 10px rgba(0,0,0,.08);
  transform: translateY(-2px);
}
.novena-cat-nome {
  font-weight: 700;
  font-family: 'EB Garamond', serif;
  color: var(--navy);
  font-size: 1rem;
  margin-bottom: 4px;
}
.novena-cat-patrono {
  font-size: .8rem;
  color: var(--gray-500);
}
.novena-cat-festa {
  font-size: .75rem;
  color: var(--gold);
  margin-top: 4px;
  font-weight: 600;
}

/* ─── Galeria de Imagens ─────────────────────────────────────── */
.img-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.img-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.img-card:hover {
  border-color: var(--gold);
  box-shadow: 0 4px 14px rgba(0,0,0,.1);
  transform: translateY(-2px);
}

.img-thumb-wrap {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
}
.img-thumb-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.img-no-thumb {
  font-size: 2.5rem;
  color: var(--gray-300);
}

.img-card-info {
  padding: 8px 10px;
}
.img-card-title {
  font-size: .78rem;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.img-card-cat {
  font-size: .7rem;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ── Painel de leituras do calendário ─────────────────────────────────────── */
.readings-panel {
  margin-top: 12px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
  background: var(--white);
}
.reading-row {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-100);
}
.reading-row:last-child { border-bottom: none; }
.reading-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.reading-ref {
  font-size: .85rem;
  font-weight: 600;
  color: var(--navy);
  padding-left: 8px;
  font-family: 'EB Garamond', serif;
}
.reading-links {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.reading-link {
  font-size: .7rem;
  color: var(--gold);
  text-decoration: none;
  border: 1px solid var(--gold);
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.reading-link:hover {
  background: var(--gold);
  color: var(--white);
}

/* ── Texto bíblico expansível ─────────────────────────────────────────────── */
.reading-text-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 102px;
  font-size: .72rem;
  color: var(--gold);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--gray-100);
  transition: background .12s;
}
.reading-text-toggle:hover { background: var(--gray-50); }
.reading-text-icon {
  display: inline-block;
  font-size: .6rem;
  transition: transform .2s;
}
.reading-text-body {
  display: none;
  padding: 8px 12px 10px 102px;
  border-bottom: 1px solid var(--gray-100);
  background: var(--gray-50);
}
.reading-text-body.open { display: block; }
.reading-text-toggle.active .reading-text-icon { transform: rotate(90deg); }
.reading-quote {
  margin: 0 0 4px 0;
  padding: 0 0 0 10px;
  border-left: 3px solid var(--gold);
  font-family: 'EB Garamond', serif;
  font-size: .9rem;
  line-height: 1.6;
  color: var(--navy);
  font-style: italic;
}
.reading-versao {
  font-size: .68rem;
  color: var(--gray-400);
  font-style: normal;
}
