/**
 * Estilos para el sistema de Rankings de Minjacocs
 */

/* ============================================================================
   OVERLAY Y MODAL
   ============================================================================ */
.ranking-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
    box-sizing: border-box;
    backdrop-filter: blur(5px);
}

.ranking-modal {
    background: linear-gradient(145deg, #3d2b1f 0%, #2a1a10 100%);
    border: 2px solid #8B4513;
    border-radius: 16px;
    max-width: 950px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow:
        0 0 30px rgba(139, 69, 19, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    color: #e6d5c3;
    font-family: 'Outfit', sans-serif;
}

.ranking-modal::-webkit-scrollbar {
    width: 8px;
}

.ranking-modal::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.ranking-modal::-webkit-scrollbar-thumb {
    background: #8B4513;
    border-radius: 4px;
}

/* ============================================================================
   HEADER DEL MODAL
   ============================================================================ */
.ranking-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid rgba(139, 69, 19, 0.5);
    position: relative;
}

.ranking-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #FFD700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.close-btn {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: #5d4636;
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #7d5636;
    transform: translateY(-50%) scale(1.1);
}

/* ============================================================================
   CONTENIDO - DOS COLUMNAS
   ============================================================================ */
.ranking-content {
    display: flex;
    gap: 20px;
    padding: 20px;
}

.ranking-column {
    flex: 1;
    min-width: 0;
}

.ranking-column:first-child {
    flex: 1.4;
    /* Hacer la columna de EBRENCS más ancha */
}

.column-title {
    text-align: center;
    color: #b5a493;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 12px;
}

.ranking-table-wrapper {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid rgba(139, 69, 19, 0.4);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.ranking-table-wrapper::-webkit-scrollbar {
    width: 6px;
}

.ranking-table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(139, 69, 19, 0.6);
    border-radius: 3px;
}

/* ============================================================================
   TABLA DE RANKING
   ============================================================================ */
.ranking-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.ranking-table thead {
    position: sticky;
    top: -1px;
    /* Un píxel de margen para asegurar que no se vea nada */
    z-index: 10;
}

.ranking-table th {
    background: #1a120b;
    padding: 10px 8px;
    text-align: left;
    color: #b5a493;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.text-right {
    text-align: right !important;
}

.ranking-table td {
    padding: 10px 8px;
    border-bottom: 1px solid rgba(139, 69, 19, 0.2);
}

.ranking-table tbody tr:hover {
    background: rgba(139, 69, 19, 0.15);
}

.ranking-table .top-three td {
    background: rgba(255, 215, 0, 0.08);
}

.ranking-table .top-three:first-child td {
    background: rgba(255, 215, 0, 0.15);
}

.rank-num {
    color: #FFD700;
    font-weight: bold;
    width: 30px;
    text-align: center;
}

