/* =================================
   VARIABLES GLOBALES Y RESET
   ================================= */
:root {
    /* Colores */
    --color-background: #111827;
    --color-surface: #1f2937;
    --color-surface-light: #374151;
    --color-surface-lighter: #4b5563;
    --color-text-primary: #f3f4f6;
    --color-text-secondary: #d1d5db;
    --color-text-muted: #9ca3af;
    --color-primary: #1ea795;
    --color-primary-dark: #176d62;
    --color-secondary: #6b7280;
    --color-danger: #dc2626;
    --color-danger-dark: #b91c1c;
    --color-success: #059669;
    --color-warning: #d97706;
    --color-border: #374151;

    /* Escenario */
    --stage-width: 1600px;
    --stage-height: 900px;
    --grid-size: 20px;
    
    /* Animaciones */
    --animation-duration: 0.2s;
}

/* Reset básico y estilos base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--color-background);
    color: var(--color-text-secondary);
    line-height: 1.5;
}

h1, h2, h3, h4 {
    color: var(--color-text-primary);
	}

.hidden {
    display: none !important;
}

/* =================================
   ESTRUCTURA PRINCIPAL
   ================================= */
#app {
    min-height: 100vh;
    padding: 0.5rem;
    display: flex;
    flex-direction: column
}

@media (min-width: 768px) {
    #app {
        padding: 0.1rem
    }
}

.app-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

@media (min-width: 768px) {
    .app-header {
        flex-direction: row;
        align-items: center;
    }
}

.header-title-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-title-group h1 {
    font-size: 1.5rem;
    font-weight: bold;
}

@media (min-width: 768px) {
    .header-title-group h1 {
        font-size: 1.875rem;
    }
}

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

.header-logo {
    width: 3rem;
    height: 3rem;
    background-color: var(--color-primary);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo .icon {
    width: 1.5rem;
    height: 1.5rem;
    color: white;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: flex-end;
}

.admin-tools {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: var(--color-surface);
    border-radius: 0.5rem;
}

.admin-tools h3 {
    font-weight: 600;
    color: white;
    margin-right: 1rem;
    margin-bottom: 0.5rem;
}

.admin-tools-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

/* =================================
   COMPONENTE: ESCENARIO (STAGE)
   ================================= */
.stage-container {
    aspect-ratio: 16/9;
    background: linear-gradient(135deg, var(--color-surface) 0%, var(--color-background) 100%);
    position: relative;
    overflow: hidden;
    border: 2px solid var(--color-border);
    border-radius: 12px;
    margin-bottom: 1rem;
    user-select: none;
}

.stage-area {
    position: absolute;
    inset: 0;
    width: var(--stage-width);
    height: var(--stage-height);
    transform-origin: top left;
    transition: transform var(--animation-duration) ease-out;
}

.stage-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding-inline: 1rem 1.6rem;
    background: rgba(0, 0, 0, 0.4);
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stage-header-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stage-header-logo img {
    width: 2.5rem;
    height: 2.5rem;
    object-fit: contain;
}

.stage-header-logo span {
    color: white;
    font-weight: 600;
}

.stage-header h2 {
    font-size: 1.25rem;
    font-weight: bold;
}

@media (min-width: 768px) {
    .stage-header h2 {
        font-size: 1.5rem;
    }
}

.stage-header #current-date {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

#members-container {
    position: absolute;
    inset: 0;
}

/* Controles del Escenario */
.stage-controls {
    position: absolute;
    right: 0.5rem;
    bottom: 0.5rem;
    z-index: 30;
}

.stage-controls-panel {
    background: rgba(31, 41, 55, 0.9);
    backdrop-filter: blur(8px);
    border-radius: 0.4rem;
    border: 1px solid var(--color-border);
    padding: 0.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

@media (min-width: 640px) {
    .stage-controls-panel {
        flex-direction: row;
    }
}

.admin-stage-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}



/* =================================
   COMPONENTE: ELEMENTO DE MIEMBRO
   ================================= */
.member-element {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transform: translate(-50%, -50%);
    transition: all var(--animation-duration) ease-out;
    cursor: pointer;
    z-index: 10;
}

.member-element.dragging {
    z-index: 50;
    transform: translate(-50%, -50%) scale(1.1);
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.5));
}

.member-element.admin-mode {
    cursor: grab;
}

.member-element.admin-mode:active {
    cursor: grabbing;
}

