﻿/* ============================================
   DESIGN TOKENS — CLUB PETROMAYAB
   ============================================ */
:root {
    --brand-primary: #EA7600;
    /* PANTONE® 716 C — Naranja PETROMAYAB */
    --brand-primary-dark: #C96500;
    --brand-primary-glow: rgba(234, 118, 0, 0.4);
    --brand-gray: #75787B;
    /* PANTONE® Cool Gray 9 C */
    --brand-gray-dark: #3D3F42;
    --brand-red: #EA7600;
    /* Alias for backward compat */
    --brand-red-glow: rgba(234, 118, 0, 0.4);
    --header-bg: #FFFFFF;
    --bg-canvas: #F5F5F3;
    /* Clean whitespace-oriented background */
    --card-surface: #FDFDFD;
    --table-header-bg: #3D3F42;
    /* Dark charcoal nav/headers */
    --table-header-text: #FFFFFF;
    --text-dark: #2D2D2D;
    --text-gray: #75787B;
    --shadow-card: 0 4px 15px rgba(0, 0, 0, 0.05);
    --border-subtle: #DDDDDD;
    --radius: 8px;
    --font: 'Montserrat', sans-serif;
    --font-display: 'Montserrat', sans-serif;
}

/* ============================================
   DARK THEME OVERRIDES
   ============================================ */
body.dark-theme {
    --brand-primary: #EA7600;
    --brand-primary-glow: rgba(234, 118, 0, 0.6);
    --brand-red: #EA7600;
    --brand-red-glow: rgba(234, 118, 0, 0.6);
    --header-bg: #1a1a1a;
    --bg-canvas: #0a0a0a;
    --card-surface: #121212;
    --table-header-bg: #1a1a1a;
    --table-header-text: #f0f0f0;
    --text-dark: #f0f0f0;
    --text-gray: #a0a0a0;
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.5);
    --border-subtle: #222222;
    color-scheme: dark;
}

/* ============================================
   RESET
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ============================================
   BODY - FIXED VIEWPORT
   ============================================ */
body {
    font-family: var(--font);
    background-color: var(--bg-canvas);
    color: var(--text-dark);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ============================================
   HEADER
   ============================================ */
.main-header {
    height: 56px;
    background-color: var(--header-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    flex-shrink: 0;
}

.logo {
    font-family: var(--font);
    font-size: 1.5rem;
    font-weight: 900;
    font-style: normal;
    letter-spacing: 1px;
}

.logo-running {
    color: var(--brand-primary);
}

.logo-puch {
    color: var(--brand-gray);
}

/* Main Nav */
.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #999;
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.nav-link.active {
    color: #fff;
    background: var(--brand-red);
}

.nav-link svg {
    flex-shrink: 0;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-avatar-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #444;
    background: #333;
    color: #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.user-avatar-btn:hover {
    border-color: var(--brand-red);
    color: #fff;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: 110%;
    right: 0;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    z-index: 100;
    min-width: 180px;
    overflow: hidden;
}

.user-dropdown.open {
    display: block;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    color: #ccc;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s;
}

.user-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.user-dropdown-item svg {
    flex-shrink: 0;
    opacity: 0.6;
}

/* ============================================
   MAIN LAYOUT
   ============================================ */
.main-layout {
    display: grid;
    grid-template-columns: 242px 1fr 242px;
    /* 220 * 1.1 = 242 => 10% bigger */
    gap: 20px;
    flex: 1;
    overflow: hidden;
    padding: 15px 20px;
}

/* ============================================
   PHONE FRAME ADS
   ============================================ */
.ad-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    overflow: hidden;
}

.phone-frame {
    width: 100%;
    max-width: 220px;
    aspect-ratio: 9 / 17;
    max-height: 95%;
    background: #111;
    border-radius: 28px;
    border: 3px solid #333;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35),
        inset 0 0 0 2px #222;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.phone-notch {
    width: 80px;
    height: 6px;
    background: #333;
    border-radius: 3px;
    margin: 8px auto 4px;
    flex-shrink: 0;
}

.phone-screen {
    flex: 1;
    position: relative;
    overflow: hidden;
    margin: 0 4px;
    border-radius: 4px;
}

.carousel-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
}

.carousel-img.active {
    opacity: 1;
}

.phone-swipe-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px 0;
    flex-shrink: 0;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #555;
    transition: background 0.3s;
}

.dot.active {
    background: #fff;
}

/* ============================================
   CENTER CONTENT
   ============================================ */
.center-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.page-title {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 10px;
    flex-shrink: 0;
}

/* ============================================
   CONTROLS BAR (Filters + Sort)
   ============================================ */
.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.filters-group,
.sort-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.controls-bar label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

/* FILTER DROPDOWN */
.filter-dropdown {
    position: relative;
}

.filter-btn {
    background: var(--card-surface);
    border: 1px solid #ddd;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    color: #333;
    transition: all 0.2s;
}

.filter-btn:hover {
    border-color: var(--brand-red);
    color: var(--brand-red);
}

body.dark-theme .filter-btn {
    border-color: #333;
    color: #e0e0e0;
}