.rank-name {
    font-weight: normal;
    color: #fff;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-town,
.rank-town-name {
    color: #b5a493;
    font-weight: normal;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-level {
    text-align: center;
    color: #8BC34A;
}

.rank-score {
    text-align: right;
    font-weight: bold;
    color: #FFD700;
}

.no-data {
    text-align: center;
    color: #888;
    padding: 30px !important;
    font-style: italic;
}

/* ============================================================================
   FOOTER DEL MODAL
   ============================================================================ */
.ranking-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(139, 69, 19, 0.3);
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
}

.ranking-footer p {
    margin: 5px 0;
    font-size: 0.85rem;
    color: #b5a493;
}

.link-accent {
    color: #FFD700;
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s;
}

.link-accent:hover {
    color: #FFA500;
}

.copy-link {
    cursor: pointer;
    font-size: 1.1rem;
    margin-left: 5px;
    transition: transform 0.2s;
    display: inline-block;
}

.copy-link:hover {
    transform: scale(1.2);
}

/* ============================================================================
   SECCIÓN DE PERFIL
   ============================================================================ */
.ranking-profile {
    padding: 15px 20px 20px;
    border-top: 1px solid rgba(139, 69, 19, 0.3);
    background: rgba(0, 0, 0, 0.15);
}

.ranking-profile h4 {
    margin: 0 0 12px 0;
    color: #e6d5c3;
    font-size: 0.95rem;
    text-align: center;
}

.profile-form {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.profile-form input,
.profile-form select {
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #5d4636;
    color: #e6d5c3;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
}

.profile-form input {
    width: 140px;
}

.profile-form select {
    width: 160px;
}

.profile-form input:focus,
.profile-form select:focus {
    outline: none;
    border-color: #FFD700;
}

.save-btn {
    background: #7d5636;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.save-btn:hover {
    background: #9d6646;
    transform: translateY(-1px);
}

/* ============================================================================
   MODAL DE RÉCORD (más pequeño)
   ============================================================================ */
.record-modal {
    max-width: 400px;
    text-align: center;
    padding: 25px;
}

.record-modal h2 {
    margin: 0 0 10px 0;
    font-size: 1.8rem;
    color: #FFD700;
}

.record-subtitle {
    color: #8BC34A;
    font-size: 1.1rem;
    margin: 0 0 5px 0;
}

.record-score {
    color: #b5a493;
    font-size: 0.95rem;
    margin: 0 0 20px 0;
}

.record-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.record-form input,
.record-form select {
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #5d4636;
    color: #e6d5c3;
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
}

.record-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.primary-btn {
    flex: 2;
    background: linear-gradient(180deg, #FFD700 0%, #FFA500 100%);
    color: #000;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 0 #8B4513;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #8B4513;
}

.primary-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #8B4513;
}

.secondary-btn {
    flex: 1;
    background: #5d4636;
    color: #fff;
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: #7d5636;
}

/* ============================================================================
   INDICADOR DE POSICIÓN EN LA UI PRINCIPAL
   ============================================================================ */
.top-badge {
    display: inline-block;
    color: #ff8800;
    font-size: 10px;
    font-weight: normal;
    margin-left: 4px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: inherit;
}

.rank-position {
    display: inline-block;
    color: #b5a493;
    font-size: 10px;
    font-weight: normal;
    margin-left: 4px;
    vertical-align: middle;
}

.rank-position:hover {
    background: rgba(139, 69, 19, 0.8);
    transform: scale(1.05);
}

/* Botón de ranking discreto */
.ranking-link {
    display: inline-block;
    color: #FFD700;
    font-size: 10px;
    cursor: pointer;
    text-decoration: underline;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.ranking-link:hover {
    opacity: 1;
}

/* ============================================================================
   RESPONSIVE - MÓVIL
   ============================================================================ */
@media (max-width: 700px) {
    .ranking-modal {
        max-height: 95vh;
        height: 95vh;
        display: flex;
        flex-direction: column;
        border-radius: 12px;
    }

    .ranking-content {
        flex-direction: column;
        flex: 1;
        gap: 10px;
        padding: 5px 10px 10px 10px;
        overflow: hidden;
    }

    .ranking-column:first-child .ranking-table-wrapper {
        max-height: 52vh;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .ranking-column:last-child .ranking-table-wrapper {
        max-height: 28vh;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .ranking-column:first-child .column-title {
        margin-top: 0 !important;
    }

    .ranking-table {
        font-size: 0.75rem;
    }

    .ranking-header {
        padding: 12px 15px;
    }

    .ranking-header h2 {
        font-size: 1.2rem;
    }

    .column-title {
        font-size: 0.75rem !important;
        letter-spacing: 1px !important;
        margin-bottom: 6px !important;
        /* Texto pegado a la tabla */
    }

    .ranking-table {
        table-layout: auto;
        /* Dejar que fluya para evitar cortes */
        width: 100% !important;
        border-spacing: 0;
    }

    .ranking-table th,
    .ranking-table td {
        padding: 6px 3px !important;
        font-size: 0.70rem;
    }

    .rank-num {
        width: 25px !important;
    }

    .rank-score {
        width: 70px !important;
        text-align: right !important;
    }

    .rank-level {
        width: 30px !important;
        text-align: center !important;
    }

    .rank-name,
    .rank-town,
    .rank-town-name {
        max-width: 75px !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Asegurar que el icono no rompa la linea */
    .rank-score span {
        display: inline-block;
    }

    .me-icon {
        vertical-align: middle;
        margin-right: 2px;
    }

    .ranking-header h2 {
        font-size: 1.2rem;
    }

    .profile-form {
        flex-direction: column;
        align-items: center;
    }

    .profile-form input,
    .profile-form select {
        width: 100%;
        max-width: 250px;
    }

    .record-modal {
        padding: 20px 15px;
    }
}

/* Para pantallas muy pequeñas */
@media (max-width: 400px) {
    .ranking-overlay {
        padding: 10px;
    }

    .ranking-modal {
        border-radius: 10px;
    }

    .ranking-header {
        padding: 15px;
    }

    .ranking-footer,
    .ranking-profile {
        padding: 12px 15px;
    }
}

/* Resaltado del jugador actual */
.ranking-table tr.is-me {
    background: rgba(255, 215, 0, 0.05) !important;
    /* Más sutil todavía */
}

.ranking-table tr.is-me .rank-score {
    color: #FFD700;
    animation: me-blink 2s infinite alternate ease-in-out;
}

.me-icon {
    height: 14px;
    width: auto;
    filter: drop-shadow(0 0 2px rgba(255, 215, 0, 0.5));
}

@keyframes me-blink {
    0% {
        opacity: 0.8;
        text-shadow: 0 0 5px rgba(255, 215, 0, 0.4);
    }

    100% {
        opacity: 1;
        text-shadow: 0 0 15px rgba(255, 215, 0, 1), 0 0 25px rgba(255, 215, 0, 0.5);
    }
}