﻿/* ============================================
   RANKING USUARIOS — Overrides & Additions
   Base styles come from styles.css
   ============================================ */

/* ============================================
   HERO + PODIUM ROW
   ============================================ */
.hero-podium-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    flex-shrink: 0;
    align-items: stretch;
}

/* ============================================
   HERO RANK CARD
   ============================================ */
.hero-rank {
    flex: 1;
    min-width: 0;
    border-radius: 12px;
    padding: 16px;
    color: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.hero-rank.tier-elite {
    background: linear-gradient(135deg, #FFD700, #FF8C00);
}

.hero-rank.tier-top10 {
    background: linear-gradient(135deg, #C0C0C0, #8B8B8B);
}

.hero-rank.tier-rising {
    background: linear-gradient(135deg, #2E7D32, #66BB6A);
}

.hero-rank.tier-ontrack {
    background: linear-gradient(135deg, #1565C0, #42A5F5);
}

.hero-rank-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.hero-medal {
    font-size: 2rem;
}

.hero-rank-number {
    font-size: 1.5rem;
    font-weight: 900;
}

.hero-nick {
    font-size: 1rem;
    font-weight: 700;
    opacity: 0.95;
}

.hero-tier-msg {
    font-size: 0.75rem;
    opacity: 0.85;
    margin-top: 2px;
}

.hero-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.hero-stat {
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 8px;
    border-radius: 6px;
}

.hero-stat-icon {
    font-size: 0.85rem;
}

.hero-progress {
    margin-top: 8px;
}

.hero-progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.hero-progress-fill {
    height: 100%;
    background: #fff;
    border-radius: 3px;
    transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.hero-progress-text {
    font-size: 0.65rem;
    opacity: 0.8;
    margin-top: 4px;
}

/* ============================================
   STATS CARD (admin/marketing)
   ============================================ */
.hero-rank.hero-stats-card {
    background: linear-gradient(135deg, #1a1a1a, #2d2d2d);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.hero-stats-card .hero-rank-number {
    font-size: 1.2rem;
}

.hero-stats-card .hero-stats {
    gap: 8px;
}

.hero-stats-card .hero-stat {
    background: rgba(255, 255, 255, 0.08);
}

/* ============================================
   PODIUM — Top 3
   ============================================ */
.podium-section {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.podium-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 10px;
    border-radius: 12px;
    background: var(--card-surface);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    min-width: 80px;
    text-align: center;
}

.podium-card.podium-1 {
    order: 1;
    transform: translateY(-8px);
    border: 2px solid #FFD700;
}

.podium-card.podium-2 {
    order: 0;
    border: 2px solid #C0C0C0;
}

.podium-card.podium-3 {
    order: 2;
    border: 2px solid #CD7F32;
}

.podium-card.podium-highlight {
    box-shadow: 0 0 16px rgba(234, 118, 0, 0.3);
}

.podium-medal {
    font-size: 1.3rem;
}

.podium-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 800;
    color: #fff;
    text-transform: uppercase;
}

.podium-nick {
    font-size: 0.7rem;
    font-weight: 700;
    color: #333;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.podium-importe {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--brand-red);
}

/* ============================================
   FLOATING USER POSITION BAR
   ============================================ */
.user-position-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #1a1a1a, #2a2a2a);
    color: #fff;
    padding: 10px 16px;
    border-radius: 10px;
    margin-top: 8px;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.4s ease-out;
}

.user-position-bar.visible {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.position-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.position-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}

.position-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.position-text strong {
    font-size: 0.85rem;
    font-weight: 800;
}

.position-text span {
    font-size: 0.7rem;
    color: #bbb;
}

.scroll-top-btn {
    background: var(--brand-red);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
    font-family: var(--font);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    white-space: nowrap;
    animation: pulseBtn 2s infinite;
}

@keyframes pulseBtn {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(234, 118, 0, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(234, 118, 0, 0);
    }
}

.scroll-top-btn:hover {
    background: #b91d00;
    transform: scale(1.05);
}

/* ============================================
   USER TABLE GRID — 9 columns
   # | Avatar | NickName | TiendaFav | Ciudad | Tickets | Puntos | Importe | Racha
   ============================================ */
.user-table-header,
.user-row {
    grid-template-columns: 40px 36px 1fr 1fr 50px 60px 60px 70px 50px !important;
}

/* ============================================
   AVATAR CELL
   ============================================ */
.avatar-th {
    text-align: center;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    text-transform: uppercase;
}

/* ============================================
   NICKNAME CELL
   ============================================ */
.cell.nickname {
    font-weight: 700;
    color: #222;
    font-size: 0.78rem;
}

/* ============================================
   RACHA CELL
   ============================================ */
.cell.racha {
    font-weight: 700;
    color: #e65100;
    font-size: 0.78rem;
    text-align: center;
}

/* ============================================
   TIENDA FAV CELL
   ============================================ */
.cell.tiendafav {
    font-weight: 500;
    color: #555;
    font-size: 0.75rem;
}

/* ============================================
   HIGHLIGHTED USER ROW
   ============================================ */
.user-row.highlighted-user {
    background: linear-gradient(90deg, #fff0f0, #ffe8e8, #fff5f5);
    border-left: 5px solid var(--brand-red);
    box-shadow:
        0 0 16px rgba(234, 118, 0, 0.2),
        inset 0 0 0 1px rgba(234, 118, 0, 0.1);
    position: relative;
    animation: highlightPulse 2s ease-in-out 3;
}

@keyframes highlightPulse {

    0%,
    100% {
        box-shadow: 0 0 16px rgba(234, 118, 0, 0.2), inset 0 0 0 1px rgba(234, 118, 0, 0.1);
    }

    50% {
        box-shadow: 0 0 24px rgba(234, 118, 0, 0.35), inset 0 0 0 1px rgba(234, 118, 0, 0.2);
    }
}

.user-row.highlighted-user .cell.nickname {
    color: var(--brand-red);
    font-weight: 800;
}

.user-row.highlighted-user .cell.rank-num {
    color: var(--brand-red);
    font-weight: 900;
}

/* ============================================
   VIRTUAL SCROLL CONTAINER
   ============================================ */
#virtual-viewport {
    position: relative;
}

.user-row {
    background-color: var(--card-surface);
    display: grid;
    grid-template-columns: 40px 36px 1fr 1fr 50px 60px 60px 70px 50px;
    padding: 8px 14px;
    border-bottom: 1px solid #f0f0f0;
    align-items: center;
    gap: 4px;
    height: 44px;
    box-sizing: border-box;
}

.user-row:hover {
    background-color: #fafafa;
}

/* ============================================
   RECORD COUNT
   ============================================ */
.record-count {
    text-align: center;
    font-size: 0.65rem;
    color: #999;
    padding: 4px 0;
    flex-shrink: 0;
    font-weight: 500;
}

/* ============================================
   TICKETS, PUNTOS & IMPORTE CELLS
   ============================================ */
.cell.tickets,
.cell.puntos {
    text-align: right;
    font-weight: 600;
    color: #555;
    font-size: 0.75rem;
}

.cell.importe {
    text-align: right;
    font-weight: 800;
    color: var(--brand-red);
    font-size: 0.75rem;
}

/* ============================================
   RESPONSIVE OVERRIDES
   ============================================ */

/* --- Tablet (<=1200px): Tighten columns --- */
@media (max-width: 1200px) {

    .user-table-header,
    .user-row {
        grid-template-columns: 35px 32px 1fr 1fr 45px 55px 55px 65px 45px !important;
    }

    .hero-podium-row {
        flex-direction: column;
    }
}

/* --- Mobile (<=700px): Show priority columns --- */
/* Priority: #, NickName, Tickets, Puntos, Importe */
@media (max-width: 700px) {

    .user-table-header,
    .user-row {
        grid-template-columns: 30px 1fr 55px 55px 65px !important;
        padding: 6px 10px !important;
    }

    /* HIDE: avatar, tiendafav, ciudad, racha */
    .th.avatar-th,
    .cell.avatar-cell,
    .th.tiendafav,
    .cell.tiendafav,
    .th.ciudad,
    .cell.ciudad,
    .th[data-sort="racha"],
    .cell.racha {
        display: none !important;
    }

    /* Rank: Bold */
    .cell.rank-num {
        font-size: 0.78rem;
        font-weight: 900;
        color: #888;
    }

    /* NickName: Full space */
    .cell.nickname {
        font-size: 0.75rem;
        font-weight: 700;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Tickets: Compact */
    .cell.tickets {
        font-size: 0.68rem;
        font-weight: 700;
        color: #333;
    }

    /* Puntos: Key metric */
    .cell.puntos {
        font-size: 0.68rem;
        font-weight: 800;
    }

    /* Importe: Compact */
    .cell.importe {
        font-size: 0.68rem;
    }

    /* Table header: Smaller, prevent truncation */
    .user-table-header .th {
        font-size: 0.6rem;
        padding: 4px 0;
        overflow: visible;
        text-overflow: unset;
        white-space: nowrap;
    }

    /* Controls: Stack vertically */
    .controls-bar {
        flex-direction: column;
        gap: 6px;
    }

    .filters-group {
        flex-wrap: wrap;
    }

    .search-group {
        width: 100%;
    }

    .search-input {
        width: 100% !important;
    }

    /* Position bar: Compact */
    .user-position-bar {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        padding: 8px 12px;
    }

    .position-info {
        justify-content: center;
    }

    .scroll-top-btn {
        width: 100%;
        justify-content: center;
        padding: 10px 16px;
        font-size: 0.82rem;
    }

    /* Hero + Podium: Stack */
    .hero-podium-row {
        flex-direction: column;
    }

    .podium-section {
        justify-content: center;
    }
}

/* --- Small phone (<=420px): Ultra-compact 4 cols --- */
/* Keep: #, NickName, Puntos, Importe */
@media (max-width: 420px) {

    .user-table-header,
    .user-row {
        grid-template-columns: 28px 1fr 58px 65px !important;
        padding: 5px 8px !important;
        gap: 2px !important;
    }

    /* Also hide tickets on very small screens */
    .th[data-sort="tickets"],
    .cell.tickets {
        display: none !important;
    }

    .cell.rank-num {
        font-size: 0.72rem;
    }

    .cell.nickname {
        font-size: 0.7rem;
    }

    .cell.puntos {
        font-size: 0.65rem;
    }

    .cell.importe {
        font-size: 0.65rem;
    }

    .user-table-header .th {
        font-size: 0.55rem;
    }

    /* Page title smaller */
    .page-title {
        font-size: 1rem !important;
    }

    .filter-btn,
    .clear-btn {
        font-size: 0.62rem !important;
        padding: 3px 8px !important;
    }
}

/* ============================================
   REWARD NOTIFICATION
   ============================================ */
.reward-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px) scale(0.9);
    background: #fff;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 320px;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-left: 4px solid #25D366;
}

.reward-notification.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
    pointer-events: auto;
}

.notif-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
}

.notif-icon {
    font-size: 1.5rem;
    background: #e8f5e9;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notif-text h3 {
    margin: 0 0 4px 0;
    font-size: 0.9rem;
    font-weight: 800;
    color: #333;
}

.notif-text p {
    margin: 0;
    font-size: 0.75rem;
    color: #666;
    line-height: 1.4;
}

.notif-cta {
    display: block;
    background: #25D366;
    color: #fff;
    text-align: center;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.2s;
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.3);
    animation: pulseCta 2s infinite;
}

@keyframes pulseCta {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.4);
    }

    70% {
        transform: scale(1.02);
        box-shadow: 0 0 0 10px rgba(37, 211, 102, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
    }
}

