/**
 * eSIM Standalone Purchase Page Styles
 * Updated to match reservation esim-selection component design
 */

/* Page Container */
.esim-page {
    padding: 40px 0 80px;
    background: linear-gradient(135deg, #f0f7ff 0%, #f5f3ff 100%);
    min-height: 100vh;
}

/* Header */
.esim-header {
    text-align: center;
    margin-bottom: 40px;
}

.esim-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 12px;
}

.esim-subtitle {
    font-size: 1.125rem;
    color: #666;
    margin: 0;
}

/* Country Selector */
.esim-country-selector {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
}

/* Dropdown Container */
.country-dropdown {
    position: relative;
    width: 100%;
    max-width: 400px;
}

/* Dropdown Trigger Button */
.country-dropdown__trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    text-align: left;
    box-sizing: border-box;
}

.country-dropdown__trigger:hover {
    border-color: #ffc107;
}

.country-dropdown.is-open .country-dropdown__trigger {
    border-color: #ffc107;
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.15);
}

.country-dropdown__flag {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.country-dropdown__name {
    font-weight: 600;
    flex: 1;
}

.country-dropdown__arrow {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    color: #999;
}

.country-dropdown.is-open .country-dropdown__arrow svg {
    transform: rotate(180deg);
}

/* Dropdown Menu */
.country-dropdown__menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    max-height: 360px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Search Input */
.country-dropdown__search-wrapper {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.country-dropdown__search {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    box-sizing: border-box;
}

.country-dropdown__search:focus {
    border-color: #ffc107;
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.1);
}

.country-dropdown__search::placeholder {
    color: #aaa;
}

/* Country List */
.country-dropdown__list {
    overflow-y: auto;
    max-height: 280px;
    padding: 4px 0;
}

/* Country Option */
.country-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.95rem;
    text-align: left;
    box-sizing: border-box;
}

.country-option:hover {
    background: #fffbeb;
}

.country-option--active {
    background: #fff8e1;
    font-weight: 600;
}

.country-option__flag {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.country-option__name {
    flex: 1;
    color: #333;
}

/* Empty State */
.country-dropdown__empty {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 0.9rem;
}

/* Main Content - Single Column */
.esim-content {
    max-width: 900px;
    margin: 0 auto;
}

/* Section Header (matching reservation style) */
.esim-section-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.esim-section-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: #ffc107;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #212529;
}

.esim-section-title {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 4px 0;
}

.esim-section-subtitle {
    font-size: 14px;
    color: #64748b;
    margin: 0;
}

/* Tabs Container */
.esim-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

/* Tab Button (Pill Style) */
.esim-tab {
    padding: 8px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 20px;
    background: white;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
}

.esim-tab:hover {
    border-color: #ffc107;
    color: #1e293b;
}

.esim-tab.active {
    background: #ffc107;
    border-color: #ffc107;
    color: #212529;
}

/* Section Titles */
.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 20px;
}

/* Packages Section */
.esim-packages-section {
    background: white;
    border: 1px solid #e0e7ff;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 32px;
}

/* Loading State */
.esim-packages-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #666;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid #f0f0f0;
    border-top-color: #ffc107;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

/* Error State */
.esim-packages-error {
    text-align: center;
    padding: 60px 20px;
    background: #fef2f2;
    border-radius: 12px;
}

.error-message {
    color: #991b1b;
    margin-bottom: 20px;
}

.retry-btn {
    background: #fee2e2;
    color: #991b1b;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.retry-btn:hover {
    background: #fecaca;
}

/* Packages Grid */
.esim-packages-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

/* Package Card - Matching reservation style */
.esim-package-card {
    display: block;
    cursor: pointer;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 36px;
    position: relative;
    transition: all 0.2s;
    text-align: center;
    box-sizing: border-box;
    min-width: 0;
}

.esim-package-card:hover {
    border-color: #ffc107;
}

.esim-package-card.selected {
    border-color: #ffc107;
    background: #fffbeb;
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.2);
}

/* Hide radio input */
.esim-package-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Selection indicator (radio circle) */
.esim-package-card::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    transition: all 0.2s;
}

.esim-package-card.selected::after {
    border-color: #ffc107;
    background: #ffc107;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23212529' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 12px;
}

/* Card Content */
.esim-card-content {
    padding-top: 12px;
}

.esim-package-data {
    font-size: 24px;
    font-weight: 700;
    color: #0c4a6e;
    line-height: 1.2;
    margin-bottom: 4px;
}

.esim-package-validity {
    font-size: 15px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 20px;
}

.esim-package-operator {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 12px;
}

.esim-package-price {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 3px;
}

.esim-price-amount {
    font-size: 20px;
    font-weight: 700;
    color: #0c4a6e;
}

.esim-price-currency {
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}

/* No Packages */
.no-packages {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    grid-column: 1 / -1;
}

/* Info Note */
.esim-info-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 16px;
    padding: 12px;
    background: rgba(255, 193, 7, 0.1);
    border-radius: 8px;
    font-size: 13px;
    color: #92400e;
}

.esim-info-note svg {
    flex-shrink: 0;
    margin-top: 1px;
}

/* Form Section */
.esim-form-section {
    /* No sticky positioning - full width in single column layout */
}

.esim-form-card {
    background: #fff;
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

/* Form Row - Two columns on desktop */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Form Styles */
.esim-form .form-group {
    margin-bottom: 20px;
}

.esim-form .form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
}

.esim-form .required {
    color: #dc3545;
}

