* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Microsoft YaHei', '微软雅黑', sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body:has(.dev-mode) {
    padding-top: 50px;
}

/* Dev mode banner (ENVIRONMENT=development) */
.dev-mode {
    width: 100%;
    margin: 0 auto;
    padding: 8px 12px;
    background: #ff0000;
    text-align: center;
    position: absolute;
    top: 0;
    left: 0;
}

.dev-mode-text {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
}


.form-container {
    background: white;
    max-width: 600px;
    width: 100%;
    margin: 10px auto;
    padding: 40px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow-x: hidden;
    position: relative;
}

/* Prevent horizontal overflow for all elements */
img, video, iframe, embed, object {
    max-width: 100%;
    height: auto;
}

table {
    width: 100%;
    table-layout: fixed;
    word-wrap: break-word;
}

input, textarea, select, button {
    max-width: 100%;
}

@media (max-width: 640px) {
    .form-container {
        padding: 20px;
        margin: 5px auto;
    }
    
    body {
        padding: 10px;
    }
}

/* Language Selector at Top Right */
.language-selector-top {
    display: flex;
    justify-content: flex-end;
    gap: 5px;
    margin-bottom: 15px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 20px;
}

.lang-btn {
    padding: 5px 10px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    text-decoration: none;
    color: #333;
    display: inline-block;
    border-radius: 4px;
}

.lang-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.lang-btn:hover:not(.active) {
    background: #f0f0f0;
}

.lang-btn.active:hover {
    background: #0056b3;
}

/* Disabled language button (when already selected) */
span.lang-btn.active {
    cursor: default !important;
    pointer-events: none !important;
    opacity: 1;
}

/* Header Banner Section */
.form-header {
    margin-bottom: 30px;
}

.logo-banner {
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
}


.logo-image {
    height: auto;
    width: 100%;
    object-fit: contain;
}

.logo-english {
    font-size: 16px;
    font-style: italic;
    font-family: serif;
    color: #333;
    font-weight: 500;
}

.logo-chinese {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    line-height: 1.2;
}

/* Form Title */
.form-title {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    text-align: center;
}

.form-subtitle {
    font-size: 16px;
    font-weight: 400;
    color: #333;
    margin-bottom: 30px;
    text-align: center;
}

/* Section Styling */
.form-section {
    margin-bottom: 30px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #007bff;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
}

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

.form-group input[type="text"],
.form-group input[type="tel"] {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input[type="text"]:focus,
.form-group input[type="tel"]:focus {
    outline: none;
    border-color: #007bff;
}

.form-group input.invalid,
.form-group textarea.invalid {
    border-color: #dc3545;
}

.form-group input[readonly] {
    background: #f5f5f5;
    color: #666;
}

/* Credit Card Number */
.credit-card-input {
    font-size: 18px;
    letter-spacing: 2px;
    font-family: 'Courier New', monospace;
}

.credit-card-input.valid {
    border-color: #28a745;
}

.credit-card-input.invalid {
    border-color: #dc3545;
}

.card-validation-message {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

/* Expiry Date */
.expiry-group {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.expiry-input {
    width: 80px;
    text-align: center;
}

.expiry-error-container {
    width: 100%;
    margin-top: 5px;
}

/* Visually hidden but accessible to screen readers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Signature */
.signature-wrapper {
    border: 1px solid #dddddd;
    border-radius: 15px;
    background: #fafafa;
}

.signature-pad {
    width: 100%;
    height: 300px;
}

/* Card Type Logos */
.card-types {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    margin-bottom: 20px;
}

.card-type-logo {
    height: 40px;
    opacity: 0.5;
    filter: grayscale(100%);
    transition: opacity 0.3s, filter 0.3s;
    pointer-events: none; /* Disable manual selection - auto-detected only */
    cursor: default;
}

.card-type-logo.selected {
    opacity: 1;
    filter: grayscale(0%);
}

/* Checkboxes */
.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 15px;
}

.checkbox-group label {
    flex: 1;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    margin: 0;
}

.checkbox-group input[type="checkbox"] {
    margin-top: 4px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-group a {
    color: #007bff;
    text-decoration: underline;
}

.checkbox-group a:hover {
    color: #0056b3;
}

/* Error Messages */
.error-message {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
}

/* Buttons */
.form-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 30px;
}

.submit-btn {
    padding: 15px 30px;
    background: #ff6600;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.submit-btn:hover {
    background: #e55a00;
}

.submit-btn:active {
    background: #cc5000;
}

.reset-btn {
    padding: 12px 30px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
}

.reset-btn:hover {
    background: #5a6268;
}

/* Success Page Styles */
.success-box {
    background: white;
    border: 2px solid #ff6600;
    border-radius: 12px;
    padding: 40px 30px;
    text-align: center;
    margin-bottom: 30px;
}

.success-icon {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
}

.success-checkmark {
    font-size: 60px;
    color: white;
    margin-bottom: 15px;
}

.success-activated {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    margin-bottom: 10px;
}

.success-message {
    font-size: 16px;
    color: #333;
    line-height: 1.5;
}

.success-info-message {
    text-align: center;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 30px;
    padding: 0 20px;
}

.terms-section {
    margin-bottom: 30px;
}

.terms-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
}

.terms-list {
    list-style: decimal;
    padding-left: 25px;
}

.terms-list li {
    margin-bottom: 12px;
    color: #666;
    line-height: 1.6;
}

/* 確保 Modal 顯示邏輯正確 */
#termsModal {
    display: none; /* 預設隱藏 */
    position: fixed;
    z-index: 9999;
    /* ... 其他樣式 ... */
}

