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

:root {
  --app-background: url("assets/fondo-iglesia.png");
}

html,
body {
  min-height: 100%;
}

body {
  font-family: Arial, sans-serif;
  color: #1f2937;
  padding-bottom: 82px;

  background-image:
    linear-gradient(
      rgba(3, 15, 35, 0.50),
      rgba(3, 15, 35, 0.72)
    ),
    var(--app-background);

  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.hidden {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}


/* =========================
   CABECERA
========================= */

.topbar {
  background: rgba(255, 255, 255, 0.96);
  padding: 20px 28px;

  display: flex;
  justify-content: space-between;
  align-items: center;

  gap: 18px;

  border-bottom: 1px solid #e5e7eb;

  backdrop-filter: blur(8px);
}

.topbar h1 {
  font-size: 24px;
  margin-bottom: 4px;
}

.topbar p {
  color: #6b7280;
  font-size: 14px;
}

.topbar button {
  border: none;

  background: #111827;
  color: white;

  padding: 10px 14px;

  border-radius: 10px;
}


/* =========================
   CONTENIDO
========================= */

#appMain,
#personasSection,
#alabanzaSection,
#sonidoSection,
#proyeccionSection,
#diaconiaSection,
#avisosSection,
#configuracionSection,
#adminSection {
  width: min(1100px, calc(100% - 32px));
  margin: 30px auto 110px;
}

/* =========================
   ESCALA
========================= */

.month-control {
  display: flex;
  align-items: center;
  justify-content: space-between;

  background:
    rgba(255, 255, 255, 0.96);

  padding: 18px;

  border-radius: 16px;

  margin-bottom: 18px;
}

.month-control button {
  width: 44px;
  height: 44px;

  border: none;

  border-radius: 12px;

  background: #e5e7eb;

  font-size: 24px;
}

.month-control div {
  text-align: center;
}

.small-text {
  display: block;

  font-size: 12px;

  color: #6b7280;

  margin-bottom: 4px;
}

.month-control h2 {
  font-size: 24px;
}

.actions {
  display: flex;

  gap: 12px;

  margin-bottom: 18px;

  flex-wrap: wrap;
}

.actions button {
  border: none;

  padding: 14px 18px;

  border-radius: 12px;

  font-size: 15px;
}

.actions .primary {
  background: #2563eb;
  color: white;
}

#editSchedule {
  background: white;

  border:
    1px
    solid
    #d1d5db;
}

.info-box {
  background:
    rgba(255, 255, 255, 0.96);

  padding: 18px;

  border-radius: 16px;

  margin-bottom: 20px;
}

.info-box h3 {
  margin-bottom: 12px;
}

.info-box ul {
  padding-left: 20px;

  color: #4b5563;
}

.info-box li {
  margin-bottom: 8px;
}

.schedule {
  display: grid;

  grid-template-columns:
    repeat(2, 1fr);

  gap: 16px;
}

.sunday-card {
  background:
    rgba(255, 255, 255, 0.97);

  border-radius: 18px;

  padding: 18px;

  display: flex;

  gap: 18px;

  border:
    1px
    solid
    #e5e7eb;
}

.date {
  width: 96px;
  min-width: 96px;
  height: 96px;

  border-radius: 16px;

  background: #111827;
  color: white;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  text-align: center;
  padding: 8px;
}

.date span {
  font-size: 8px;
  letter-spacing: 0.6px;
  line-height: 1;
  white-space: nowrap;
}

.date strong {
  font-size: 30px;
  margin-top: 6px;
  line-height: 1;
}

.areas {
  flex: 1;
}

.area {
  padding: 10px 0;

  border-bottom:
    1px
    solid
    #e5e7eb;
}

.area:last-child {
  border-bottom: none;
}

.area h3 {
  font-size: 16px;

  margin-bottom: 3px;
}

.area p {
  color: #6b7280;

  font-size: 14px;
}


/* =========================
   CABECERAS DE SECCIONES
========================= */

.section-header {
  background:
    rgba(255, 255, 255, 0.96);

  border-radius: 18px;

  padding: 18px 22px;

  margin-bottom: 18px;

  display: flex;

  justify-content: space-between;

  align-items: center;

  gap: 16px;

  flex-wrap: wrap;
}

.section-header h2 {
  font-size: 28px;
}

.section-header .primary {
  margin-left: auto;
  flex-shrink: 0;
  border: none;

  background: #2563eb;

  color: white;

  padding: 12px 16px;

  border-radius: 12px;

  font-size: 15px;
}


