@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600&family=Geist+Mono:wght@400;500&display=swap');

:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --text: #1c1917;
  --text-2: #57534e;
  --text-3: #a8a29e;
  --accent: #44403c;
  --accent-bg: #f5f5f4;
  --accent-border: #d6d3d1;
  --danger: #dc2626;
  --success-bg: #f0fdf4;
  --success-text: #15803d;
  --error-bg: #fef2f2;
  --error-text: #dc2626;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] {
  --bg: #0c0a09;
  --surface: #1c1917;
  --surface-2: #231f1d;
  --border: #2d2926;
  --border-strong: #44403c;
  --text: #fafaf9;
  --text-2: #a8a29e;
  --text-3: #57534e;
  --accent: #a8a29e;
  --accent-bg: #2d2926;
  --accent-border: #44403c;
  --danger: #ef4444;
  --success-bg: #052e16;
  --success-text: #4ade80;
  --error-bg: #2d0a0a;
  --error-text: #f87171;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: 'Geist', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

/* THEME TOGGLE */
.btn-theme {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  border-radius: var(--radius-sm);
  width: 34px;
  height: 34px;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-theme:hover {
  background: var(--bg);
  border-color: var(--text-3);
  color: var(--text);
}

/* STATUS BAR */
#status-bar {
  text-align: center;
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg);
  color: var(--text-3);
  letter-spacing: 0.01em;
  border-bottom: 1px solid var(--border);
}

#status-bar.ok {
  background: var(--success-bg);
  color: var(--success-text);
}

#status-bar.err {
  background: var(--error-bg);
  color: var(--error-text);
}

/* HEADER */
header {
  background: var(--surface);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-icon img {
  width: 48px;
  height: 48px;
  object-fit: cover;
}

.brand-text h1 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand-text p {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 1px;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-outline:hover {
  background: var(--bg);
  border-color: var(--text-3);
  color: var(--text);
}

/* LAYOUT */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

/* CALENDAR CARD */
.calendar-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.cal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cal-nav button {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-2);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  line-height: 1;
}

.cal-nav button:hover {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.cal-month {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  min-width: 160px;
  text-align: center;
  letter-spacing: -0.02em;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  width: 100%;
}

.cal-dow {
  padding: 10px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.cal-day {
  min-height: 86px;
  padding: 8px 7px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
  overflow: hidden;
  min-width: 0;
  position: relative;
}

.cal-day:nth-child(7n) {
  border-right: none;
}

.cal-day:hover {
  background: var(--surface-2);
}

.cal-day.empty {
  background: var(--surface-2);
  cursor: default;
  opacity: 0.5;
}

.cal-day.today {
  background: var(--surface-2);
}

.cal-day.selected {
  background: var(--accent-bg);
  outline: 2px solid var(--border-strong);
  outline-offset: -2px;
  z-index: 1;
}

.cal-day.sunday .day-num {
  color: var(--text-2);
}

.day-num {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  margin-bottom: 5px;
  font-family: 'Geist Mono', monospace;
}

.cal-day.today .day-num {
  color: var(--text);
  font-weight: 700;
}

.cal-day.selected .day-num {
  color: var(--text);
  font-weight: 700;
}

.day-dots {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.day-dot {
  font-size: 10px;
  background: var(--bg);
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  display: block;
  line-height: 1.5;
}

.day-dot.minister {
  background: var(--surface-2);
  color: var(--text-3);
  border-color: var(--border);
}

/* SIDE PANEL */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
}

.panel-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.date-label {
  font-size: 11px;
  color: var(--text-2);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
}

.panel-body {
  padding: 16px 18px;
}

.no-selection {
  text-align: center;
  padding: 32px 16px;
}

.no-selection .icon {
  font-size: 28px;
  margin-bottom: 10px;
  opacity: 0.4;
}

.no-selection p {
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.6;
  max-width: 200px;
  margin: 0 auto;
}

/* SECTION LABELS */
.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 8px;
}

/* LISTS */
.section-list {
  list-style: none;
  margin-bottom: 10px;
}

.section-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  gap: 6px;
}

.section-list li .item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-list li .item-sub {
  font-size: 11px;
  color: var(--text-3);
  flex-shrink: 0;
}

.item-del {
  background: none;
  border: none;
  color: var(--border-strong);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s;
  flex-shrink: 0;
}

.item-del:hover {
  color: var(--danger);
}

.yt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ef4444;
  color: white;
  border-radius: 4px;
  font-size: 10px;
  padding: 2px 7px;
  text-decoration: none;
  margin-right: 4px;
  transition: background 0.15s;
  flex-shrink: 0;
  font-weight: 600;
}

