/* =========================================
   PERFIL.CSS - VERSIÓN FINAL CORREGIDA
   (Iconos en fila única + Espaciado limpio)
   ========================================= */

/* --- 1. BASE Y HEADER TRANSPARENTE --- */
html,
body {
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    font-family: 'Montserrat', sans-serif;
    overflow-x: hidden;
}

/* Barra de Navegación */
.profile-nav-bar {
    background-color: transparent;
    height: 80px;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    padding: 0 30px;
    box-sizing: border-box;
}

/* EN PERFIL.CSS */

/* Actualizamos el contenedor para separar los botones (Izquierda <-> Derecha) */
.nav-container {
    width: 100%;
    display: flex;
    justify-content: space-between; /* CLAVE: Empuja los elementos a los extremos */
    align-items: center;
}

/* Contenedor de botones Admin */
.admin-controls {
    display: flex;
    gap: 15px; /* Espacio entre el escaner y el POS */
}

/* Estilo de los botones redondos */
.btn-admin {
    width: 45px;
    height: 45px;
    background-color: #ffffff; /* Fondo blanco para contraste alto */
    color: #5e1c26; /* Color vino para el ícono */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); /* Sombra para que "floten" */
    transition:
        transform 0.2s ease,
        background 0.2s;
}

.btn-admin:hover {
    transform: scale(1.1);
    background-color: #fffac2; /* Color crema al pasar el mouse */
    color: #d35400;
}

/* Opcional: Ocultar texto "Volver" en móviles muy pequeños para dar espacio */
@media (max-width: 400px) {
    .hide-mobile {
        display: none;
    }
}

/* Botón Volver */
.btn-back-home {
    background-color: #fffac2;
    color: #5e1c26;
    padding: 10px 25px;
    border-radius: 50px;
    font-weight: 800;
    text-decoration: none;
    font-size: 14px;
    box-shadow: 0 4px 10px rgba(94, 28, 38, 0.15);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.btn-back-home:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(94, 28, 38, 0.25);
    background-color: #fff;
}

/* Ocultar elementos viejos */
.nav-user,
.cart-icon {
    display: none !important;
}

/* --- 2. LAYOUT GENERAL --- */
.profile-layout {
    max-width: 1100px;
    margin: 120px auto 40px auto;
    padding: 0 20px;
}

.profile-header-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
}

/* Portada */
.profile-cover {
    height: 180px;
    background: linear-gradient(135deg, #5e1c26 0%, #3a0e15 100%);
    position: relative;
    z-index: 1;
}
.profile-cover::after {
    content: '🧀';
    font-size: 40px;
    position: absolute;
    top: 20px;
    right: 40px;
    opacity: 0.05;
    color: white;
}

/* Contenedor Info */
.profile-content-wrapper {
    display: flex;
    align-items: flex-end;
    padding: 0 50px 30px 50px;
    margin-top: -80px;
    gap: 30px;
    position: relative;
    z-index: 10;
}

/* FOTO */
.profile-pic-area {
    flex-shrink: 0;
    position: relative;
    z-index: 20;
}
.profile-pic-wrapper {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: 6px solid white;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    background: #fff;
    cursor: pointer;
    overflow: hidden;
    position: relative;
}
.profile-pic-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.edit-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    opacity: 0;
    transition: 0.3s;
}
.profile-pic-wrapper:hover .edit-overlay {
    opacity: 1;
}

.profile-text-area {
    flex: 1;
    padding-bottom: 10px;
    /* Alineación estricta a la izquierda en PC */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end; /* Pegado abajo alineado con la foto */
}

.profile-text-area h1 {
    font-size: 32px;
    font-weight: 800;
    margin: 40px 0 5px 0;
    color: #fffac2; /* CAMBIO: Gris oscuro (ya no es color Vino) */
    line-height: 1.1;
    text-align: left;
}