.member-element .member-name {
    font-size: 16px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    color: white;
    background-color: rgba(17, 24, 39, 0.8);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.member-element .member-avatar {
    position: relative;
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border: 3px solid var(--color-text-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 12px -2px rgba(0, 0, 0, 0.3), 0 4px 8px -2px rgba(0, 0, 0, 0.2);
}

.member-element .member-avatar img {
    width: 4rem; /* 48px */
    height: 4rem;
    object-fit: contain;
}

.member-element .member-id {
    position: absolute;
    width: 28px;
    height: 28px;
    font-size: 14px;
    font-weight: 900;
    top: -8px;
    left: -8px;
    background-color: var(--color-primary);
    color: white;
    border: 3px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
}

.member-element .member-icons {
    min-height: 40px;
    gap: 8px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.member-element .member-icons img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

/* Botones de admin en el avatar */
.member-avatar .admin-buttons {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity var(--animation-duration);
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
}

.member-avatar:hover .admin-buttons {
    opacity: 1;
}

.member-avatar .admin-btn {
    width: 1.75rem;
    height: 1.75rem;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    border: none;
    cursor: pointer;
}

.member-avatar .admin-btn.edit {
    background-color: var(--color-primary);
}
.member-avatar .admin-btn.edit:hover {
    background-color: var(--color-primary-dark);
}

.member-avatar .admin-btn.delete {
    background-color: var(--color-danger);
}
.member-avatar .admin-btn.delete:hover {
    background-color: var(--color-danger-dark);
}

/* Mejoras responsive para miembros */
@media (max-width: 768px) {
    .member-element .member-name { font-size: 18px; padding: 8px 14px; }
    .member-element .member-avatar { width: 100px; height: 100px; border-width: 4px; }
    .member-element .member-id { width: 32px; height: 32px; font-size: 16px; }
    .member-element .member-icons img { width: 40px; height: 40px; }
}

@media (max-width: 480px) {
    .member-element .member-name { font-size: 20px; padding: 10px 16px; }
    .member-element .member-avatar { width: 120px; height: 120px; }
    .member-element .member-id { width: 36px; height: 36px; font-size: 18px; }
    .member-element .member-icons img { width: 44px; height: 44px; }
}

/* =================================
   GUIAS Y REJILLA (GRID/GUIDES)
   ================================= */
.grid-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--animation-duration) ease-out;
    z-index: 5;
}

.grid-overlay.visible {
    opacity: 0.3;
    background-image: 
        repeating-linear-gradient(0deg, rgba(59, 130, 246, 0.3), rgba(59, 130, 246, 0.3) 1px, transparent 1px, transparent var(--grid-size)),
        repeating-linear-gradient(90deg, rgba(59, 130, 246, 0.3), rgba(59, 130, 246, 0.3) 1px, transparent 1px, transparent var(--grid-size));
}

.guide-line {
    position: absolute;
    background: rgba(59, 130, 246, 0.6);
    pointer-events: none;
    z-index: 30;
    opacity: 0;
    transition: opacity 0.1s ease-out;
}

.guide-line.horizontal { left: 0; right: 0; height: 1px; }
.guide-line.vertical { top: 0; bottom: 0; width: 1px; }
.guide-line.visible { opacity: 1; }

/* =================================
   COMPONENTE: TOOLTIP
   ================================= */
.tooltip {
    position: absolute;
    background: rgba(17, 24, 39, 0.98);
    border: 2px solid var(--color-primary);
    border-radius: 12px;
    padding: 1rem;
    font-size: 1rem;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease-out;
    backdrop-filter: blur(12px);
    max-width: 320px;
    min-width: 240px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    visibility: hidden;
}

.tooltip.visible {
    opacity: 1;
    visibility: visible;
}

.tooltip.interactive {
    pointer-events: auto;
}

.tooltip .tooltip-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: var(--color-danger);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#tooltip-content h4 {
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}
#tooltip-content p {
    font-size: 0.875rem;
}
#tooltip-content .tooltip-label {
    font-weight: 600;
    color: var(--color-text-secondary);
}

@media (max-width: 768px) {
    .tooltip {
        font-size: 18px;
        padding: 20px;
        max-width: 90vw;
        border-radius: 16px;
    }
}

/* =================================
   COMPONENTE: TABLA DE DATOS
   ================================= */
.table-container {
    background-color: var(--color-surface);
    border-radius: 0.5rem;
    overflow: hidden;
}

.table-scroll-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid var(--color-border);
    padding: 12px 16px;
    text-align: left;
    white-space: nowrap;
}

.data-table th {
    background: var(--color-surface-light);
    font-weight: 600;
    font-size: 14px;
    /*text-transform: uppercase;*/
    letter-spacing: 0.02em;
    color: var(--color-text-secondary);
}

.data-table tbody tr:hover {
    background: var(--color-surface-light);
}

.data-table .action-link {
    color: var(--color-primary);
    text-decoration: none;
    cursor: pointer;
    margin-right: 0.75rem;
}
.data-table .action-link:hover {
    text-decoration: underline;
}
.data-table .action-link.delete {
    color: var(--color-danger);
}

/* Icono + texto dentro de la celda de Instrumento */
.instrument-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.instrument-cell img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  vertical-align: middle;
}

/* Paginación de la tabla */
.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-top: 1px solid var(--color-border);
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#page-numbers {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