body.dark-theme .filter-btn:hover {
    border-color: var(--brand-red);
    color: var(--brand-red);
}

.filter-btn.active-filter {
    background: var(--brand-red);
    color: #fff;
    border-color: var(--brand-red);
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 110%;
    left: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 50;
    min-width: 140px;
    max-height: 200px;
    overflow-y: auto;
}

.dropdown-menu.open {
    display: block;
}

.dropdown-item {
    padding: 8px 14px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.dropdown-item:hover {
    background: #f5f5f5;
}

.dropdown-item.selected {
    background: #fdeaea;
    color: var(--brand-red);
    font-weight: 700;
}

body.dark-theme .dropdown-menu {
    background: #1a1a1a;
    border-color: #333;
}

body.dark-theme .dropdown-item {
    color: #f0f0f0;
}

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

body.dark-theme .dropdown-item.selected {
    background: rgba(234, 118, 0, 0.2);
    color: var(--brand-red);
}

/* CLEAR BUTTON */
.clear-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 0.7rem;
    cursor: pointer;
    padding: 5px 8px;
    font-weight: 600;
    transition: color 0.2s;
}

.clear-btn:hover {
    color: var(--brand-red);
}

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

body.dark-theme .clear-btn:hover {
    color: var(--brand-red);
}

/* SEARCH INPUT */
.search-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-wrapper {
    position: relative;
}

.search-input {
    background: var(--card-surface);
    border: 1px solid #ddd;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #333;
    width: 220px;
    outline: none;
    transition: border-color 0.2s;
    font-family: var(--font);
}

.search-input:focus {
    border-color: var(--brand-red);
}

.search-input::placeholder {
    color: #aaa;
}

body.dark-theme .search-input {
    background-color: #1a1a1a;
    color: #fff;
    border-color: #333;
}

body.dark-theme .search-input:focus {
    border-color: var(--brand-red);
}

.search-suggestions {
    display: none;
    position: absolute;
    top: 110%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 60;
    max-height: 200px;
    overflow-y: auto;
}

.search-suggestions.open {
    display: block;
}

.suggestion-item {
    padding: 8px 14px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-item:hover {
    background: #f5f5f5;
}

body.dark-theme .search-suggestions {
    background: #1a1a1a;
    border-color: #333;
}

body.dark-theme .suggestion-item {
    color: #f0f0f0;
}

body.dark-theme .suggestion-item mark {
    background: rgba(234, 118, 0, 0.2);
    /* Brand red tint for highlighting */
    color: var(--brand-red);
}

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

.suggestion-item mark {
    background: #fdeaea;
    color: var(--brand-red);
    font-weight: 700;
    border-radius: 2px;
    padding: 0 1px;
}

/* ============================================
   TABLE HEADER
   ============================================ */
.table-header {
    background-color: var(--table-header-bg);
    color: var(--table-header-text);
    display: grid;
    grid-template-columns: 40px 80px 55px 1fr 40px 50px 60px 55px 85px;
    flex-shrink: 0;
    gap: 4px;
}

.data-table th {
    background: var(--table-header-bg);
    color: var(--table-header-text);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-subtle);
}

.th {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.th.sortable:hover {
    color: #ffcccc;
}

.th.sortable.active-sort {
    color: var(--brand-red);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.sort-arrow {
    font-size: 0.6rem;
    opacity: 0.5;
}

.th.sortable.active-sort .sort-arrow {
    opacity: 1;
}

.th.clientes,
.th.tkts,
.th.importe {
    text-align: right;
}

/* ============================================
   SCROLLABLE LIST
   ============================================ */
.ranking-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
}

.ranking-list::-webkit-scrollbar {
    display: none;
}

/* ============================================
   STORE ROW
   ============================================ */
.store-row {
    background-color: var(--card-surface);
    display: grid;
    grid-template-columns: 40px 80px 55px 1fr 40px 50px 60px 55px 85px;
    padding: 12px 14px;
    border-bottom: 1px solid #f0f0f0;
    align-items: center;
    transition: background-color 0.2s;
    gap: 4px;
}

.store-row:last-child {
    border-bottom: none;
    border-radius: 0 0 var(--radius) var(--radius);
}

.store-row:hover {
    background-color: rgba(234, 118, 0, 0.04);
    border-left: 3px solid var(--brand-red);
    padding-left: 11px;
}

body.dark-theme .store-row {
    border-bottom-color: #222;
}

body.dark-theme .store-row:hover {
    background-color: rgba(234, 118, 0, 0.08);
    border-left: 3px solid var(--brand-red);
    padding-left: 11px;
}

/* Cell styles */
.cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.78rem;
}

.cell.rank-num {
    font-weight: 800;
    font-size: 0.95rem;
    color: #333;
}

.store-row.top-1 .cell.rank-num {
    font-size: 1.8rem;
}

.store-row.top-1 {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.08) 0%, transparent 60%);
    border-left: 3px solid #FFD700;
    padding-left: 11px;
}