/* ============================================
   INTERACTION LOCK OVERLAY
   ============================================ */
#interaction-lock-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s ease;
}

#interaction-lock-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ============================================
   DARK THEME
   Usamos .dark-theme en :root para que funcione
   desde <html> (head script) o <body> (theme.js)
   ============================================ */
body.dark-theme {
    --bg-canvas: #121212;
    --card-surface: #1e1e1e;
    --text-dark: #e0e0e0;
    --text-gray: #999;
    --table-header-bg: #111;
    --header-bg: #0a0a0a;
}

body.dark-theme .page-title {
    color: #e0e0e0;
}

body.dark-theme .user-row {
    border-bottom-color: #333;
}

body.dark-theme .user-row:hover {
    background-color: #2a2a2a;
}

body.dark-theme .cell.nickname {
    color: #e0e0e0;
}

body.dark-theme .cell.tiendafav,
body.dark-theme .cell.tickets,
body.dark-theme .cell.puntos {
    color: #bbb;
}

body.dark-theme .cell.ciudad {
    color: #aaa;
}

body.dark-theme .cell.rank-num {
    color: #ccc;
}

body.dark-theme .filter-btn {
    background: #2a2a2a;
    border-color: #444;
    color: #ccc;
}

body.dark-theme .dropdown-menu {
    background: #2a2a2a;
    border-color: #444;
}

