/**
 * AI 對話式註冊頁面樣式
 * 複用 AISidebarManager 的聊天元件 + 全頁佈局
 */

:root {
    --chat-primary: #1a237e;
    --chat-primary-light: #3949ab;
    --chat-accent: #f5b800;
    --chat-accent-dark: #e6a800;
    --chat-bg: #f5f6fa;
    --chat-max-width: 700px;
}

/* ==================== 全頁佈局 ==================== */

body.chat-register-page {
    margin: 0;
    padding: 0;
    font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--chat-bg);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-page-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: var(--chat-max-width);
    margin: 0 auto;
    width: 100%;
    background: white;
    box-shadow: 0 0 40px rgba(0,0,0,0.1);
}

/* ==================== 頂部 Header ==================== */

.chat-header {
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 10;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-logo {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.chat-header-badge {
    background: rgba(255,255,255,0.15);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.chat-lang-switcher {
    display: flex;
    gap: 4px;
}

.chat-lang-switcher a {
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    padding: 4px 8px;
    font-size: 0.8rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.chat-lang-switcher a:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.chat-lang-switcher a.active {
    color: white;
    background: rgba(255,255,255,0.2);
    font-weight: 600;
}

/* ==================== 訊息區域 ==================== */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--chat-bg);
    scroll-behavior: smooth;
}

/* 訊息氣泡（複用 ai-message 模式） */
.chat-msg {
    margin-bottom: 16px;
    max-width: 85%;
    animation: chatFadeIn 0.3s ease;
}

@keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg-user {
    margin-left: auto;
}

.chat-msg-assistant {
    margin-right: auto;
}

.chat-msg-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    word-break: break-word;
}

.chat-msg-user .chat-msg-content {
    background: var(--chat-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg-assistant .chat-msg-content {
    background: white;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
    color: #333;
}

/* 用戶圖片訊息 */
.chat-msg-image img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 12px;
    object-fit: cover;
}

/* ==================== Typing 動畫 ==================== */

.chat-typing {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
}

.chat-typing span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: chatTyping 1.4s ease-in-out infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ==================== 快速回覆按鈕 ==================== */

.chat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    margin-bottom: 16px;
}

.chat-quick-reply-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: 2px solid var(--chat-primary);
    border-radius: 24px;
    background: white;
    color: var(--chat-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-quick-reply-btn:hover {
    background: var(--chat-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26,35,126,0.3);
}

.chat-quick-reply-btn.variant-primary {
    background: var(--chat-primary);
    color: white;
}

.chat-quick-reply-btn.variant-primary:hover {
    background: var(--chat-primary-light);
}

.chat-quick-reply-btn.variant-outline {
    background: transparent;
}

.chat-quick-reply-btn i {
    font-size: 1.1rem;
}

/* ==================== 資料卡片 ==================== */

.chat-data-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    overflow: hidden;
    margin: 8px 0 16px;
    max-width: 85%;
}

.chat-data-card-header {
    background: linear-gradient(135deg, var(--chat-accent), #f7c948);
    color: #333;
    padding: 10px 16px;
    font-weight: 600;
    font-size: 0.85rem;
}

.chat-data-card-body {
    padding: 0;
}

.chat-data-row {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.chat-data-row:last-child {
    border-bottom: none;
}

.chat-data-row:hover {
    background: #fafafa;
}

.chat-data-label {
    font-size: 0.8rem;
    color: #888;
    width: 80px;
    flex-shrink: 0;
}

.chat-data-value {
    flex: 1;
    font-size: 0.9rem;
    color: #333;
    font-weight: 500;
}

.chat-data-edit-btn {
    padding: 4px 8px;
    border: none;
    background: none;
    color: #999;
    cursor: pointer;
    font-size: 0.85rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.chat-data-edit-btn:hover {
    color: var(--chat-primary);
    background: rgba(26,35,126,0.05);
}

/* 編輯模式 */
.chat-data-row.editing .chat-data-value {
    display: none;
}

.chat-data-edit-input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid var(--chat-primary);
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
}

.chat-data-save-btn {
    padding: 4px 12px;
    border: none;
    background: var(--chat-primary);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    margin-left: 6px;
}

/* ==================== 行業/規模選擇 ==================== */

.chat-select-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 8px 0 16px;
    max-width: 85%;
}

.chat-select-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.chat-select-item:hover {
    border-color: var(--chat-primary);
    background: rgba(26,35,126,0.03);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.chat-select-item.selected {
    border-color: var(--chat-primary);
    background: rgba(26,35,126,0.06);
}

.chat-select-item i {
    font-size: 1.5rem;
    color: var(--chat-primary);
}

.chat-select-item span {
    font-size: 0.8rem;
    color: #555;
    font-weight: 500;
}

/* 規模選擇（橫向） */
.chat-size-grid {
    display: flex;
    gap: 8px;
    margin: 8px 0 16px;
    flex-wrap: wrap;
}

.chat-size-item {
    padding: 10px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 24px;
    background: white;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.chat-size-item:hover {
    border-color: var(--chat-primary);
    color: var(--chat-primary);
}

/* ==================== 表單欄位 ==================== */

.chat-form-inline {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    padding: 20px;
    margin: 8px 0 16px;
    max-width: 85%;
}

.chat-form-field {
    margin-bottom: 14px;
}

.chat-form-field:last-child {
    margin-bottom: 0;
}

.chat-form-field label {
    display: block;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 4px;
    font-weight: 500;
}

.chat-form-field input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.chat-form-field input:focus {
    border-color: var(--chat-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(26,35,126,0.1);
}

.chat-form-submit {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: var(--chat-primary);
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s;
}

.chat-form-submit:hover {
    background: var(--chat-primary-light);
}

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

/* 驗證碼輸入 */
.chat-verify-code-container {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 16px 0;
}

.chat-verify-code-input {
    width: 48px;
    height: 56px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    border: 2px solid #ddd;
    border-radius: 10px;
    transition: border-color 0.2s;
}

.chat-verify-code-input:focus {
    border-color: var(--chat-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(26,35,126,0.1);
}

/* ==================== 進度動畫 ==================== */

.chat-progress {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    padding: 20px;
    margin: 8px 0 16px;
    max-width: 85%;
}

.chat-progress-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    color: #999;
    transition: color 0.3s;
}

.chat-progress-step.active {
    color: var(--chat-primary);
    font-weight: 600;
}

.chat-progress-step.done {
    color: #4caf50;
}

.chat-progress-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    border: 2px solid #ddd;
    flex-shrink: 0;
}

.chat-progress-step.active .chat-progress-icon {
    border-color: var(--chat-primary);
    background: var(--chat-primary);
    color: white;
    animation: chatPulse 1.5s infinite;
}

.chat-progress-step.done .chat-progress-icon {
    border-color: #4caf50;
    background: #4caf50;
    color: white;
}

@keyframes chatPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(26,35,126,0.3); }
    50% { box-shadow: 0 0 0 8px rgba(26,35,126,0); }
}

/* ==================== 成功卡片 ==================== */

.chat-success-card {
    background: white;
    border: 2px solid #4caf50;
    border-radius: 16px;
    overflow: hidden;
    margin: 8px 0 16px;
    max-width: 85%;
    text-align: center;
}

.chat-success-header {
    background: linear-gradient(135deg, #4caf50, #66bb6a);
    color: white;
    padding: 24px 20px;
}

.chat-success-header i {
    font-size: 2.5rem;
    margin-bottom: 8px;
    display: block;
}

.chat-success-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.chat-success-body {
    padding: 20px;
}

.chat-success-info {
    text-align: left;
    margin-bottom: 16px;
}

.chat-success-info div {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
}

.chat-success-info div:last-child {
    border-bottom: none;
}

.chat-success-info .label {
    color: #888;
}

.chat-success-info .value {
    font-weight: 600;
    color: #333;
}

.chat-success-login-btn {
    display: inline-block;
    padding: 12px 32px;
    background: var(--chat-primary);
    color: white;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    transition: background 0.2s;
}

.chat-success-login-btn:hover {
    background: var(--chat-primary-light);
    color: white;
}

/* ==================== 輸入區域 ==================== */

.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid #e0e0e0;
    background: white;
    flex-shrink: 0;
}

.chat-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f5f5f5;
    border-radius: 24px;
    padding: 4px 8px;
}

.chat-btn-upload {
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: #666;
    cursor: pointer;
    font-size: 1.2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-btn-upload:hover {
    background: rgba(0,0,0,0.08);
    color: var(--chat-primary);
}

.chat-input-text {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 4px;
    font-size: 0.95rem;
    outline: none;
}

.chat-btn-send {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--chat-primary);
    color: white;
    cursor: pointer;
    font-size: 1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-btn-send:hover {
    background: var(--chat-primary-light);
}

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

/* 圖片預覽 */
.chat-image-preview {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    flex-wrap: wrap;
}

.chat-image-preview-item {
    position: relative;
    width: 60px;
    height: 60px;
}

.chat-image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.chat-image-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border: none;
    background: #ff5252;
    color: white;
    border-radius: 50%;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==================== 底部連結 ==================== */

.chat-footer {
    padding: 8px 16px;
    text-align: center;
    background: white;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.chat-footer a {
    color: #999;
    text-decoration: none;
    font-size: 0.8rem;
}

.chat-footer a:hover {
    color: var(--chat-primary);
}

/* ==================== RWD ==================== */

@media (max-width: 768px) {
    .chat-page-container {
        max-width: 100%;
        box-shadow: none;
    }

    .chat-select-grid {
        grid-template-columns: repeat(2, 1fr);
        max-width: 100%;
    }

    .chat-msg, .chat-data-card, .chat-form-inline, .chat-progress, .chat-success-card {
        max-width: 92%;
    }

    .chat-header-badge {
        display: none;
    }
}

/* ==================== 功能包選擇 ==================== */

.chat-feature-pack-container {
    max-width: var(--chat-max-width);
    margin: 0 auto;
    padding: 8px 0;
}

.chat-feature-pack-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    margin-bottom: 8px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-feature-pack-item:hover {
    border-color: var(--chat-accent);
    background: #fffde7;
}

.chat-feature-pack-item.selected {
    border-color: var(--chat-accent);
    background: #fff8e1;
    box-shadow: 0 2px 8px rgba(245, 184, 0, 0.2);
}

.chat-feature-pack-icon {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--chat-accent), var(--chat-accent-dark));
    border-radius: 10px;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.chat-feature-pack-info {
    flex: 1;
    min-width: 0;
}

.chat-feature-pack-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #333;
}

.chat-feature-pack-desc {
    font-size: 0.8rem;
    color: #888;
    margin-top: 2px;
    line-height: 1.3;
}

.chat-feature-pack-check {
    font-size: 1.3rem;
    color: #ccc;
    flex-shrink: 0;
}

.chat-feature-pack-item.selected .chat-feature-pack-check {
    color: var(--chat-accent-dark);
}

.chat-feature-pack-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    justify-content: center;
}

