/* ============================================================
   APP.CSS - Super American Pool PWA
   Estilos tipo aplicación móvil con fondo global, carrusel
   de publicidades corregido y diseño responsive completo
   ============================================================ */

/* ============================================================
   VARIABLES GLOBALES
   ============================================================ */
:root {
    --app-bg: #0f1419;
    --app-surface: #1a2332;
    --app-surface-2: #232d3f;
    --app-border: #2d3748;
    --app-primary: #00a86b;
    --app-primary-dark: #008a58;
    --app-primary-light: #00c97f;
    --app-text: #ffffff;
    --app-text-muted: #a0a8b5;
    --app-danger: #ef4444;
    --app-warning: #f59e0b;
    --app-info: #3b82f6;
    --app-radius: 16px;
    --app-radius-sm: 10px;
    --bottom-nav-height: 70px;
    --top-bar-height: 60px;
}

/* ============================================================
   RESET Y BASE
   ============================================================ */
* {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body.app-body {
    color: var(--app-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    padding-bottom: calc(var(--bottom-nav-height) + 15px);
    padding-top: var(--top-bar-height);
    min-height: 100vh;
    overflow-x: hidden;
    margin: 0;
    
    /* Fondo global: imagen + degradado oscuro */
    background-image: 
        linear-gradient(
            135deg,
            rgba(15, 20, 25, 0.88) 0%,
            rgba(26, 35, 50, 0.82) 50%,
            rgba(15, 20, 25, 0.90) 100%
        ),
        url('../images/fondo_img.jpg');
    background-size: cover, cover;
    background-position: center center, center center;
    background-repeat: no-repeat, no-repeat;
    background-attachment: fixed, fixed;
}

/* ============================================================
   TOP BAR
   ============================================================ */
.app-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--top-bar-height);
    background: rgba(26, 35, 50, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 2px solid var(--app-primary);
    z-index: 1030;
    display: flex;
    align-items: center;
    padding: 0 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.app-topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--app-text);
    font-weight: 700;
    font-size: 1.1rem;
    min-width: 0;
    overflow: hidden;
}

.app-topbar-brand img {
    height: 38px;
    width: auto;
    flex-shrink: 0;
}

.app-topbar-brand span {
    color: var(--app-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-topbar-brand .brand-accent {
    color: var(--app-primary);
}

.app-topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.app-topbar-icon {
    color: var(--app-text);
    font-size: 1.25rem;
    text-decoration: none;
    position: relative;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-topbar-icon:hover {
    color: var(--app-primary);
}

.app-topbar-icon .notif-badge {
    position: absolute;
    top: -5px;
    right: -8px;
    background: var(--app-danger);
    color: white;
    font-size: 0.65rem;
    padding: 2px 5px;
    border-radius: 10px;
    font-weight: 700;
}

/* ============================================================
   WALLET BUTTON EN TOPBAR
   ============================================================ */
.wallet-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,168,107,0.15);
    border: 1px solid rgba(0,168,107,0.4);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--app-text);
    flex-shrink: 0;
}

.wallet-btn:hover {
    background: rgba(0,168,107,0.25);
    border-color: var(--app-primary);
    color: var(--app-primary) !important;
}

.wallet-btn i {
    font-size: 1rem;
    color: var(--app-primary);
}

.wallet-btn .wallet-badge {
    font-weight: 700;
    color: var(--app-primary);
    font-size: 0.8rem;
    white-space: nowrap;
}

@media (max-width: 576px) {
    .wallet-btn {
        padding: 5px 10px;
    }
    .wallet-btn .wallet-badge {
        display: none;
    }
}

/* ============================================================
   BOTTOM NAVIGATION
   ============================================================ */
.app-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: rgba(26, 35, 50, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--app-border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1040;
    padding: 5px 0;
    box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.4);
    padding-bottom: env(safe-area-inset-bottom, 5px);
}

.app-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--app-text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    padding: 8px 4px;
    transition: all 0.2s ease;
    position: relative;
    min-width: 0;
}

.app-nav-item i {
    font-size: 1.35rem;
    margin-bottom: 3px;
    transition: transform 0.2s ease;
}

.app-nav-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.app-nav-item:hover,
.app-nav-item.active {
    color: var(--app-primary);
}

.app-nav-item.active i {
    transform: scale(1.1);
}

.app-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 3px;
    background: var(--app-primary);
    border-radius: 0 0 3px 3px;
}

/* ============================================================
   CARDS TIPO APP
   ============================================================ */
.app-card {
    background: rgba(26, 35, 50, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--app-radius);
    border: 1px solid rgba(45, 55, 72, 0.8);
    padding: 18px;
    margin-bottom: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s, box-shadow 0.2s;
}

.app-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.app-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(45, 55, 72, 0.6);
}

.app-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--app-text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-card-title i {
    color: var(--app-primary);
}

