/* ===== CSS VARIABLES ===== */
:root {
  --primary-blue: #4299e1;
  --primary-blue-dark: #3182ce;
  --primary-orange: #ed8936;
  --primary-orange-dark: #dd7711;
  --bg-light: #f8fafc;
  --card-bg: #ffffff;
  --text-primary: #2d3748;
  --text-secondary: #718096;
  --text-muted: #a0aec0;
  --border-light: #e2e8f0;
  --border-hover: #cbd5e0;
  --success: #48bb78;
  --error: #f56565;
  --shadow-light: 0 4px 6px rgba(0, 0, 0, 0.05);
  --shadow-medium: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* ===== BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.product-container {
    background-color: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 500px;
    padding: 30px;
}

h1 {
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 10px;
    font-weight: 600;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 1rem;
    line-height: 1.5;
}

.youtube-link {
    color: var(--primary-blue);
    text-decoration: none;
    border-bottom: 1px dotted var(--primary-blue);
    padding-bottom: 1px;
    transition: all 0.2s ease;
}

.youtube-link:hover {
    color: var(--primary-blue-dark);
    border-bottom-style: solid;
}

.file-list {
    background-color: #f7fafc;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 10px;
    border: 1px solid var(--border-light);
    max-height: 300px;
    overflow-y: auto;
}

.file-list-title {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.support-prompt {
    text-align: center;
    margin-bottom: 25px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.support-link {
    color: var(--primary-blue);
    text-decoration: none;
    transition: all 0.2s ease;
}

.support-link:hover {
    color: var(--primary-blue-dark);
    text-decoration: underline;
}

.file-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.file-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.file-item:last-child {
    border-bottom: none;
}

.file-name {
    color: #4a5568;
}

.file-size {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.file-item.clickable {
    cursor: pointer;
    padding: 10px 12px;
    margin: 0 -12px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.file-item.clickable:hover {
    background-color: #f0f4f8;
}

.file-item.clickable .file-name {
    color: var(--primary-blue-dark);
    font-weight: 500;
}

.file-item.clickable .file-size {
    color: var(--primary-blue);
}

/* ===== PAYMENT & FORM STYLES ===== */
.payment-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.payment-option {
    border: 2px solid var(--border-light);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    background-color: white;
}

.payment-option.selected {
    border-color: var(--primary-blue);
    background-color: #f0f7ff;
}

.payment-option:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-light);
}

.option-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.option-price {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.option-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.code-section {
    margin-bottom: 25px;
    transition: all 0.3s ease;
    max-height: 200px;
    overflow: hidden;
    opacity: 1;
}

.code-section.hidden {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
}

.code-label {
    display: block;
    margin-bottom: 10px;
    color: #4a5568;
    font-weight: 500;
}

.code-inputs {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.code-input {
    width: 60px;
    height: 60px;
    text-align: center;
    font-size: 1.5rem;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    transition: all 0.2s;
    text-transform: uppercase;
}

.code-input:focus {
    border-color: var(--primary-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
}

.code-input.filled {
    border-color: var(--success);
}

.code-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 5px;
}

/* ===== SINGLE PAYMENT BUTTON STYLES ===== */
.payment-action {
    margin-top: 30px;
    text-align: center;
}

.total-amount {
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.total-label {
    color: var(--text-secondary);
    margin-right: 8px;
}

.amount {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.4rem;
}

.primary-payment-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 18px 30px;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-blue-dark));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-light);
    opacity: 0.5;
    pointer-events: none;
    min-width: 250px;
    justify-content: center;
}

.primary-payment-btn.enabled {
    opacity: 1;
    pointer-events: all;
}

.primary-payment-btn.enabled:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.payment-methods {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.recommended-badge, .supporter-badge {
    color: white;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 20px;
    margin-left: 5px;
    font-weight: 600;
}

.recommended-badge { background-color: var(--primary-blue); }
.supporter-badge { background-color: #9f7aea; }

/* ===== BUTTON STYLES ===== */
.button-container {
    display: flex;
    justify-content: center;
    margin: 20px 0 40px;
}

.button {
    min-width: 200px;
    height: 56px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    font-size: 1.1rem;
    box-shadow: var(--shadow-light);
    border: none;
    color: white;
    user-select: none;
    gap: 8px;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-blue-dark));
    padding: 0 24px;
    position: relative;
    overflow: hidden;
}

.button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.progress-strip {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
}

.progress-fill {
    height: 100%;
    width: 0%;
    transition: width 0.1s linear;
    background: rgba(255, 255, 255, 0.9);
}

.btn-text {
    position: relative;
    z-index: 1;
}

/* ===== POPUP STYLES ===== */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    opacity: 0;
    animation: fadeIn 0.3s ease-out forwards;
}

.popup {
    background: var(--card-bg);
    width: calc(100vw - 40px); /* Mobile: full width with margins */
    max-width: 550px; /* Desktop: wider than product-container (500px) */
    padding: 28px 24px 36px;
    border-radius: 16px;
    overflow-y: visible;
    color: var(--text-primary);
    transform: scale(0.7);
    opacity: 0;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.1s forwards;
    border: 1px solid var(--border-light);
    box-shadow: 0 20px 25px rgba(0, 0, 0, 0.15);
    position: relative;
}

@keyframes fadeIn { to { opacity: 1; } }

@keyframes popIn {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.popup-overlay.closing {
    animation: fadeOut 0.2s ease-in forwards;
}

.popup.closing {
    animation: popOut 0.2s ease-in forwards;
}

@keyframes fadeOut { to { opacity: 0; } }
@keyframes popOut { to { transform: scale(0.8); opacity: 0; } }

.popup-header {
    margin-bottom: 20px;
    text-align: center;
}

.popup-header h2 {
    margin: 0 0 20px 0;
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

.close-popup {
    position: absolute;
    top: -15px;
    right: -15px;
    background: #e53e3e;
    border: none;
    width: 30px;
    height: 30px;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-light);
}

.close-popup:hover {
    background: #c53030;
    transform: scale(1.1);
}

.close-popup::before {
    content: '✕';
    color: white;
    font-size: 16px;
    font-weight: bold;
}

.popup-input-group {
    margin-bottom: 20px;
}

.popup-input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.popup-input-group input {
    width: 100%;
    padding: 16px;
    background-color: #f7fafc;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 1.05rem;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.popup-input-group input:focus {
    border-color: var(--primary-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
    background-color: white;
}

.popup-input-group input[type="text"] {
    text-align: center;
}

.filename-highlight {
    color: var(--text-primary);
    font-weight: 600;
}

/* ===== TEMPLATE-SPECIFIC STYLES ===== */
.processing-message, .success-message {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 10px;
    text-align: center;
}

.error-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    padding: 0 20px 20px;
}

.error-icon-container {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: 8px;
}

.error-text {
    color: var(--text-primary);
    font-size: 1.05rem;
    line-height: 1.5;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .popup {
        width: calc(100vw - 40px); /* Full width with 20px margins on each side */
        max-width: none; /* Override desktop max-width on mobile */
    }
}

@media (max-width: 480px) {
    .product-container { padding: 20px; }
    .payment-options { grid-template-columns: 1fr; }
    .code-input { width: 50px; height: 50px; font-size: 1.2rem; }
    .popup { 
        padding: 20px; 
        border-radius: 12px;
        width: calc(100vw - 30px); /* Slightly smaller margins on very small screens */
    }
    .popup-header h2 { font-size: 1.4rem; margin-bottom: 15px; }
    .popup-input-group input { padding: 14px; font-size: 1rem; }
    .close-popup { top: -10px; right: -10px; width: 25px; height: 25px; }
    .close-popup::before { font-size: 14px; }
    .primary-payment-btn { 
        min-width: 220px; 
        padding: 16px 24px;
        font-size: 1rem;
    }
}

@media (max-width: 360px) {
    body { padding: 10px; }
    .product-container { padding: 15px; }
    .payment-options { gap: 10px; }
    .payment-option { padding: 15px; }
    .code-inputs { gap: 10px; }
    .code-input { width: 45px; height: 45px; }
    .popup {
        width: calc(100vw - 20px); /* Minimal margins on very small screens */
        padding: 15px;
    }
    .primary-payment-btn { 
        min-width: 200px; 
        padding: 14px 20px;
        font-size: 0.95rem;
    }
}