/* =========================
   TARJETAS
========================= */

.settings-card {
  background:
    rgba(255, 255, 255, 0.97);

  border:
    1px
    solid
    #e5e7eb;

  border-radius: 16px;

  padding: 20px;
}

.settings-card + .settings-card {
  margin-top: 16px;
}

.settings-card h3 {
  margin-bottom: 12px;
}


/* =========================
   PERSONAS
========================= */

.roles-info {
  display: grid;

  grid-template-columns:
    repeat(2, 1fr);

  gap: 14px;

  margin-bottom: 20px;
}

.role-card {
  background:
    rgba(255, 255, 255, 0.97);

  border:
    1px
    solid
    #e5e7eb;

  border-radius: 16px;

  padding: 16px;
}

.role-card strong {
  display: block;

  margin-bottom: 6px;

  font-size: 16px;
}

.role-card p {
  color: #6b7280;

  font-size: 14px;
}

.people-list {
  display: flex;

  flex-direction: column;

  gap: 12px;
}

.person-card {
  background:
    rgba(255, 255, 255, 0.98);

  border:
    1px
    solid
    #e5e7eb;

  border-radius: 16px;

  padding: 16px;

  display: flex;

  align-items: center;

  gap: 16px;
}

.avatar {
  width: 56px;

  height: 56px;

  min-width: 56px;

  border-radius: 50%;

  background: #111827;

  color: white;

  display: flex;

  align-items: center;

  justify-content: center;

  font-weight: bold;

  font-size: 18px;
}

.person-info {
  flex: 1;
}

.person-info h3 {
  margin-bottom: 4px;

  font-size: 17px;
}

.person-info p {
  color: #6b7280;

  font-size: 14px;

  margin-bottom: 8px;
}

.person-tags {
  display: flex;

  flex-wrap: wrap;

  gap: 6px;
}

.person-tags span {
  background: #eef2ff;

  color: #3730a3;

  padding: 5px 9px;

  border-radius: 999px;

  font-size: 12px;
}

.person-edit {
  border:
    1px
    solid
    #d1d5db;

  background: white;

  padding: 9px 12px;

  border-radius: 10px;
}


/* =========================
   ALABANZA
========================= */

.worship-summary {
  display: grid;

  grid-template-columns:
    repeat(3, 1fr);

  gap: 14px;

  margin: 18px 0 22px;
}

.worship-summary > div {
  background: #f5f7fb;

  border:
    1px
    solid
    #e5e7eb;

  border-radius: 14px;

  padding: 14px;

  text-align: center;
}

.worship-summary strong {
  font-size: 24px;

  color: #111827;
}

.worship-member-card {
  display: flex;

  justify-content: space-between;

  align-items: center;

  gap: 20px;

  padding: 16px;

  margin-top: 14px;

  background: #f8fafc;

  border:
    1px
    solid
    #e5e7eb;

  border-radius: 14px;
}

.worship-member-card h4 {
  margin-bottom: 4px;

  font-size: 18px;

  color: #111827;
}

.worship-member-card p {
  margin-bottom: 8px;

  color: #64748b;
}

.member-tags {
  display: flex;

  gap: 8px;

  flex-wrap: wrap;
}

.member-tags span {
  background: #e8eefc;

  color: #1e40af;

  padding: 5px 10px;

  border-radius: 999px;

  font-size: 13px;
}

.worship-member-card button {
  background: white;

  color: #dc2626;

  border:
    1px
    solid
    #fecaca;

  border-radius: 9px;

  padding: 8px 12px;
}


/* =========================
   CONFIGURACIÓN
========================= */

#configuracionSection {
  max-width: 900px;
}

#backgroundInput,
#logoInput {
  display: block;

  margin: 14px 0;
}

#resetBackground,
#resetLogo {
  background: #111827;

  color: white;

  border: none;

  border-radius: 10px;

  padding: 11px 16px;
}


/* =========================
   MODALES
========================= */

.modal {
  position: fixed;

  inset: 0;

  background:
    rgba(17, 24, 39, 0.55);

  display: flex;

  align-items: center;

  justify-content: center;

  padding: 20px;

  z-index: 1000;
}

.modal-content {
  width:
    min(
      560px,
      calc(100% - 20px)
    );

  background: white;

  border-radius: 18px;

  padding: 24px;

  max-height: 90vh;

  overflow-y: auto;
}

.modal-header {
  display: flex;

  align-items: center;

  justify-content: space-between;

  gap: 12px;

  margin-bottom: 20px;
}

