/**
 * Centro Punti Popup - Mobile First CSS
 * Clanto Tessera Fedelta
 */

/* ===== OVERLAY & BASE POPUP ===== */
.clantopf-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.clantopf-popup {
    width: 95%;
    height: 95vh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* ===== HEADER ===== */
.clantopf-popup-header {
    background: var(--clantopf-color, #0d9488);
    color: #fff;
    padding: 1.25rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.clantopf-popup-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.clantopf-popup-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.clantopf-popup-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== BODY ===== */
.clantopf-popup-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.5rem 1rem;
}

/* Desktop: 2 columns layout */
@media (min-width: 768px) {
    .clantopf-popup-body {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 1.5rem !important;
        padding: 2rem !important;
        align-items: start;
    }
}

/* ===== SECTIONS ===== */
.clantopf-popup-section {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.clantopf-section-title {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #1f2937;
    text-align: center;
}

/* ===== CODES SECTION ===== */
.clantopf-codes-section {
    background: #f9fafb;
}

/* Desktop grid positioning */
@media (min-width: 768px) {
    /* Left column: QR + Wallet */
    .clantopf-codes-section {
        grid-column: 1 !important;
        grid-row: 1 !important;
    }

    /* Right column: Balance + Redeem */
    .clantopf-balance-section {
        grid-column: 2 !important;
        grid-row: 1 !important;
    }

    /* Full width: History */
    .clantopf-history-section {
        grid-column: 1 / -1 !important;
        grid-row: 2 !important;
    }
}

/* Mobile stacking */
@media (max-width: 767px) {
    .clantopf-popup-section {
        margin-bottom: 0;
    }
    
    .clantopf-popup-section:last-child {
        margin-bottom: 0;
    }
}

.clantopf-code-display {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.clantopf-code-item {
    width: 100%;
    max-width: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.clantopf-qr-code,
.clantopf-barcode {
    width: 100%;
    max-width: 250px;
    height: auto;
    background: #fff;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.clantopf-qr-code svg,
.clantopf-qr-code canvas {
    max-width: 100%;
    height: auto;
}

.clantopf-code-label {
    margin: 0;
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

.clantopf-code-text {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    color: #1f2937;
    font-weight: 600;
}

/* ===== BALANCE SECTION ===== */
.clantopf-balance-section {
    background: var(--clantopf-color, #0d9488);
    color: #fff;
    text-align: center;
}

.clantopf-balance-section > * + * {
    margin-top: 1.5rem;
}

.clantopf-balance-hero {
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.clantopf-balance-label {
    font-size: 2rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    opacity: 0.95;
    margin-bottom: 0.75rem;
}

.clantopf-balance-amount {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.clantopf-balance-unit {
    font-size: 1.125rem;
    font-weight: 500;
    opacity: 0.95;
}

.clantopf-balance-value {
    font-size: 1rem;
    font-weight: 500;
    opacity: 0.85;
    margin-top: 0.5rem;
}

.clantopf-user-info {
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.clantopf-user-name {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.clantopf-user-email {
    font-size: 1.4rem;
    font-weight: 400;
    opacity: 0.9;
}

/* ===== CODES SECTION SPACING ===== */
.clantopf-codes-section > * + * {
    margin-top: 1.5rem;
}

.clantopf-code-display .clantopf-card-code {
    font-size: 2rem;
    font-weight: 600;
    color: var(--clantopf-color, #0d9488);
    margin-top: 0;
    margin-bottom: 0;
    letter-spacing: 0.05em;
}

.clantopf-wallet-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

.clantopf-wallet-button {
    width: 100%;
    padding: 0.875rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.clantopf-google-wallet {
    background: #4285f4;
    color: #fff;
}

.clantopf-google-wallet:hover {
    background: #357ae8;
}

.clantopf-apple-wallet {
    background: #000;
    color: #fff;
}

.clantopf-apple-wallet:hover {
    background: #333;
}

/* ===== REDEEM SECTION ===== */
.clantopf-redeem-section {
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.clantopf-collapsible {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.clantopf-collapsible-header {
    padding: 1rem;
    background: #f9fafb;
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    color: #1f2937;
    transition: background 0.2s ease;
}

.clantopf-collapsible-header:hover {
    background: #f3f4f6;
}

.clantopf-collapsible-header::-webkit-details-marker {
    display: none;
}

.clantopf-collapsible-icon {
    transition: transform 0.2s ease;
    font-size: 0.75rem;
}

.clantopf-collapsible[open] .clantopf-collapsible-icon {
    transform: rotate(90deg);
}

.clantopf-collapsible-content {
    padding: 1rem;
    background: #fff;
}

/* ===== HISTORY SECTION ===== */
.clantopf-history-section {
    background: #fff;
}

.clantopf-history-scroll {
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.clantopf-history-scroll::-webkit-scrollbar {
    width: 6px;
}

.clantopf-history-scroll::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 3px;
}

.clantopf-history-scroll::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.clantopf-history-scroll::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ===== TABLET/DESKTOP (768px+) ===== */
@media (min-width: 768px) {
    .clantopf-popup-overlay {
        padding: 2rem;
    }
    
    .clantopf-popup {
        width: 90vw;
        max-width: 900px;
        height: auto;
        max-height: 90vh;
        border-radius: 16px;
    }
    
    .clantopf-history-scroll {
        max-height: 400px;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes clantopf-popup-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes clantopf-popup-slide-up {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.clantopf-popup-overlay {
    animation: clantopf-popup-fade-in 0.2s ease;
}

.clantopf-popup {
    animation: clantopf-popup-slide-up 0.3s ease;
}

@media (min-width: 768px) {
    @keyframes clantopf-popup-scale-in {
        from {
            transform: scale(0.9);
            opacity: 0;
        }
        to {
            transform: scale(1);
            opacity: 1;
        }
    }
    
    .clantopf-popup {
        animation: clantopf-popup-scale-in 0.3s ease;
    }
}