#termsModal.show {
    display: block !important; /* 當有 .show 時強制顯示 */
}

.update-button {
    width: 100%;
    padding: 15px 30px;
    background: #ff6600;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    margin-bottom: 20px;
}

.update-button:hover {
    background: #e55a00;
}

.return-btn {
    width: 100%;
    padding: 15px 30px;
    background: #ff6600;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    margin-bottom: 20px;
}

.return-btn:hover {
    background: #e55a00;
}

.customer-info-section {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

.customer-info-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
}

.customer-info-item:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: #333;
}

.info-value {
    color: #666;
}

.copyright {
    text-align: center;
    color: #999;
    font-size: 12px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

/* Responsive */
@media (max-width: 768px) {
    .form-container {
        padding: 20px;
    }
    
    .logo-banner {
        flex-direction: column;
        gap: 20px;
        padding: 15px 20px;
    }
    
    .logo-left,
    .logo-right {
        justify-content: center;
        width: 100%;
    }
    
    .logo-right {
        justify-content: center;
    }
    
    .logo-chinese {
        font-size: 24px;
    }
    
    .sun-title {
        font-size: 28px;
    }
    
    .sun-subtitle {
        font-size: 16px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .success-box {
        padding: 20px;
    }

    .success-activated {
        font-size: 24px;
    }

    .success-message {
        font-size: 16px;
    }
}

/* Terms Link Styling */
.terms-link {
    color: #007bff;
    text-decoration: underline;
    cursor: pointer;
}

.terms-link:hover {
    color: #0056b3;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 0;
    border: 1px solid #888;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 30px;
    background: #ff6600;
    color: white;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.modal-close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: opacity 0.3s;
}

.modal-close:hover,
.modal-close:focus {
    opacity: 0.7;
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}

.modal-body .terms-list {
    margin: 0;
    padding-left: 25px;
}

.modal-body .terms-list li {
    margin-bottom: 15px;
    line-height: 1.6;
    color: #333;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
}

.modal-close-btn {
    padding: 10px 30px;
    background: #ff6600;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.modal-close-btn:hover {
    background: #e55a00;
}

/* Service Provider Toggle */
.service-toggle {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    justify-content: center;
}

.toggle-btn {
    flex: 1;
    max-width: 250px;
    padding: 20px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #f5f5f5;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #333;
}

.toggle-btn:hover {
    border-color: #e55a00;
    background: #fff5f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.toggle-btn.active {
    border-color: #ff6600;
    background: #fff5f0;
}

.toggle-icon-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 78px;
    height: 78px;
    border-radius: 50%;
    background-color: #dddddd;
}

.toggle-icon {
    width: 48px;
    height: 48px;
    filter: invert(25%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(70%) contrast(70%);
}

.toggle-btn.active .toggle-icon {
    filter: invert(47%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(90%) contrast(90%);
}

.toggle-text {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}

/* Landing Page Cards */
.landing-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.landing-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 40px 30px;
    text-align: center;
    text-decoration: none;
    color: #333;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    min-height: 280px;
}

.landing-card:hover {
    border-color: #ff6600;
    box-shadow: 0 8px 20px rgba(255, 102, 0, 0.15);
    transform: translateY(-5px);
}

.landing-card-icon {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 50%;
    margin-bottom: 10px;
}

.landing-icon {
    width: 48px;
    height: 48px;
    filter: invert(47%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(90%) contrast(90%);
}

.landing-card:hover .landing-icon {
    filter: invert(45%) sepia(89%) saturate(2544%) hue-rotate(4deg) brightness(101%) contrast(104%);
}

.landing-card-title {
    font-size: 22px;
    font-weight: 600;
    color: #333;
    margin-top: 10px;
}

.landing-card-subtitle {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.landing-card-arrow {
    font-size: 24px;
    color: #ff6600;
    margin-top: auto;
    font-weight: 600;
}

/* Responsive Modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-header {
        padding: 15px 20px;
    }

    .modal-header h2 {
        font-size: 20px;
    }

    .modal-body {
        padding: 20px;
    }

    .modal-footer {
        padding: 15px 20px;
    }
    
    .service-toggle {
        flex-direction: column;
        gap: 10px;
    }
    
    .toggle-btn {
        max-width: 100%;
    }
    
    .landing-cards {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .landing-card {
        min-height: 240px;
        padding: 30px 20px;
    }
}