.user-badge {
    background: #5e1c26;
    color: #fffac2;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: inline-block;
    margin-bottom: 15px;
    margin-top: 5px;
    /* Asegurar que no tenga márgenes extraños */
    margin-left: 0;
}

/* 2. BARRA EXP (Corrección para que no se peguen los textos) */
/* Contenedor Principal */
.exp-bar-container {
    max-width: 320px;
    width: 100%; /* Ocupar espacio disponible */
    margin-top: 15px;
    /* Aseguramos que se vea en móvil y escritorio */
    display: block;
}

/* Info (Texto Nivel y Puntos) */
.exp-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 11px;
    font-weight: 700;
    color: #888;
    margin-bottom: 8px; /* Espacio antes de la barra */
}

/* EL RIEL (Fondo Gris) - Esto es lo que faltaba */
.progress-track {
    width: 100%;
    height: 10px; /* Altura visible */
    background: #eeeeee;
    border-radius: 10px;
    overflow: hidden;
    position: relative; /* Para asegurar posición */
}

/* EL RELLENO (Amarillo) */
.progress-fill {
    height: 100%;
    background: #f1c40f;
    border-radius: 10px;
    width: 0%; /* JS lo cambiará */
    transition: width 1s ease-out; /* Animación suave */
    display: block;
}

/* Mensaje inferior */
#nextLevelMessage {
    font-size: 11px;
    color: #999;
    margin-top: 6px;
    display: block;
}
/* MONEDERO Y ACCIONES */
.profile-wallet-area {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 15px;
    padding-bottom: 10px;
    position: relative;
    z-index: 50;
}

.wallet-badge {
    background: white;
    border: 1px solid #eee;
    padding: 12px 25px;
    border-radius: 15px;
    text-align: right;
    min-width: 140px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}
.wallet-badge small {
    display: block;
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
    font-weight: 700;
}
.balance-display {
    font-size: 26px;
    font-weight: 800;
    color: #5e1c26;
    margin-top: 2px;
}

/* Botones Settings / Logout */
.profile-actions {
    display: flex;
    gap: 10px;
    pointer-events: auto;
}
.btn-settings {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: #f4f4f4;
    color: #5e1c26;
    cursor: pointer;
    font-size: 18px;
    transition: 0.2s;
    /* Centrado de iconos FontAwesome */
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.btn-settings:hover {
    background: #e0e0e0;
    transform: scale(1.1);
}
.btn-logout {
    background: #ffebee;
    color: #d32f2f;
}
.btn-logout:hover {
    background: #ffcdd2;
}

/* --- 3. PESTAÑAS (TABS) --- */
.tabs-container {
    background: white;
    border-radius: 16px;
    padding: 10px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    margin-bottom: 25px;
    overflow: visible; /* Importante para que no corte sombras */
}

/* Estilo Base (Escritorio) */
.profile-tabs {
    display: flex;
    justify-content: center; /* Centrado en escritorio */
    gap: 15px;
    overflow-x: auto;
    padding: 0 20px;
    padding-bottom: 5px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.profile-tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.tab-btn:hover {
    background: #f9f9f9;
    color: #5e1c26;
}
.tab-btn.active {
    background: #5e1c26;
    color: #fffac2;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(94, 28, 38, 0.2);
    transform: translateY(-1px);
}
.tab-icon {
    font-size: 16px;
    line-height: 1;
}

/* --- 4. DIRECCIONES --- */
.address-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 15px;
}
.address-card {
    background: white;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 20px;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    transition: 0.2s;
}
.address-card:hover {
    border-color: #5e1c26;
}
.address-card button {
    position: absolute;
    top: 10px;
    right: 10px;
    border: none;
    background: none;
    color: #d32f2f;
    font-weight: bold;
    cursor: pointer;
    font-size: 18px;
}
.address-card.add-new {
    border: 2px dashed #ddd;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    cursor: pointer;
    min-height: 100px;
}
.address-card.add-new:hover {
    border-color: #5e1c26;
    color: #5e1c26;
    background: #fffdf5;
}
.address-card.add-new span {
    font-size: 30px;
}

/* --- 5. PANELES Y CONTENIDO --- */
.panel {
    display: none;
    animation: fadeIn 0.4s ease;
}
.panel.active {
    display: block;
}
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Lealtad */
.loyalty-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 25px;
    align-items: stretch;
}
.dashboard-card {
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    border: 1px solid #f0f0f0;
}
.qr-card {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ffffff 0%, #f9f9f9 100%);
    order: 2;
}
.qr-card h3 {
    color: #5e1c26;
    margin: 0 0 5px 0;
    font-size: 20px;
}
.qr-placeholder img {
    width: 180px;
    height: 180px;
    border-radius: 15px;
    border: 4px solid #5e1c26;
    padding: 10px;
    background: white;
    margin: 20px 0;
}
.ref-code-mini {
    font-family: 'Courier New', monospace;
    background: #eee;
    padding: 8px 15px;
    border-radius: 8px;
    color: #333;
    font-weight: 800;
    font-size: 14px;
}
.stamp-card-container {
    order: 1;
}
.stamp-card-container h3 {
    margin: 0;
    color: #5e1c26;
    font-size: 22px;
}
.stamp-counter {
    background: #5e1c26;
    color: #fffac2;
    padding: 5px 15px;
    border-radius: 15px;
    font-weight: 800;
    font-size: 14px;
}
.stamps-grid-8 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    background: #fffdf5;
    padding: 30px;
    border-radius: 20px;
    border: 2px dashed #f0e6d2;
    margin-top: 25px;
}
.stamp {
    aspect-ratio: 1/1;
    border-radius: 50%;
    background: white;
    border: 4px solid #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: #ddd;
}
.stamp.filled {
    border-color: #f1c40f;
    background: #fffde7;
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(241, 196, 15, 0.3);
    color: #333;
}
.stamp.gift {
    border-color: #d35400;
    color: #d35400;
    font-size: 40px;
}