.esim-form .form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 1.5px solid #e0e0e0;
    border-radius: 10px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.esim-form .form-control:focus {
    outline: none;
    border-color: #ffc107;
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.1);
}

.esim-form .form-control.is-invalid {
    border-color: #dc3545;
}

.esim-form .invalid-feedback {
    display: none;
    font-size: 0.8rem;
    color: #dc3545;
    margin-top: 6px;
}

.esim-form .form-control.is-invalid + .invalid-feedback {
    display: block;
}

.esim-form .form-hint {
    font-size: 0.8rem;
    color: #888;
    margin-top: 6px;
}

/* Phone Input Override */
.esim-form .iti {
    width: 100%;
}

.esim-form .iti__selected-flag {
    border-radius: 10px 0 0 10px;
}

/* Checkbox */
.esim-form .form-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.esim-form .form-check-input {
    width: 20px;
    height: 20px;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #ffc107;
}

.esim-form .form-check-label {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.4;
    cursor: pointer;
}

.esim-form .form-check-label a {
    color: #ffc107;
    text-decoration: none;
}

.esim-form .form-check-label a:hover {
    text-decoration: underline;
}

/* Total */
.form-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-top: 1px solid #e8e8e8;
    margin: 24px 0;
}

.total-label {
    font-size: 1rem;
    color: #666;
}

.total-amount {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.total-price {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a1a1a;
}

.total-currency {
    font-size: 1rem;
    color: #666;
}

/* Submit Button */
.btn-submit {
    width: 100%;
    padding: 16px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    background: #ffc107;
    color: #212529;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-submit:hover:not(:disabled) {
    background: #e0a800;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3);
}

.btn-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-submit .btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Form Error */
.form-error-message {
    margin-top: 16px;
    padding: 12px 16px;
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 10px;
    color: #dc3545;
    font-size: 0.9rem;
}

/* Benefits Section */
.esim-benefits {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid #e8e8e8;
}

.benefit-item {
    display: flex;
    align-items: center;
    gap: 16px;
}

.benefit-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fffbeb;
    border-radius: 12px;
    color: #ffc107;
    font-size: 1.5rem;
}

.benefit-text {
    display: flex;
    flex-direction: column;
}

.benefit-text strong {
    font-size: 0.95rem;
    color: #1a1a1a;
    margin-bottom: 2px;
}

.benefit-text span {
    font-size: 0.85rem;
    color: #888;
}

/* Responsive */
@media (max-width: 1200px) {
    .esim-packages-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .esim-packages-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .esim-page {
        padding: 24px 0 60px;
    }

    .esim-title {
        font-size: 1.75rem;
    }

    .esim-subtitle {
        font-size: 1rem;
    }

    .country-dropdown {
        max-width: none;
    }

    .esim-packages-section {
        padding: 16px;
    }

    .esim-section-icon {
        width: 40px;
        height: 40px;
    }

    .esim-section-title {
        font-size: 16px;
    }

    .esim-tabs {
        width: 100%;
    }

    .esim-tab {
        flex: 1;
        text-align: center;
        padding: 10px 12px;
    }

    .esim-packages-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .esim-benefits {
        flex-direction: column;
        gap: 24px;
        align-items: center;
    }

    .benefit-item {
        width: 100%;
        max-width: 300px;
    }

    .esim-form-card {
        padding: 24px;
        border-radius: 16px;
    }

    .esim-package-data {
        font-size: 20px;
    }

    .esim-price-amount {
        font-size: 18px;
    }

    .esim-package-card {
        padding: 12px 32px;
    }
}

/* ========================================
   MOBILE COMPACT LIST (≤480px)
   ======================================== */

@media (max-width: 480px) {
    /* Grid becomes vertical list */
    .esim-packages-grid {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    /* Compact card - horizontal row */
    .esim-package-card {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 40px 12px 16px;
        text-align: left;
        border-radius: 10px;
        width: 100%;
    }

    /* Radio circle on the right, centered vertically */
    .esim-package-card::after {
        position: absolute;
        top: 50%;
        right: 12px;
        transform: translateY(-50%);
        width: 18px;
        height: 18px;
        border: 2px solid #cbd5e1;
        border-radius: 50%;
    }

    .esim-package-card.selected::after {
        border-color: #ffc107;
        background: #ffc107;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23212529' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: center;
        background-size: 10px;
    }

    /* Content in row */
    .esim-package-card .esim-card-content {
        display: flex;
        align-items: center;
        gap: 8px;
        padding-top: 0;
        flex: 1;
        min-width: 0;
    }

    /* Data (10GB) - main element */
    .esim-package-card .esim-package-data {
        font-size: 15px;
        font-weight: 600;
        margin: 0;
        white-space: nowrap;
        min-width: 45px;
    }

    /* Separator */
    .esim-package-card .esim-package-validity::before {
        content: "•";
        margin-right: 8px;
        color: #cbd5e1;
    }

    /* Validity (7 days) */
    .esim-package-card .esim-package-validity {
        font-size: 13px;
        margin: 0;
        white-space: nowrap;
    }

    /* Hide operator on mobile - save space */
    .esim-package-card .esim-package-operator {
        display: none;
    }

    /* Price on the right */
    .esim-package-card .esim-package-price {
        margin-left: auto;
        flex-shrink: 0;
    }

    .esim-package-card .esim-price-amount {
        font-size: 15px;
        font-weight: 600;
    }

    .esim-package-card .esim-price-currency {
        font-size: 12px;
    }
}