body.dark-theme .dropdown-item:hover {
    background: #333;
}

body.dark-theme .dropdown-item.selected {
    background: #3a1a1a;
}

body.dark-theme .search-input {
    background: #2a2a2a;
    border-color: #444;
    color: #e0e0e0;
}

body.dark-theme .search-suggestions {
    background: #2a2a2a;
    border-color: #444;
}

body.dark-theme .suggestion-item:hover {
    background: #333;
}

body.dark-theme .ranking-list {
    background: #1e1e1e;
}

body.dark-theme .controls-bar label {
    color: #aaa;
}

body.dark-theme .clear-btn {
    color: #888;
}

body.dark-theme .podium-card {
    background: #2a2a2a;
}

body.dark-theme .podium-nick {
    color: #e0e0e0;
}

body.dark-theme .reward-notification {
    background: #2a2a2a;
}

body.dark-theme .notif-text h3 {
    color: #e0e0e0;
}

body.dark-theme .notif-text p {
    color: #aaa;
}

body.dark-theme .notif-icon {
    background: #1b3a1b;
}

body.dark-theme .user-row.highlighted-user {
    background: linear-gradient(90deg, #3a1a1a, #2e1515, #2a1a1a);
}

body.dark-theme .user-row.highlighted-user .cell.nickname {
    color: #ff6b4a;
}