/* Cupones */
.coupons-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}
.coupon-ticket {
    background: #fff;
    border: 2px dashed #5e1c26;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: transform 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}
.coupon-ticket:hover {
    transform: translateY(-5px);
}
.coupon-ticket::before,
.coupon-ticket::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 24px;
    height: 24px;
    background: #f4f4f4;
    border-radius: 50%;
    transform: translateY(-50%);
    z-index: 2;
}
.coupon-ticket::before {
    left: -14px;
    border-right: 2px dashed #5e1c26;
}
.coupon-ticket::after {
    right: -14px;
    border-left: 2px dashed #5e1c26;
}
.coupon-header {
    background: #5e1c26;
    color: #fffac2;
    padding: 15px;
    text-align: center;
    border-bottom: 2px dashed #fff;
}
.coupon-header h4 {
    margin: 0;
}
.coupon-body {
    padding: 25px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    flex: 1;
}
.coupon-code {
    font-family: 'Courier New', monospace;
    font-size: 20px;
    font-weight: 800;
    color: #333;
    background: #f0f0f0;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px dashed #ccc;
}

/* Historial */
.orders-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.order-card {
    background: white;
    border: 1px solid #eee;
    border-radius: 16px;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}
.order-card:hover {
    transform: translateY(-3px);
    border-color: #5e1c26;
}
.order-id {
    font-weight: 800;
    font-size: 16px;
    color: #333;
}
.order-highlight {
    font-size: 14px;
    color: #666;
}
.order-price {
    font-weight: 800;
    color: #5e1c26;
    font-size: 18px;
}
.order-date {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

/* Referidos y Notis */
.referral-hero {
    background: white;
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid #eee;
}
.referral-hero h3 {
    color: #5e1c26;
    font-size: 28px;
    margin-bottom: 15px;
}
.btn-save {
    background: #5e1c26;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 800;
}
.notifications-container {
    background: white;
    border-radius: 20px;
    padding: 25px;
    border: 1px solid #eee;
}
.noti-toolbar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}
.noti-card {
    display: flex;
    gap: 20px;
    padding: 20px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #eee;
    align-items: flex-start;
    margin-bottom: 10px;
}
.noti-card.unread {
    background: #fffdf5;
    border-left: 5px solid #f1c40f;
}
.noti-icon-box {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
/* EN PERFIL.CSS - AGREGAR AL FINAL O EN SECCIÓN NOTIS */

/* 1. Puntito Rojo en Pestaña */
.tab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    background-color: #d32f2f; /* Rojo alerta */
    border-radius: 50%;
    border: 2px solid white; /* Borde blanco para separar */
    z-index: 10;
}