.store-row.top-1 .cell.rank-num::before {
    content: '🥇 ';
}

.store-row.top-2 .cell.rank-num {
    font-size: 1.5rem;
}

.store-row.top-2 {
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.08) 0%, transparent 60%);
    border-left: 3px solid #C0C0C0;
    padding-left: 11px;
}

.store-row.top-2 .cell.rank-num::before {
    content: '🥈 ';
}

.store-row.top-3 .cell.rank-num {
    font-size: 1.3rem;
}

.store-row.top-3 {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.08) 0%, transparent 60%);
    border-left: 3px solid #CD7F32;
    padding-left: 11px;
}

.store-row.top-3 .cell.rank-num::before {
    content: '🥉 ';
}

.cell.marca {
    font-weight: 600;
    color: #333;
}

.cell.fqcia {
    font-weight: 500;
    color: #666;
}

.cell.tienda {
    font-weight: 600;
    color: #222;
}

.cell.tipo {
    font-weight: 500;
    color: #888;
    font-size: 0.72rem;
}

.cell.ciudad {
    font-weight: 600;
    color: #555;
    font-size: 0.72rem;
}

.cell.clientes,
.cell.tkts {
    text-align: right;
    font-weight: 600;
    color: #555;
}

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

/* Dark mode overrides for cell text colors */
body.dark-theme .cell.rank-num,
body.dark-theme .cell.marca,
body.dark-theme .cell.tienda {
    color: #e0e0e0;
}

body.dark-theme .cell.fqcia,
body.dark-theme .cell.tipo,
body.dark-theme .cell.ciudad,
body.dark-theme .cell.clientes,
body.dark-theme .cell.tkts {
    color: #999;
}

/* ============================================
   FOOTER
   ============================================ */
.main-footer {
    background-color: var(--header-bg);
    padding: 8px 40px;
    flex-shrink: 0;
    text-align: center;
}

.footer-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.social-label {
    color: #aaa;
    font-size: 0.7rem;
    font-weight: 500;
}

.social-icons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.social-icons a {
    display: flex;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.social-icons a:hover {
    opacity: 1;
}

.footer-legal {
    color: #555;
    font-size: 0.5rem;
    border-top: 1px solid #333;
    padding-top: 10px;
}



/* ============================================
   CONFETTI CANVAS
   ============================================ */
.confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* ============================================
   WHATSAPP BUTTON
   ============================================ */
.whatsapp-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: #25D366;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4);
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
}

.whatsapp-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.5);
}

.whatsapp-btn svg {
    width: 30px;
    height: 30px;
    fill: #fff;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .main-layout {
        grid-template-columns: 200px 1fr 200px;
        gap: 10px;
        padding: 10px;
    }

    .table-header,
    .store-row {
        grid-template-columns: 35px 70px 50px 1fr 35px 45px 55px 50px 75px;
        padding: 10px 10px;
    }
}

@media (max-width: 950px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .ad-slot {
        display: none;
    }

    .main-header {
        padding: 0 15px;
    }
}

@media (max-width: 700px) {

    .table-header,
    .store-row {
        grid-template-columns: 35px 70px 1fr 55px 55px 75px;
    }

    .th.fqcia,
    .store-row .cell.fqcia,
    .th.tipo,
    .store-row .cell.tipo,
    .th.ciudad,
    .store-row .cell.ciudad {
        display: none;
    }

    .controls-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .main-nav {
        display: none;
    }
}

@media (max-width: 500px) {

    .table-header {
        display: none;
    }

    .store-row {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "rank tienda"
            "marca importe"
            "metrics metrics";
        gap: 4px 12px;
        padding: 14px 16px;
        border-bottom: 1px solid #eee;
        border-radius: 10px;
        margin-bottom: 8px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    }

    body.dark-theme .store-row {
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
        border-bottom-color: #333;
    }

    .store-row .cell.rank-num {
        grid-area: rank;
        font-size: 1.1rem !important;
    }

    .store-row .cell.tienda {
        grid-area: tienda;
        text-align: right;
        font-size: 0.72rem;
        white-space: normal;
    }

    .store-row .cell.marca {
        grid-area: marca;
        font-size: 0.65rem;
        color: #888;
    }

    .store-row .cell.importe {
        grid-area: importe;
        text-align: right;
        font-size: 0.9rem;
    }

    .store-row .cell.fqcia,
    .store-row .cell.tipo,
    .store-row .cell.ciudad {
        display: none;
    }

    .store-row .cell.clientes,
    .store-row .cell.tkts {
        grid-area: metrics;
        display: inline;
        font-size: 0.65rem;
        text-align: left;
        color: #888;
    }

    .store-row .cell.clientes::before {
        content: 'Clientes: ';
        font-weight: 400;
    }

    .store-row .cell.tkts::before {
        content: ' · Tkts: ';
        font-weight: 400;
    }

    .page-title {
        font-size: 1.3rem;
    }

    .logo {
        font-size: 1.1rem;
    }

    .store-row.top-1,
    .store-row.top-2,
    .store-row.top-3 {
        padding-left: 13px;
    }
}