:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --secondary: #0ea5e9;
  --success: #16a34a;
  --error: #dc2626;
  --warning: #d97706;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-light: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #475569;
  --radius: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.3);

  --role-directiva: #7c3aed;
  --role-coordinador: #0891b2;
  --role-miembro: #64748b;
  --module-beraka: #8b5cf6;
  --module-dulces: #ec4899;
  --module-comunidad: #14b8a6;
}

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

body {
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a {
  color: var(--secondary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Flash messages */
.flash-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flash {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.flash-hide {
  opacity: 0;
  transform: translateX(100%);
}

.flash-success {
  background: var(--success);
  color: white;
}
.flash-error {
  background: var(--error);
  color: white;
}
.flash-warning {
  background: var(--warning);
  color: white;
}
.flash-info {
  background: var(--secondary);
  color: white;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Auth pages */
.auth-page {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  overflow: hidden;

  background-image: url("../imagenes/fondo_robot.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;

  animation: fondoZoom 12s ease-in-out infinite alternate;
}

@keyframes fondoZoom {
  from {
    background-size: 100% 100%;
  }

  to {
    background-size: 105% 105%;
  }
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 18px;
  padding: 2rem;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.45),
    0 0 30px rgba(79, 70, 229, 0.15);

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  animation: loginEntrada 0.9s ease-out;
}

@keyframes loginEntrada {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.auth-header .hint,
.auth-info .hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.auth-info {
  margin-bottom: 1.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.auth-form .form-group {
  margin-bottom: 1rem;
}

.auth-links {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.auth-links span {
  margin: 0 0.5rem;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
textarea,
select,
.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25);
}

/* Mostrar/ocultar contraseña */
.password-input-wrap {
  position: relative;
}

.password-input-wrap input[type] {
  padding-right: 2.75rem;
}

.password-toggle-visibility {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  border: none;
  background: none;
  padding: 0;
  color: var(--text-muted);
  cursor: pointer;
}

.password-toggle-visibility:hover {
  color: var(--text);
}

.password-toggle-visibility .icon-eye-off {
  display: none;
}

.password-toggle-visibility.is-visible .icon-eye {
  display: none;
}

.password-toggle-visibility.is-visible .icon-eye-off {
  display: block;
}

textarea {
  resize: vertical;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  text-align: center;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  text-decoration: none;
}

.btn-secondary {
  background: var(--surface-light);
  color: var(--text);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(30, 41, 59, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
}

.nav-back {
  color: var(--text-muted);
  margin-right: auto;
  padding-right: 1rem;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.role-badge {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.role-directiva {
  background: var(--role-directiva);
}
.role-coordinador {
  background: var(--role-coordinador);
}
.role-miembro {
  background: var(--role-miembro);
}

/* Shared card base  */
.module-card,
.permissions-info,
.section-card,
.panel,
.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Dashboard */
.dashboard,
.module-page,
.comunidad-page,
.section-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
}

.dashboard-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.dashboard-header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.dashboard-header p {
  color: var(--text-muted);
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.module-card {
  padding: 2rem;
  text-align: center;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  color: var(--text);
  text-decoration: none;
}

.module-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  text-decoration: none;
}

.module-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.module-card h2 {
  margin-bottom: 0.5rem;
}

.module-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.module-beraka {
  border-top: 4px solid var(--module-beraka);
}
.module-dulces {
  border-top: 4px solid var(--module-dulces);
}
.module-comunidad {
  border-top: 4px solid var(--module-comunidad);
}

.permissions-info {
  padding: 1.5rem;
}

.permissions-info h3 {
  margin-bottom: 0.75rem;
}

.permissions-info ul {
  padding-left: 1.25rem;
  color: var(--text-muted);
}

/* Module pages */
.module-page header,
.comunidad-page header {
  margin-bottom: 2rem;
}

.sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.section-card {
  padding: 1.5rem;
  text-align: center;
  color: var(--text);
  transition: background 0.2s;
}

.section-card:hover {
  background: var(--surface-light);
  text-decoration: none;
}

/* Section musical layout */
.section-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .section-layout,
  .misa-layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.panel h3 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.sidebar .panel {
  margin-bottom: 1rem;
}

.canto-list {
  list-style: none;
}

.canto-list li {
  margin-bottom: 0.5rem;
}

.canto-btn {
  width: 100%;
  padding: 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s;
}

.canto-btn:hover:not(:disabled) {
  border-color: var(--primary);
}

.canto-btn.active {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.15);
}

.canto-display {
  min-height: 200px;
}

.canto-display h2 {
  color: var(--secondary);
  margin-bottom: 1rem;
}

#canto-letra {
  white-space: pre-wrap;
  font-family: inherit;
  color: var(--text-muted);
  background: transparent;
  border: none;
}

.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.gallery-item img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.gallery-item figcaption {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  text-align: center;
}

/* Comunidad */
.form-panel {
  margin-bottom: 2rem;
}

.items-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.item-card {
  padding: 1.25rem;
}

.item-card h3 {
  margin-bottom: 0.5rem;
}

.item-card .meta {
  color: var(--secondary);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.item-card footer {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

.message-card p {
  margin-bottom: 0.5rem;
}

/* Misa */
.misa-header {
  margin-bottom: 1.5rem;
}

.misa-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
}

.leader-panel .hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.lider-actual-box {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.misa-partes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.misa-parte-card h2 {
  font-size: 1rem;
}

/* BARRA DE INSTRUMENTOS*/

.instrumentos-section {
  width: 100%;
  margin: 0 0 1.5rem 0;
}

/* Encabezado */

.instrumentos-header {
  margin-bottom: 0.8rem;
}

.instrumentos-header .section-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: #8b5cf6;
  margin-bottom: 0.25rem;
}

.instrumentos-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text);
}

.instrumentos-header p {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* CONTENEDOR DE INSTRUMENTOS */

.instrumentos-bar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.6rem;

  padding: 0.7rem;

  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

/*TARJETA DE INSTRUMENTO*/

.instrumento-card {
  min-height: 75px;

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

  gap: 0.4rem;

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

  border: 1px solid var(--border);
  border-radius: 9px;

  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;

  transition:
    transform 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.instrumento-card.active {
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.2);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

/*EFECTO AL PASAR EL MOUSE */

.instrumento-card:hover {
  transform: translateY(-3px);

  background: rgba(139, 92, 246, 0.1);

  border-color: #8b5cf6;

  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
}

/* ICONO */

.instrumento-icon {
  font-size: 1.7rem;
  line-height: 1;
}

/* NOMBRE DEL INSTRUMENTO */

.instrumento-nombre {
  font-size: 0.75rem;
  font-weight: 700;
}

.instrumento-seleccionado {
  text-align: center;
  margin-top: 0.75rem;
  color: var(--secondary);
  font-weight: 600;
  font-size: 0.9rem;
}

.misa-parte-btn {
  border: none;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
}

.misa-parte-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.misa-parte-btn:not(:disabled):hover {
  background: var(--surface-light);
}

.image-gallery-large .gallery-item-large img {
  height: auto;
  max-height: 70vh;
  object-fit: contain;
  background: var(--bg);
}

.gallery-item-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
}

.gallery-item {
  border-radius: 8px;
  transition:
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

.gallery-item.active {
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.35);
  border-radius: 8px;
}

.gallery-item.active img {
  border-color: #8b5cf6;
}

.btn-marcar-canto {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
}

.canto-actual-banner {
  margin-top: 0.5rem;
  color: var(--secondary);
  font-weight: 600;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.9);
}

.lightbox[hidden] {
  display: none;
}

.lightbox-img {
  width: 94vw;
  height: 88vh;
  object-fit: contain;
  border-radius: 8px;
  background: var(--surface);
}

.lightbox-caption {
  color: var(--text);
  font-size: 0.95rem;
}

.lightbox-close {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

/* RESPONSIVE */

@media (max-width: 1000px) {
  .instrumentos-bar {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 600px) {
  .instrumentos-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Admin */
.admin-panel {
  margin-bottom: 1.5rem;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.admin-links {
  margin-top: 2rem;
}

.letra-preview {
  white-space: pre-wrap;
  color: var(--text-muted);
  font-family: inherit;
  margin: 0.5rem 0 1rem;
}

.inline-form {
  display: inline;
}

#app-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: var(--bg);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#app-loader.app-loader--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.app-loader-spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid rgba(148, 163, 184, 0.25);
  border-top-color: var(--secondary);
  animation: app-loader-spin 0.8s linear infinite;
}

.app-loader-brand {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

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

@media (prefers-reduced-motion: reduce) {
  .app-loader-spinner {
    animation-duration: 1.6s;
  }
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stat-card .stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.stat-percent {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--secondary);
}

.progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.top-cantos-details {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.top-cantos-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--secondary);
}

.top-cantos-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.top-canto-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}

.top-canto-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.top-canto-titulo {
  font-weight: 600;
}

.top-canto-porcentaje {
  color: var(--secondary);
  font-weight: 700;
  flex-shrink: 0;
}

.progress-bar--sm {
  height: 5px;
  margin-bottom: 0.35rem;
}

.empty-state--sm {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.carpeta-instrumento-panel {
  margin-bottom: 1.5rem;
}

.carpeta-instrumento-panel h3 {
  margin-bottom: 1rem;
}

.partes-details {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.partes-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--secondary);
  margin-bottom: 0.75rem;
}

.partes-carpetas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.parte-carpeta-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
}

.parte-carpeta-item h4 {
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.parte-carpeta-item input[type="url"] {
  width: 100%;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.parte-carpeta-actions {
  margin-bottom: 0.35rem;
}