.balance-card {
    background: linear-gradient(
        135deg,
        rgba(26, 35, 50, 0.92) 0%,
        rgba(35, 45, 63, 0.88) 100%
    );
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--app-radius);
    padding: 22px 20px;
    margin-bottom: 15px;
    border: 1px solid rgba(45, 55, 72, 0.8);
    position: relative;
    overflow: hidden;
}

.balance-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0,168,107,0.15) 0%, transparent 70%);
    pointer-events: none;
}

.balance-label {
    font-size: 0.7rem;
    letter-spacing: 2px;
    color: var(--app-text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
    font-weight: 600;
}

.balance-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--app-primary);
    margin-bottom: 5px;
    line-height: 1.1;
}

.balance-sub {
    color: var(--app-text-muted);
    font-size: 0.85rem;
}

/* ============================================================
   BOTONES TIPO APP
   ============================================================ */
.btn-app {
    background: var(--app-primary);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 12px 24px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    cursor: pointer;
}

.btn-app:hover {
    background: var(--app-primary-dark);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(0,168,107,0.3);
}

.btn-app-outline {
    background: transparent;
    color: var(--app-primary);
    border: 2px solid var(--app-primary);
    border-radius: 25px;
    padding: 10px 22px;
    font-weight: 600;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
}

.btn-app-outline:hover {
    background: var(--app-primary);
    color: white;
}

/* ============================================================
   GRID DE APPS
   ============================================================ */
.app-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    padding: 5px 0;
}

.app-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--app-text);
    text-align: center;
    transition: transform 0.2s;
}

.app-grid-item:active {
    transform: scale(0.95);
}

.app-grid-icon {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: white;
    margin-bottom: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    position: relative;
}