.modal-header button,
.modal-close {
  border: none;

  background: transparent;

  font-size: 22px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;

  font-weight: 600;

  margin-bottom: 7px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="file"],
.form-group select {
  width: 100%;

  padding: 12px 14px;

  border:
    1px
    solid
    #d1d5db;

  border-radius: 10px;

  background: white;
}

.checkbox-list {
  display: grid;

  grid-template-columns:
    repeat(2, 1fr);

  gap: 10px;
}

.checkbox-list label {
  display: flex;

  align-items: center;

  gap: 8px;

  background: #f9fafb;

  border:
    1px
    solid
    #e5e7eb;

  border-radius: 10px;

  padding: 10px;
}

.modal-actions {
  display: flex;

  justify-content: flex-end;

  gap: 10px;

  margin-top: 22px;
}

.primary-btn,
.secondary-btn {
  border: none;

  padding: 12px 16px;

  border-radius: 10px;
}

.primary-btn {
  background: #2563eb;

  color: white;
}

.secondary-btn {
  background: #e5e7eb;

  color: #111827;
}


/* =========================
   MODAL ALABANZA
========================= */

#worshipMemberForm {
  display: flex;

  flex-direction: column;

  gap: 14px;
}

#worshipMemberForm label {
  font-weight: 600;

  color: #1f2937;
}

#worshipMemberForm input[type="text"],
#worshipMemberForm select {
  width: 100%;

  padding: 12px;

  border:
    1px
    solid
    #d1d5db;

  border-radius: 10px;
}

#worshipMemberForm .checkbox-row {
  display: flex;

  align-items: center;

  gap: 8px;
}

#worshipMemberForm button[type="submit"] {
  margin-top: 10px;

  width: 100%;

  padding: 13px;

  border: none;

  border-radius: 10px;

  background: #2563eb;

  color: white;

  font-weight: 600;
}


/* =========================
   LOGIN
========================= */

.auth-section {
  min-height: 100vh;

  display: flex;

  align-items: center;

  justify-content: center;

  padding: 30px 20px;
}

.auth-card {
  width: 100%;

  max-width: 440px;

  background: white;

  border:
    1px
    solid
    #e5e7eb;

  border-radius: 20px;

  padding: 28px;
}

.developer-brand {
  width: 100%;

  margin-bottom: 18px;

  text-align: center;
}

.developer-brand img {
  width: 100%;

  max-width: 180px;

  height: auto;

  border-radius: 14px;

  display: block;

  margin: 0 auto;
}

.auth-card h1 {
  text-align: center;

  font-size: 30px;

  margin-bottom: 6px;
}

.auth-subtitle {
  text-align: center;

  color: #6b7280;

  margin-bottom: 24px;
}

.auth-tabs {
  display: grid;

  grid-template-columns:
    1fr 1fr;

  gap: 8px;

  margin-bottom: 22px;
}

.auth-tabs button {
  border:
    1px
    solid
    #d1d5db;

  background: white;

  padding: 12px;

  border-radius: 10px;
}

.auth-tabs button.active {
  background: #111827;

  color: white;

  border-color: #111827;
}

.auth-form {
  display: flex;

  flex-direction: column;

  gap: 4px;
}

.auth-submit {
  width: 100%;

  margin-top: 8px;
}

