/* ==================================================================
 *  快速咨询模态框 (Quick Consult Modal) v4.0 - 融入项目设计系统
 * ------------------------------------------------------------------
 *  - 使用项目CSS变量系统，遵循设计规范
 *  - 利用现有组件样式，减少重复代码
 *  - 保持独立性的同时与整体风格统一
 * ================================================================== */

/* --- Modal Container & State --- */
.quick-consult-modal-container {
    position: fixed;
    inset: 0;
    z-index: var(--z-index-modal);
    pointer-events: none;
}

/* --- Overlay --- */
.quick-consult-overlay {
    position: absolute;
    inset: 0;

    /* Note: Using neutral-900 with opacity for overlay */
    background-color: var(--neutral-900);
    opacity: 0; /* 默认不可见，只有在模态框打开时才显示 */
    transition: var(--transition-fade);
}

/* --- Trigger Button - 使用项目主色系 --- */
.quick-consult-trigger-btn {
    position: fixed;
    bottom: var(--space-50);
    right: var(--space-6); 
    width: var(--space-15); /* Note: No direct mapping, 56px or 64px are options */
    height: var(--space-15);
    background-color: var(--white);
    border: 1px solid var(--primary-300);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition-all);
    z-index: var(--z-index-sticky); /* Ensure it's above most content */
}

.quick-consult-trigger-btn:hover {
    background-color: var(--primary-700);
    transform: scale(1.1);
}

.quick-consult-trigger-btn .trigger-icon {
    font-size: var(--text-xl);
}

.quick-consult-trigger-btn i {
    color: var(--primary-600);
    padding: var(--space-1)!important;
}

.quick-consult-trigger-btn:hover i {
    color: var(--white);
}

/* --- Quick Consult Modal - 使用玻璃拟态效果 --- */
.quick-consult-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 90%;
    max-width: 500px;
    z-index: var(--z-index-modal);

    /* 使用项目的玻璃拟态效果 */
    /* Note: Hardcoded RGBA and values */
    background: var(--white);
    backdrop-filter: blur(var(--space-3)) saturate(150%);
    -webkit-backdrop-filter: blur(var(--space-3)) saturate(150%);
    border: 1px solid var(--white);
    padding: var(--space-6) var(--space-8);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);

    /* 初始隐藏状态 */
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
    transition: var(--transition-all);
    visibility: hidden;
    pointer-events: none;
}

/* --- State Control --- */
[data-quick-consult-state="open"] {
    pointer-events: auto;
}

[data-quick-consult-state="open"] .quick-consult-overlay {
    opacity: var(--opacity-50); /* 使用半透明遮罩 */
}

[data-quick-consult-state="open"] .quick-consult-modal {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    visibility: visible;
    pointer-events: auto;
}

/* --- Close Button - 使用项目按钮样式 --- */
.quick-consult-close-btn {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    background: transparent;
    border: none;
    font-size: var(--text-2xl); /* 1.75rem -> 1.5rem */
    cursor: pointer;
    color: var(--neutral-500);
    padding: var(--space-3);
    line-height: var(--line-height-none);
    transition: var(--transition-all);
    width: var(--space-10); /* 40px */
    height: var(--space-10); /* 40px */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
}

.quick-consult-close-btn:hover {
    color: var(--neutral-700);
    transform: rotate(90deg);
    background: var(--neutral-100);
}

/* --- Title - 使用项目排版系统 --- */
.quick-consult-title {
    text-align: center;
    margin-bottom: var(--space-3);
    color: var(--text-color-primary);
    font-weight: var(--font-weight-semibold);
    font-size: var(--text-2xl);
    line-height: var(--line-height-snug);
}

/* --- Form - 使用项目公共表单样式 --- */
/* 表单样式已移至 suker-forms.js，此处仅保留表单容器样式 */
.quick-consult-form {
    width: 100%;
}

