/**
 * Credits Purchase Modal
 * Compact, beautiful modal for purchasing AI credits
 */

/* Modal Overlay */
.credits-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.credits-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal Container */
.credits-modal {
    background: rgba(15, 12, 10, 0.95);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(242, 207, 123, 0.2);
    border-radius: 24px;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.8),
        0 0 0 1px rgba(242, 207, 123, 0.1),
        0 0 80px rgba(242, 207, 123, 0.15);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.credits-modal-overlay.active .credits-modal {
    transform: scale(1) translateY(0);
}

/* Close Button */
.credits-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(196, 181, 160, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.credits-modal-close:hover {
    background: rgba(242, 207, 123, 0.1);
    border-color: rgba(242, 207, 123, 0.3);
    color: #f2cf7b;
    transform: rotate(90deg);
}

/* Modal Header */
.credits-modal-header {
    padding: 32px 32px 24px;
    border-bottom: 1px solid rgba(242, 207, 123, 0.1);
    position: relative;
}

.credits-modal-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.credits-modal-title-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(168, 85, 247, 0.15));
    border: 1px solid rgba(139, 92, 246, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c084fc;
}

.credits-modal-title h2 {
    font-size: 24px;
    font-weight: 800;
    color: #f4f1ea;
    margin: 0;
    letter-spacing: -0.5px;
}

.credits-modal-subtitle {
    color: rgba(196, 181, 160, 0.7);
    font-size: 14px;
    margin-top: 4px;
    margin-left: 52px;
}

.credits-modal-requirement {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0 0 52px;
    padding: 10px 12px;
    background: linear-gradient(135deg, rgba(255, 183, 94, 0.1), rgba(255, 140, 66, 0.08));
    border: 1px solid rgba(255, 183, 94, 0.25);
    border-radius: 12px;
    color: #ffd9a0;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.credits-modal-requirement::before {
    content: '⚡';
    display: inline-flex;
    width: 26px;
    height: 26px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255, 183, 94, 0.18);
    color: #ffd38a;
    font-size: 14px;
}