/* 2. Botón de Borrar (Basurero) */
.btn-icon-clear {
    background: #fff;
    border: 1px solid #eee;
    color: #999;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon-clear:hover {
    background: #ffebee;
    color: #d32f2f;
    border-color: #ffcdd2;
    transform: scale(1.05);
}

/* --- RESPONSIVE (MÓVIL) --- */
@media (max-width: 900px) {
    /* Header Móvil */
    header {
        top: 20px;
    }

    /* Layout Móvil */
    .profile-cover {
        height: 140px;
    }
    .profile-content-wrapper {
        flex-direction: column;
        align-items: center;
        text-align: center;
        margin-top: -70px;
    }

    .profile-pic-area {
        margin-bottom: 15px;
    }
    .profile-text-area {
        width: 100%;
        align-items: center; /* Centrado horizontal */
        text-align: center;
    }

    .profile-text-area h1 {
        color: #5e1c26;
        text-align: center;
    }

    /* En móvil la barra puede ser un poco más ancha si quieres */
    .exp-bar-container {
        max-width: 100%;
        padding: 0 20px; /* Margen de seguridad lateral */
        box-sizing: border-box;
    }

    .profile-wallet-area {
        align-items: center;
        width: 100%;
        border-top: 1px solid #eee;
        padding-top: 20px;
        gap: 15px;
    }
    .wallet-badge {
        text-align: center;
        box-shadow: none;
        border: 1px solid #eee;
    }

    /* PESTAÑAS MÓVIL (CORREGIDO: Fila Única y Espaciadas) */
    .profile-tabs {
        flex-wrap: nowrap !important; /* Prohibido bajar de línea */
        justify-content: space-between; /* Distribución uniforme */
        gap: 5px;
        padding: 10px 30px;
        width: 100%;
        margin: 0;
    }

    .tab-btn {
        flex: 0 0 auto; /* No estirar */
        width: 48px; /* Ancho controlado para que quepan 6 */
        height: 45px;
        padding: 0;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .tab-label {
        display: none;
    } /* Ocultar texto */
    .tab-icon {
        font-size: 22px;
        margin: 0;
    } /* Icono grande */

    /* Lealtad Móvil */
    .loyalty-grid {
        grid-template-columns: 1fr;
    }
    .qr-card {
        order: 1;
    }
    .stamp-card-container {
        order: 2;
    }
    .stamps-grid-8 {
        grid-template-columns: repeat(4, 1fr);
        padding: 15px;
        gap: 10px;
    }
    .stamp {
        font-size: 20px;
    }
}

@media (min-width: 901px) {
    .loyalty-grid {
        grid-template-columns: 1fr 350px;
    }
    .qr-card {
        order: 2;
    }
    .stamp-card-container {
        order: 1;
    }
}

/* Modal Settings */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
}
.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}
.modal-content-settings {
    background: white;
    width: 90%;
    max-width: 450px;
    padding: 30px;
    border-radius: 16px;
    transform: translateY(20px);
    transition: 0.3s;
}
.modal-overlay.show .modal-content-settings {
    transform: translateY(0);
}
.close-modal {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    float: right;
    color: #999;
}
.input-gray {
    width: 100%;
    padding: 12px;
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 15px;
    box-sizing: border-box;
}