.auth-link {
  border: 0;
  background: transparent;
  color: #1d4ed8;
  padding: 12px 8px;
  text-align: center;
  text-decoration: underline;
}
.auth-link:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; border-radius: 8px; }
.recovery-help { color: #64748b; font-size: 14px; line-height: 1.5; margin: 8px 0 16px; }

.register-note {
  margin-top: 12px;

  font-size: 13px;

  color: #6b7280;

  text-align: center;

  line-height: 1.4;
}

.auth-message {
  margin-top: 16px;

  text-align: center;

  font-size: 14px;

  min-height: 20px;
}

.auth-message.success {
  color: #15803d;
}

.auth-message.error {
  color: #b91c1c;
}


/* =========================
   MENÚ INFERIOR
========================= */

.bottom-nav {
  position: fixed;

  bottom: 0;

  left: 0;

  right: 0;

  background:
    rgba(255, 255, 255, 0.97);

  border-top:
    1px
    solid
    #e5e7eb;

  padding: 10px;

  display: flex;

  justify-content: center;

  gap: 8px;

  z-index: 900;

  backdrop-filter: blur(8px);
}

.bottom-nav button {
  border: none;

  background: transparent;

  padding: 10px 14px;

  border-radius: 10px;

  color: #4b5563;
}

.bottom-nav button.active {
  background: #111827;

  color: white;
}


/* =========================
   MÓVIL
========================= */

@media (max-width: 800px) {

  .schedule {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;

    gap: 14px;

    flex-wrap: wrap;
  }

  .sunday-card {
    flex-direction: column;
  }

  .date {
    width: 100%;

    height: 72px;

    flex-direction: row;

    gap: 10px;
  }

  .roles-info {
    grid-template-columns: 1fr;
  }

  .worship-summary {
    grid-template-columns: 1fr;
  }

  .bottom-nav {
    justify-content: flex-start;

    overflow-x: auto;
  }
}


@media (max-width: 600px) {

  .checkbox-list {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .primary-btn,
  .secondary-btn {
    width: 100%;
  }

  .person-card {
    align-items: flex-start;
  }

}

/* =========================
   AVISOS / CHAT
========================= */

#avisosSection {
  width: min(1100px, calc(100% - 32px));
  margin: 30px auto 110px;
}

.chat-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  margin-top: 18px;
}

.chat-sidebar,
.chat-main {
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  padding: 18px;
  min-height: 470px;
}

.chat-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.chat-sidebar-header h3 {
  margin-bottom: 5px;
  color: #111827;
}

.chat-sidebar-header p {
  color: #6b7280;
  font-size: 14px;
}

.notice-badge {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: #dc2626;
  color: white;

  border-radius: 999px;
  font-weight: bold;
  font-size: 13px;
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.conversation-item {
  width: 100%;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  border-radius: 14px;
  padding: 14px;
  text-align: left;
  color: #111827;
}

.conversation-item:hover {
  background: #eef2ff;
}

.conversation-item.active {
  border-color: #2563eb;
  background: #eff6ff;
}

.conversation-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
}

.conversation-person {
  display: block;
  color: #6b7280;
  font-size: 12px;
  margin-bottom: 7px;
}

.conversation-item p {
  color: #475569;
  font-size: 13px;
  line-height: 1.4;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-dot {
  width: 10px;
  height: 10px;
  min-width: 10px;
  border-radius: 50%;
  background: #dc2626;
}

.chat-empty-state {
  min-height: 420px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  text-align: center;
  color: #64748b;
}

.chat-empty-state h3 {
  color: #111827;
  margin-bottom: 8px;
}

.chat-conversation-header {
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.chat-conversation-header h3 {
  color: #111827;
  margin-bottom: 4px;
}

#chatConversationArea {
  color: #6b7280;
  font-size: 14px;
}

.chat-messages {
  height: 320px;
  overflow-y: auto;

  padding: 10px 4px;

  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-message {
  max-width: 78%;
}

.chat-message-author {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 4px;
}

.chat-bubble {
  background: #e8eefc;
  color: #111827;

  padding: 11px 14px;

  border-radius: 16px 16px 16px 4px;

  line-height: 1.45;
}

.chat-message-time {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: #94a3b8;
}

.chat-reply-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;

  margin-top: 14px;
  padding-top: 14px;

  border-top: 1px solid #e5e7eb;
}

.chat-reply-form textarea {
  flex: 1;
  resize: none;

  padding: 12px;

  border: 1px solid #d1d5db;
  border-radius: 12px;

  font-family: inherit;
  font-size: 14px;
}

.chat-reply-form button {
  min-width: 90px;
}

#conversationForm textarea {
  width: 100%;
  padding: 12px 14px;

  border: 1px solid #d1d5db;
  border-radius: 10px;

  resize: vertical;
  font-family: inherit;
}

@media (max-width: 800px) {

  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-sidebar,
  .chat-main {
    min-height: auto;
  }

  .chat-messages {
    height: 300px;
  }

  .chat-reply-form {
    flex-direction: column;
  }

  .chat-reply-form button {
    width: 100%;
  }

}

#appLogo {
  position: fixed;
  bottom: 18px;
right: 22px;

  width: 120px;
  height: auto;

  opacity: 0.75;

  z-index: 1200;

  border-radius: 10px;

  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.35));

  pointer-events: none;
}