.yt-btn:hover {
  background: #dc2626;
}

.empty-list {
  color: var(--text-3);
  font-size: 12px;
  padding: 12px 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}

/* ADD ROW */
.add-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.add-row input,
.add-row select {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.add-row input:focus,
.add-row select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.add-row input::placeholder {
  color: var(--text-3);
}

.add-row button {
  background: var(--accent);
  border: none;
  color: white;
  border-radius: var(--radius-sm);
  width: 34px;
  height: 34px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  line-height: 1;
}

.add-row button:hover {
  background: var(--text-2);
}

/* NOTES */
.notes-area {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  resize: vertical;
  min-height: 80px;
  outline: none;
  margin-bottom: 8px;
  transition: border-color 0.15s;
  line-height: 1.6;
}

.notes-area:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.notes-area::placeholder {
  color: var(--text-3);
}

.btn-save {
  background: var(--border-strong);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
  letter-spacing: -0.01em;
}

.btn-save:hover {
  background: var(--text-2);
  color: var(--surface);
}

/* DIVIDER */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* TEAM GRID */
.team-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 14px 18px;
}

.member-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.member-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-2);
  flex-shrink: 0;
  font-family: 'Geist Mono', monospace;
}

.member-info .name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.member-info .instr {
  font-size: 11px;
  color: var(--text-3);
}

.no-members {
  padding: 16px 18px;
  color: var(--text-3);
  font-size: 13px;
}

/* MODAL */
#members-modal,
#login-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.4);
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  cursor: pointer;
  /* indica que se puede cerrar al hacer clic fuera */
}

#members-modal.open,
#login-modal.open {
  display: flex;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  max-width: 460px;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  cursor: default;
  /* evita que el clic dentro cierre el modal */
}

.modal-box h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.modal-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.modal-member-row .name {
  font-size: 13px;
  font-weight: 500;
}

.modal-member-row .instr {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 1px;
}

.btn-close-modal {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  transition: all 0.15s;
}

.btn-close-modal:hover {
  background: var(--border);
  color: var(--text);
}

/* TOAST */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: white;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.2s;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ─── RESPONSIVE MOBILE ─── */
@media (max-width: 960px) {
  .main {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 12px;
  }

  .side-panel {
    /* On mobile, show panel below calendar naturally */
  }
}

@media (max-width: 640px) {
  header {
    padding: 0 16px;
    height: 54px;
  }

  .brand-text p {
    display: none;
  }

  .main {
    padding: 10px;
    gap: 10px;
  }

  /* Calendar */
  .cal-header {
    padding: 12px 14px;
  }

  .cal-month {
    font-size: 14px;
    min-width: 130px;
  }

  .cal-day {
    min-height: 64px;
    padding: 5px 4px;
  }

  .day-num {
    font-size: 11px;
    margin-bottom: 3px;
  }

  .day-dot {
    font-size: 9px;
    padding: 1px 3px;
  }

  .cal-dow {
    font-size: 10px;
    padding: 8px 2px;
  }

  /* Panel */
  .panel-body {
    padding: 12px 14px;
  }

  .panel-header {
    padding: 12px 14px;
  }

  /* Add row — stack URL input below on mobile */
  .add-row {
    flex-wrap: wrap;
  }

  .add-row #new-song-url {
    flex: 0 0 calc(100% - 40px);
    order: 3;
  }

  .add-row #new-song {
    flex: 1;
    min-width: 120px;
  }

  .add-row button {
    order: 2;
  }

  /* Minister select takes full row */
  .add-row select {
    flex: 1;
    min-width: 0;
  }

  /* Team grid single column on very small screens */
  .team-grid {
    grid-template-columns: 1fr;
  }

  .modal-box {
    padding: 18px;
  }

  #toast {
    bottom: 16px;
    right: 16px;
    left: 16px;
    text-align: center;
  }
}

/* CONFIRM MODAL */
#confirm-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(0, 0, 0, 0.4);
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

#confirm-modal.open {
  display: flex;
}

.confirm-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  max-width: 340px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.confirm-box p {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 18px;
}

.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-cancel-confirm {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-cancel-confirm:hover {
  background: var(--border);
  color: var(--text);
}

.btn-ok-confirm {
  background: var(--danger);
  border: 1px solid var(--danger);
  color: white;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-ok-confirm:hover {
  background: #b91c1c;
}