.chat-feature-pack-confirm,
.chat-feature-pack-skip {
    padding: 10px 28px;
    border-radius: 20px;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-feature-pack-confirm {
    background: linear-gradient(135deg, var(--chat-accent), var(--chat-accent-dark));
    color: #333;
}

.chat-feature-pack-confirm:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 184, 0, 0.3);
}

.chat-feature-pack-skip {
    background: #f5f5f5;
    color: #888;
}

.chat-feature-pack-skip:hover {
    background: #e0e0e0;
    color: #555;
}

/* === 子網域輸入 === */
.chat-subdomain-container {
    padding: 16px;
    margin: 8px 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.chat-subdomain-input-group {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.chat-subdomain-input-group:focus-within {
    border-color: var(--chat-accent);
}

.chat-subdomain-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 14px;
    font-size: 16px;
    color: var(--chat-text);
    outline: none;
    font-family: monospace;
}

.chat-subdomain-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.chat-subdomain-input.is-invalid {
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.chat-subdomain-suffix {
    padding: 12px 14px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    white-space: nowrap;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
}

.chat-subdomain-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 8px;
}

.chat-subdomain-preview {
    display: none;
    font-size: 14px;
    color: var(--chat-accent);
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(245, 184, 0, 0.08);
    border-radius: 6px;
}

.chat-subdomain-confirm {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: linear-gradient(135deg, var(--chat-accent), var(--chat-accent-dark));
    color: #333;
    transition: all 0.2s ease;
}

.chat-subdomain-confirm:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 184, 0, 0.3);
}