/* Current Balance Display */
.credits-modal-balance {
    margin-top: 20px;
    padding: 16px;
    background: rgba(168, 107, 62, 0.08);
    border: 1px solid rgba(168, 107, 62, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.credits-modal-balance-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.credits-modal-balance-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(139, 92, 246, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c084fc;
}

.credits-modal-balance-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.credits-modal-balance-label {
    font-size: 11px;
    color: rgba(196, 181, 160, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.credits-modal-balance-amount {
    font-size: 20px;
    font-weight: 800;
    color: #f2cf7b;
    letter-spacing: -0.5px;
}

.credits-modal-balance-note {
    font-size: 13px;
    color: #fca5a5;
    font-weight: 600;
    max-width: 240px;
    text-align: right;
    line-height: 1.3;
}

/* Modal Body */
.credits-modal-body {
    padding: 24px 32px 32px;
    overflow-y: auto;
    flex: 1;
}

/* Packages Grid */
.credits-modal-packages {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 8px;
}

/* Package Card */
.credits-modal-package {
    background: rgba(20, 18, 16, 0.6);
    border: 1.5px solid rgba(168, 107, 62, 0.2);
    border-radius: 16px;
    padding: 20px;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.credits-modal-package:hover {
    border-color: rgba(242, 207, 123, 0.4);
    background: rgba(25, 22, 18, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.credits-modal-package.featured {
    border-color: rgba(139, 92, 246, 0.5);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(168, 85, 247, 0.08));
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.2);
}

/* Package badges (Best Value, Savings) */
.credits-modal-package-badge,
.credits-modal-package-savings {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 6px;
    z-index: 2;
}

.credits-modal-package-badge {
    background: linear-gradient(135deg, #8b5cf6, #a855f7);
    color: white;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}

.credits-modal-package-savings {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.credits-modal-package-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.credits-modal-package-name {
    font-size: 16px;
    font-weight: 700;
    color: #f4f1ea;
    margin: 0;
}

.credits-modal-package-price {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.credits-modal-package-price-main {
    font-size: 24px;
    font-weight: 800;
    color: #f2cf7b;
    letter-spacing: -0.5px;
    line-height: 1;
}

.credits-modal-package-price-onetime {
    font-size: 11px;
    color: #f2cf7b;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.credits-modal-package-price-per {
    font-size: 11px;
    color: rgba(196, 181, 160, 0.6);
    font-weight: 600;
}

.credits-modal-package-features {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.credits-modal-package-feature {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: rgba(196, 181, 160, 0.8);
}

.credits-modal-package-feature svg {
    width: 14px;
    height: 14px;
    stroke: rgba(139, 92, 246, 0.6);
    flex-shrink: 0;
}

.credits-modal-package-feature strong {
    color: #f2cf7b;
    font-weight: 700;
}

.credits-modal-package-button {
    margin-top: auto;
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(242, 207, 123, 0.15), rgba(168, 107, 62, 0.15));
    border: 1px solid rgba(242, 207, 123, 0.3);
    border-radius: 10px;
    color: #f2cf7b;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.credits-modal-package:hover .credits-modal-package-button,
.credits-modal-package-button:hover {
    background: linear-gradient(135deg, rgba(242, 207, 123, 0.25), rgba(168, 107, 62, 0.25));
    border-color: rgba(242, 207, 123, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(242, 207, 123, 0.2);
}

.credits-modal-package.featured .credits-modal-package-button {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(168, 85, 247, 0.2));
    border-color: rgba(139, 92, 246, 0.4);
    color: #c084fc;
}

.credits-modal-package.featured .credits-modal-package-button:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(168, 85, 247, 0.3));
    border-color: rgba(139, 92, 246, 0.6);
}

/* Loading State */
.credits-modal-loading {
    text-align: center;
    padding: 60px 20px;
    color: rgba(196, 181, 160, 0.6);
}

.credits-modal-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(242, 207, 123, 0.2);
    border-top-color: #f2cf7b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error State */
.credits-modal-error {
    text-align: center;
    padding: 60px 20px;
    color: rgba(239, 68, 68, 0.8);
}

.credits-modal-error svg {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    opacity: 0.6;
}

/* Info Note */
.credits-modal-note {
    margin-top: 24px;
    padding: 16px;
    background: rgba(168, 107, 62, 0.08);
    border: 1px solid rgba(168, 107, 62, 0.2);
    border-radius: 12px;
    display: flex;
    gap: 12px;
    align-items: start;
}

.credits-modal-note-icon {
    width: 20px;
    height: 20px;
    color: #f2cf7b;
    flex-shrink: 0;
    margin-top: 2px;
}

.credits-modal-note-text {
    font-size: 12px;
    color: rgba(196, 181, 160, 0.8);
    line-height: 1.5;
}

.credits-modal-note-text strong {
    color: #f2cf7b;
    display: block;
    margin-bottom: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .credits-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
    
    .credits-modal {
        max-width: 100%;
        max-height: 90vh;
        border-radius: 24px 24px 0 0;
        transform: translateY(100%);
    }
    
    .credits-modal-overlay.active .credits-modal {
        transform: translateY(0);
    }
    
    .credits-modal-header {
        padding: 20px 16px 12px;
    }
    
    .credits-modal-title {
        gap: 8px;
        margin-bottom: 4px;
    }

    .credits-modal-title h2 {
        font-size: 18px;
    }
    
    .credits-modal-subtitle,
    .credits-modal-requirement {
        margin-left: 0;
    }
    
    .credits-modal-title-icon {
        width: 28px;
        height: 28px;
        border-radius: 8px;
    }

    .credits-modal-title-icon svg {
        width: 16px;
        height: 16px;
    }
    
    .credits-modal-body {
        padding: 20px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
    
    .credits-modal-packages {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .credits-modal-package {
        padding: 14px;
        gap: 10px;
    }

    .credits-modal-package-price-main {
        font-size: 20px;
    }

    .credits-modal-package-name {
        font-size: 15px;
    }

    .credits-modal-package-feature {
        font-size: 12px;
    }

    .credits-modal-package-button {
        padding: 10px;
        font-size: 13px;
    }

    .credits-modal-close {
        top: 16px;
        right: 16px;
    }

    /* Mobile Balance Section Improvements */
    .credits-modal-balance {
        margin-top: 12px;
        padding: 10px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .credits-modal-balance-info {
        justify-content: center;
        gap: 8px;
    }

    .credits-modal-balance-icon {
        width: 24px;
        height: 24px;
    }

    .credits-modal-balance-icon svg {
        width: 14px;
        height: 14px;
    }

    .credits-modal-balance-label {
        font-size: 10px;
    }

    .credits-modal-balance-amount {
        font-size: 16px;
    }

    .credits-modal-balance-note {
        max-width: 100%;
        text-align: center;
        font-size: 11px;
        padding: 6px 10px;
        background: rgba(252, 165, 165, 0.08);
        border-radius: 8px;
        border: 1px solid rgba(252, 165, 165, 0.15);
        line-height: 1.4;
    }
}