#page-numbers button {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    background-color: var(--color-surface-lighter);
    color: var(--color-text-secondary);
}
#page-numbers button:hover {
    background-color: #4b5563;
}
#page-numbers button.active {
    background-color: var(--color-primary);
    color: white;
}


/* =================================
   ESTILOS DE FORMULARIOS Y MODALES
   ================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-content {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--color-border);
    width: 100%;
    max-width: 500px;
}

.modal-content.large {
    max-width: 650px;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 1rem;
    text-align: center;
}

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

.form-label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.form-input {
    width: 100%;
    background: var(--color-surface-light);
    border: 1px solid var(--color-surface-lighter);
    border-radius: 6px;
    padding: 8px 12px;
    color: white;
    font-size: 14px;
    transition: border-color 0.2s ease-out;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.form-group-checkbox {
    display: flex;
    align-items: center;
    margin: 1rem 0;
}

.form-group-checkbox label {
    margin-left: 0.5rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.form-checkbox {
    width: 1rem;
    height: 1rem;
    accent-color: var(--color-primary);
    background-color: var(--color-surface-light);
    border: 1px solid var(--color-surface-lighter);
    border-radius: 4px;
}

.form-error {
    color: var(--color-danger);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1rem;
}

/* =================================
   BOTONES Y ELEMENTOS DE UI
   ================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease-out;
}

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

.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-secondary); color: white; }
.btn-secondary:hover:not(:disabled) { background: var(--color-surface-lighter); }
.btn-danger { background: var(--color-danger); color: white; }
.btn-danger:hover:not(:disabled) { background: var(--color-danger-dark); }

.btn-control {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 6px;
    background: var(--color-surface-light);
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 32px;
    height: 28px;
}
.btn-control:hover { background: var(--color-surface-lighter); }
.btn-control:active { transform: scale(0.95); }
.btn-control .icon-sm { width: 0.9rem; height: 0.9rem; }

.btn .icon-sm {
    width: 1rem;
    height: 1rem;
}

/* Estado "OFF/ON" más discreto (opcional) */
#snap-status, #grid-status {
  font-size: 11px;    /* acompasa el botón */
  letter-spacing: 0.2px;
}

/* Notificación y estado */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    padding: 12px 16px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease-out;
    max-width: 320px;
}
.notification.visible { opacity: 1; transform: translateX(0); }
.notification.success { background: var(--color-success); }
.notification.error { background: var(--color-danger); }
.notification.warning { background: var(--color-warning); }

.save-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    color: var(--color-text-muted);
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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



/* Asegurar que la tabla ajuste ancho por contenido */
.data-table {
  table-layout: auto;  /* si antes tenías fixed, cámbialo a auto */
  width: 100%;
}

/* Comprimir específicamente la 1ª columna (ID) y pegar la 2ª (Nombre) */
.data-table th:nth-child(1),
.data-table td:nth-child(1) {
  width: 1%;           /* fuerza a ser lo más estrecha posible */
  white-space: nowrap; /* evita saltos de línea en el ID */
  padding-right: 6px;  /* menos espacio a la derecha */
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
  padding-left: 6px;   /* “pega” la col 2 a la 1 */
}

/* Instrumento: icono + texto compactos */
.instrument-cell {
  display: inline-flex;
  align-items: center;
  gap: 4px;             /* un pelín menos de separación */
}

.instrument-cell img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  vertical-align: middle;
}

/* --- Responsive (pantallas pequeñas) --- */
@media (max-width: 640px) {
  /* Fuente un poco más pequeña en la tabla */
  .data-table {
    font-size: 0.65rem;     /* ajusta a 0.85rem si quieres más pequeño */
  }

  /* Menos padding para pegar columnas */
  .data-table th,
  .data-table td {
    padding: 3px;      /* antes 10-12px típicos */
  }

  /* Comprimir todavía más el ID en móvil */
  .data-table th:nth-child(1),
  .data-table td:nth-child(1) {
    width: 1%;
    padding-right: 4px;
    letter-spacing: 0.2px; /* se mantiene legible sin ensanchar */
  }

  .data-table th:nth-child(2),
  .data-table td:nth-child(2) {
    padding-left: 4px;
  }

  /* Si hay columna de acciones (Editar/Eliminar), compactarla */
  .data-table th:last-child,
  .data-table td:last-child {
    white-space: nowrap;
    width: 1%;
  }
}

/* Opcional: evitar que algunas celdas se estiren por palabras largas */
.data-table td,
.data-table th {
  word-break: keep-all;
}

/* =================================  */
.header {
	position: relative;
            background: rgba(14, 17, 22, 0.9);
            border-bottom: 1px solid #2a3441;
        }
        .app-header {
            margin-top: 0;
        }
        .footer {
            margin-top: auto;
        }

.hospitality-note {
  margin-top: 1rem;
  padding: 1rem;
  background-color: var(--color-surface);
  border-left: 4px solid var(--color-primary);
  border-radius: 8px;
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  line-height: 1.4;
  text-align: center;
}