#appWatermarkLogo {
  position: fixed;
 bottom: 75px;
  right: 22px;

  width: 120px;
  height: auto;

  opacity: 0.75;

  z-index: 850;

  filter: drop-shadow(
    0 3px 8px rgba(0, 0, 0, 0.35)
  );

  pointer-events: none;
}
.data-status { width: min(1100px, calc(100% - 32px)); margin: 16px auto; padding: 16px; background: #fff7ed; border-radius: 12px; display: flex; align-items: center; gap: 16px; justify-content: space-between; }
.data-status button, .user-actions button, #refreshUsersBtn { padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 10px; background: white; }
.user-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.user-actions select { max-width: 100%; padding: 10px; border: 1px solid #d1d5db; border-radius: 10px; }
#usersList { margin-top: 18px; }
button:disabled { cursor: wait; opacity: .6; }
@media (max-width: 600px) { #usersList .person-card { flex-direction: column; align-items: stretch; } .data-status { flex-direction: column; align-items: stretch; } }

.empty-state { background: rgba(255,255,255,.96); padding: 18px; border-radius: 12px; color: #475569; }
.member-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.member-actions [data-edit-worship] { color: #1d4ed8; border-color: #bfdbfe; }
.account-card p { margin: 12px 0; overflow-wrap: anywhere; }
#adminSettings { margin-top: 16px; }
#manualAssignments fieldset { border: 1px solid #d1d5db; border-radius: 12px; padding: 14px; margin-bottom: 16px; }
#manualAssignments legend { padding: 0 6px; font-weight: bold; }
.chat-conversation-header { display: flex; flex-direction: row-reverse; justify-content: space-between; gap: 12px; align-items: center; }
.bottom-nav { overflow-x: auto; justify-content: safe center; }
.bottom-nav button { flex-shrink: 0; }
.install-dialog { margin: auto; width: min(440px, calc(100% - 24px)); padding: 24px; border: 0; border-radius: 18px; color: #1f2937; }
.install-dialog::backdrop { background: rgba(17,24,39,.6); }
.install-dialog p { margin: 16px 0; line-height: 1.6; }
.notification-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.notification-actions button { padding: 12px 16px; border: 1px solid #d1d5db; border-radius: 10px; }
.notification-actions .primary { background: #2563eb; color: white; border-color: #2563eb; }
.topbar { flex-wrap: wrap; gap: 12px; }
#notificationsBtn { background: #2563eb; color: white; }
.connection-status { position: fixed; top: 0; left: 0; right: 0; z-index: 1300; padding: 12px 16px; background: #fff7ed; color: #7c2d12; text-align: center; }

/* Pantallas pequeñas, teclado del móvil y zonas seguras del dispositivo. */
.chat-layout > *, .person-info, .areas, .topbar > div { min-width: 0; }
.chat-bubble, .person-info, .area p, #usersRefreshStatus { overflow-wrap: anywhere; }
.chat-bubble { white-space: pre-wrap; }
.month-control { gap: 12px; }
.month-control button { flex-shrink: 0; }
.bottom-nav { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
body { padding-bottom: calc(82px + env(safe-area-inset-bottom, 0px)); }
.modal { padding-top: max(12px, env(safe-area-inset-top, 0px)); padding-bottom: max(12px, env(safe-area-inset-bottom, 0px)); }
.modal-content { max-height: 90dvh; overscroll-behavior: contain; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 3px;
}

@media (max-width: 800px) {
  .bottom-nav { justify-content: flex-start; }
  .chat-reply-form textarea { width: 100%; min-height: 90px; }
  .chat-empty-state { min-height: 160px; }
  .chat-message { max-width: 95%; }
  .chat-conversation-header { flex-wrap: wrap; }
  #appWatermarkLogo { width: 72px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); opacity: .35; }
}

@media (max-width: 600px) {
  button, .checkbox-list label { min-height: 44px; }
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px; max-width: 100%; }
  .topbar { padding: 16px; }
  .topbar h1 { font-size: 22px; }
  .auth-section { min-height: 100dvh; padding: 20px 12px; }
  .auth-card { padding: 24px 18px; }
  .section-header { padding: 16px; gap: 12px; }
  .section-header h2 { font-size: 24px; }
  .section-header .primary { padding: 11px 12px; }
  .month-control { padding: 12px; }
  .month-control h2 { font-size: 18px; }
  .month-control div { min-width: 0; }
  .modal { padding-left: 8px; padding-right: 8px; }
  .modal-content { width: 100%; padding: 20px 16px; }
  .user-actions { width: 100%; }
  .user-actions select { width: 100%; }
  #appLogo { position: static; width: 76px; opacity: 1; }
  .developer-brand { background: #102347; border-radius: 12px; padding: 12px; }
}