.app-grid-icon.bg-brown { background: linear-gradient(135deg, #8b5a2b, #a0522d); }
.app-grid-icon.bg-teal { background: linear-gradient(135deg, #0d7377, #14a0a5); }
.app-grid-icon.bg-green { background: linear-gradient(135deg, #00a86b, #008a58); }
.app-grid-icon.bg-purple { background: linear-gradient(135deg, #6f42c1, #8e44ad); }
.app-grid-icon.bg-red { background: linear-gradient(135deg, #dc3545, #c82333); }
.app-grid-icon.bg-blue { background: linear-gradient(135deg, #0d6efd, #0b5ed7); }
.app-grid-icon.bg-orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.app-grid-icon.bg-darkblue { background: linear-gradient(135deg, #1e3a8a, #1e40af); }
.app-grid-icon.bg-pink { background: linear-gradient(135deg, #ec4899, #db2777); }
.app-grid-icon.bg-cyan { background: linear-gradient(135deg, #06b6d4, #0891b2); }

.app-grid-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--app-text);
    line-height: 1.2;
}

.app-grid-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff6b35;
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

/* ============================================================
   SECCIÓN TÍTULO
   ============================================================ */
.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--app-text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 20px 0 12px 0;
    padding-left: 3px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* ============================================================
   FORMULARIOS TIPO APP
   ============================================================ */
.app-form .form-control,
.app-form .form-select {
    background: rgba(35, 45, 63, 0.9);
    border: 1px solid var(--app-border);
    color: var(--app-text);
    border-radius: var(--app-radius-sm);
    padding: 14px 16px;
    font-size: 1rem;
    transition: all 0.2s;
    width: 100%;
}

.app-form .form-control:focus,
.app-form .form-select:focus {
    background: rgba(35, 45, 63, 1);
    border-color: var(--app-primary);
    color: var(--app-text);
    box-shadow: 0 0 0 0.2rem rgba(0,168,107,0.2);
    outline: none;
}

.app-form .form-control::placeholder {
    color: var(--app-text-muted);
    opacity: 0.7;
}

.app-form .form-label {
    color: var(--app-text);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: block;
}

/* ============================================================
   ALERTAS TIPO APP
   ============================================================ */
.app-alert {
    background: rgba(35, 45, 63, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
    padding: 15px;
    color: var(--app-text);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-alert.success { border-left: 4px solid var(--app-primary); }
.app-alert.danger { border-left: 4px solid var(--app-danger); }
.app-alert.warning { border-left: 4px solid var(--app-warning); }
.app-alert.info { border-left: 4px solid var(--app-info); }

/* ============================================================
   BADGES Y ESTADOS
   ============================================================ */
.app-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.app-badge-success { background: rgba(0,168,107,0.2); color: var(--app-primary-light); }
.app-badge-danger { background: rgba(239,68,68,0.2); color: #fca5a5; }
.app-badge-warning { background: rgba(245,158,11,0.2); color: #fcd34d; }
.app-badge-info { background: rgba(59,130,246,0.2); color: #93c5fd; }
.app-badge-secondary { background: rgba(160,168,181,0.15); color: var(--app-text-muted); }

/* ============================================================
   ✨ CARRUSEL DE PUBLICIDADES — SLIDER CORREGIDO
   Solo se muestra 1 slide a la vez (display: none)
   Altura controlada por aspect-ratio
   ============================================================ */
.promo-carousel {
    position: relative;
    width: 100%;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: 0 15px 40px -10px rgba(0,0,0,0.6);
    background: #0a1a14;
    aspect-ratio: 16 / 6;
    max-height: 480px;
}

/* Slides ocultos por defecto (NO ocupan espacio) */
.promo-slide {
    display: none;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: #0a1a14;
}

/* Solo el slide activo se muestra */
.promo-slide.active {
    display: block;
    animation: promoFadeIn 0.6s ease;
}

@keyframes promoFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Patrón decorativo */
.promo-bg-pattern {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: 
        linear-gradient(135deg, transparent 45%, rgba(0,201,127,0.08) 45%, rgba(0,201,127,0.08) 55%, transparent 55%),
        linear-gradient(45deg, transparent 48%, rgba(0,201,127,0.05) 48%, rgba(0,201,127,0.05) 52%, transparent 52%);
    background-size: 120px 120px, 80px 80px;
    opacity: 0.3;
    z-index: 0;
}

/* Wrapper de la imagen */
.promo-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
}

.promo-image-link {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
}

/* Imagen: se ajusta al contenedor */
.promo-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center;
}

/* Overlay sutil en la parte inferior */
.promo-slide::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        transparent 0%,
        transparent 75%,
        rgba(0, 0, 0, 0.4) 100%
    );
    pointer-events: none;
    z-index: 2;
}

/* Etiqueta PUBLICIDAD */
.promo-ad-label {
    position: absolute;
    bottom: 12px;
    right: 15px;
    font-size: 0.65rem;
    color: rgba(255,255,255,0.85);
    letter-spacing: 2px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 3;
    background: rgba(0,0,0,0.4);
    padding: 4px 10px;
    border-radius: 10px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* Indicadores (dots) */
.promo-dots {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 5;
    background: rgba(0,0,0,0.4);
    padding: 6px 12px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.promo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: all 0.3s;
}

.promo-dot.active {
    background: #00c97f;
    width: 24px;
    border-radius: 4px;
}

/* Flechas de navegación (solo desktop) */
.promo-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.2s;
}

.promo-nav:hover {
    background: rgba(0,168,107,0.9);
    transform: translateY(-50%) scale(1.1);
}

.promo-prev { left: 15px; }
.promo-next { right: 15px; }

@media (min-width: 992px) {
    .promo-nav { display: flex; }
}

/* ============================================================
   RESPONSIVE DEL CARRUSEL
   ============================================================ */
/* Móvil */
@media (max-width: 768px) {
    .promo-carousel {
        aspect-ratio: 16 / 10;
        max-height: 280px;
        border-radius: 14px;
        margin-bottom: 15px;
    }
    
    .promo-dots {
        bottom: 8px;
        padding: 4px 10px;
    }
    
    .promo-dot {
        width: 6px;
        height: 6px;
    }
    
    .promo-dot.active {
        width: 18px;
    }
    
    .promo-ad-label {
        font-size: 0.55rem;
        bottom: 6px;
        right: 8px;
        padding: 3px 7px;
        letter-spacing: 1.5px;
    }
}

/* Móvil muy pequeño */
@media (max-width: 480px) {
    .promo-carousel {
        aspect-ratio: 16 / 11;
        max-height: 240px;
        border-radius: 12px;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 991px) {
    .promo-carousel {
        aspect-ratio: 16 / 7;
        max-height: 380px;
    }
}

/* Desktop grande */
@media (min-width: 1200px) {
    .promo-carousel {
        aspect-ratio: 16 / 6;
        max-height: 500px;
    }
}

/* ============================================================
   RESPONSIVE GENERAL
   ============================================================ */
@media (min-width: 992px) {
    body.app-body {
        padding-bottom: 20px;
        padding-top: 80px;
    }
    
    .app-bottom-nav {
        display: none;
    }
    
    .app-topbar {
        height: 70px;
        padding: 0 30px;
    }
    
    .app-topbar-brand img {
        height: 45px;
    }
    
    .app-container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 20px;
    }
    
    .app-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 20px;
    }
    
    .app-grid-icon {
        width: 70px;
        height: 70px;
        font-size: 1.8rem;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .app-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 991px) {
    body.app-body {
        background-attachment: scroll, scroll;
    }
}

@media (max-width: 360px) {
    .app-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
    
    .app-grid-icon {
        width: 55px;
        height: 55px;
        font-size: 1.4rem;
    }
}

@supports (padding: env(safe-area-inset-bottom)) {
    .app-bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    }
    
    body.app-body {
        padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 15px);
    }
}

.app-body::-webkit-scrollbar {
    width: 5px;
}

.app-body::-webkit-scrollbar-track {
    background: transparent;
}

.app-body::-webkit-scrollbar-thumb {
    background: var(--app-border);
    border-radius: 5px;
}