/**
 * Senka (戦果) — Sistema de Torneos y Liga Beyblade X (BDB)
 * Estilos Modulares para Ajustes y Opciones Avanzadas (Challonge Spec)
 * Autor: Sebastián Ariza / https://sebastiandeveloper.website/
 */

/* Contenedor Principal de Ajustes */
.settings-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-xl);
    overflow: hidden;
    margin-bottom: 2.5rem;
    box-shadow: var(--shadow-md);
}

/* Cabecera Superior Naranja Estilo Challonge */
.settings-advanced-badge-header {
    background: rgba(255, 85, 0, 0.08);
    border-bottom: 1px solid rgba(255, 85, 0, 0.3);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.settings-badge-title {
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--orange-xtreme);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-badge-title svg {
    flex-shrink: 0;
}

/* Subpestañas Internas de Configuración */
.settings-subnav-bar {
    display: flex;
    background: var(--bg-base);
    border-bottom: 1px solid var(--border-light);
    padding: 0 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    gap: 0.5rem;
}

.settings-subnav-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    padding: 0.9rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.settings-subnav-tab:hover {
    color: var(--text-primary);
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.settings-subnav-tab.active {
    color: var(--cyan-neon);
    border-bottom-color: var(--cyan-neon);
    background: rgba(0, 240, 255, 0.04);
}

.settings-subnav-tab.tab-danger {
    color: var(--text-secondary);
}

.settings-subnav-tab.tab-danger:hover {
    color: var(--danger);
}

.settings-subnav-tab.tab-danger.active {
    color: #ff5252;
    border-bottom-color: #ff5252;
    background: rgba(255, 82, 82, 0.06);
}

/* Paneles de Contenido */
.settings-panel-body {
    padding: 2rem 1.75rem;
}

.settings-tab-pane {
    display: none;
}

.settings-tab-pane.active {
    display: block;
    animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Secciones y Bloques dentro de Paneles */
.settings-section-head {
    margin-bottom: 1.5rem;
}

.settings-section-head h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.settings-section-head p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Grillas de Formulario */
.settings-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

/* Aviso de Estado Inmutable si está en progreso */
.settings-locked-notice {
    background: rgba(0, 240, 255, 0.07);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.settings-locked-notice strong {
    color: var(--cyan-neon);
}

.settings-locked-notice.warning {
    background: rgba(255, 183, 0, 0.08);
    border-color: rgba(255, 183, 0, 0.3);
}

.settings-locked-notice.warning strong {
    color: var(--gold-trophy);
}

/* Selector de Jueces y Árbitros Oficiales */
.settings-sr-only {
    position: absolute;
    clip-path: inset(50%);
    overflow: hidden;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    white-space: nowrap;
}

.referees-search-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.referees-search-box {
    position: relative;
    flex: 1;
    min-width: 240px;
    display: flex;
    align-items: center;
}

.referees-search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.referees-search-input {
    width: 100%;
    font: inherit;
    font-size: 0.88rem;
    padding: 0.6rem 2.4rem 0.6rem 2.45rem;
    min-height: 42px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.referees-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.referees-search-input::placeholder {
    color: var(--text-muted);
}

.referees-search-input:focus {
    outline: none;
    border-color: var(--cyan-neon);
    box-shadow: 0 0 0 2px rgba(0, 240, 255, 0.18);
}

.referees-search-input:focus-visible {
    outline: 2px solid var(--cyan-neon);
    outline-offset: 2px;
}

.referees-search-clear {
    position: absolute;
    right: 0.45rem;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background 0.15s ease;
}

.referees-search-clear:hover {
    color: var(--text-primary);
    background: rgba(0, 240, 255, 0.12);
}

.referees-search-clear:focus-visible {
    outline: 2px solid var(--cyan-neon);
    outline-offset: 1px;
}

.referees-search-clear[hidden] {
    display: none;
}

.referees-search-meta {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.referees-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
    margin-top: 0.85rem;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.referee-select-card {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.referee-select-card[hidden] {
    display: none;
}

.referees-empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 1.35rem 1rem;
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-md);
    background: rgba(17, 42, 64, 0.45);
    color: var(--text-secondary);
    font-size: 0.86rem;
}

.referees-empty-state[hidden] {
    display: none;
}

@media (pointer: coarse) {
    .referees-search-input {
        font-size: 1rem;
        min-height: 48px;
    }
    .referees-search-clear {
        width: 38px;
        height: 38px;
    }
}

.referee-select-card:hover {
    border-color: var(--border-medium);
    background: rgba(0, 240, 255, 0.05);
}

.referee-select-card.selected {
    border-color: var(--cyan-neon);
    background: rgba(0, 240, 255, 0.1);
}

.referee-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.referee-info {
    flex: 1;
    min-width: 0;
}

.referee-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.referee-role-tag {
    font-size: 0.72rem;
    color: var(--cyan-neon);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Pestaña: Reiniciar o Eliminar (Challonge Spec Exacta) */
.danger-actions-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.danger-action-card {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    transition: border-color 0.2s ease;
}

.danger-action-card:hover {
    border-color: rgba(255, 82, 82, 0.35);
}

.danger-action-card.card-disabled {
    opacity: 0.55;
    pointer-events: none;
    filter: grayscale(0.5);
}

.danger-action-info {
    flex: 1;
}

.danger-action-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    font-style: italic;
    color: var(--text-primary);
    margin: 0 0 0.4rem;
}

.danger-action-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.danger-action-desc strong {
    color: var(--text-primary);
}

.btn-challonge-danger {
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.6rem;
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(231, 76, 60, 0.35);
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-challonge-danger:hover {
    background: #d63031;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(231, 76, 60, 0.45);
}

.btn-challonge-warning {
    background: var(--gold-trophy);
    color: #050b11;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.6rem;
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(255, 183, 0, 0.35);
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-challonge-warning:hover {
    background: #ffc425;
    transform: translateY(-1px);
}

/* Barra de Guardado Inferior */
.settings-bottom-actions {
    background: var(--bg-base);
    border-top: 1px solid var(--border-light);
    padding: 1.25rem 1.75rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .danger-action-card {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .btn-challonge-danger,
    .btn-challonge-warning {
        width: 100%;
        text-align: center;
    }
}