/* --- Submit Button - 使用项目按钮样式 --- */
.quick-consult-submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-base);
    border: none;
    font-weight: var(--font-weight-semibold);
    font-size: var(--text-primary);
    line-height: var(--line-height-normal);
    text-align: center;
    cursor: pointer;
    transition: var(--transition-all);
    gap: var(--space-3);
    margin: var(--space-2) 0;
    background: var(--success-700);
    color: var(--white);
    box-shadow: var(--shadow-sm);
}

.quick-consult-submit-btn:hover:not(:disabled) {
    background: var(--success-700);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.quick-consult-submit-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.quick-consult-submit-btn:disabled {
    background-color: var(--neutral-300);
    cursor: not-allowed;
    opacity: var(--opacity-60);
}

.quick-consult-submit-btn span {
    color: var(--white);
}

/* 提交按钮文本显示/隐藏控制 */
.quick-consult-submit-text.hidden {
    display: none !important;
}

.quick-consult-submit-loading {
    display: none;
}

.quick-consult-submit-loading:not(.hidden) {
    display: inline;
}

/* 触发按钮显示/隐藏控制 */
.quick-consult-trigger-btn.hidden {
    display: none !important;
}

/* --- Success Message --- */
#quick-consult-success {
    text-align: center;
    padding: var(--space-6) var(--space-4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--transition-fast) ease-in-out;
}

#quick-consult-success.hidden {
    display: none;
}

#quick-consult-success i {
    font-size: var(--text-4xl);
    color: var(--success-600);
    margin-bottom: var(--space-4);
}

#quick-consult-success h3 {
    font-size: var(--text-xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-color-primary);
    margin-bottom: var(--space-2);
}

#quick-consult-success p {
    color: var(--neutral-600);
    font-size: var(--text-base);
}

/* --- General Error Message --- */
.quick-consult-general-error {
    background-color: var(--danger-50);
    border: 1px solid var(--danger-200);
    color: var(--danger-700);
    padding: var(--space-3);
    border-radius: var(--radius-base);
    margin-bottom: var(--space-4);
    font-size: var(--text-sm);
    text-align: center;
    animation: shake 0.3s ease-in-out;
}

.quick-consult-general-error.hidden {
    display: none;
}

/* --- Field Error Message --- */
.form-error {
    color: var(--danger-600);
    font-size: var(--text-xs);
    margin-top: var(--space-1);
    min-height: var(--space-4);
}

.form-error.hidden {
    display: none;
}

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

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

/* ==================================================================
 *  浏览器自动填充 (Autofill) 样式覆盖
 *  解决 Chrome 等浏览器自动填充时背景变蓝和文字颜色问题
 * ================================================================== */
.quick-consult-form .form-control:-webkit-autofill,
.quick-consult-form .form-control:-webkit-autofill:hover,
.quick-consult-form .form-control:-webkit-autofill:focus,
.quick-consult-form .form-control:-webkit-autofill:active {
    /* 使用 inset shadow 覆盖默认的淡蓝色背景，设置为白色 */
    -webkit-box-shadow: 0 0 0 1000px var(--white) inset !important;
    /* 强制文本颜色为项目标准文本色，避免刺眼的默认黑色 */
    -webkit-text-fill-color: var(--text-color-primary) !important;
    /* 防止背景色过渡动画导致的闪烁 */
    transition: background-color 5000s ease-in-out 0s;
}

/* 统一 Placeholder 颜色 */
.quick-consult-form .form-control::placeholder {
    color: var(--neutral-400); /* 柔和的灰色 */
    opacity: 1;
}

/* 兼容各浏览器前缀 */
.quick-consult-form .form-control::-webkit-input-placeholder { color: var(--neutral-400); }
.quick-consult-form .form-control::-moz-placeholder { color: var(--neutral-400); opacity: 1; }
.quick-consult-form .form-control:-ms-input-placeholder { color: var(--neutral-400); }
