#med-ai-chat-container {
    position: fixed !important;
    bottom: 10px !important;
    right: 20px !important;
    z-index: 999999 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    width: auto;
    height: auto;
    margin: 0 !important;
    padding: 0 !important;
}

/* 移动端触控优化 */
#med-ai-chat-container * {
    -webkit-tap-highlight-color: transparent;
}
#med-ai-chat-toggle,
#med-ai-chat-send,
.med-ai-chat-inline-btn,
.med-ai-chat-form-button,
.med-ai-chat-payment-button {
    touch-action: manipulation;
}

body .medc-sticky-appoint-btn {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    z-index: -9999 !important;
}

body .appointment-modal {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    z-index: -9999 !important;
}



#med-ai-chat-widget {
    width: 480px;
    max-width: calc(100vw - 40px);
    height: min(750px, 80vh);
    max-height: calc(100vh - 20px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    overflow: hidden;
    position: absolute;
    bottom: 10px;
    right: 0;
}

#med-ai-chat-widget.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

#med-ai-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    flex-shrink: 0;
    position: relative;
}

.med-ai-chat-avatar-info-area {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-radius: 8px;
    padding: 4px 8px;
    margin: -4px -8px;
    transition: background 0.2s;
}

.med-ai-chat-avatar-info-area:hover {
    background: rgba(255,255,255,0.15);
}

.med-ai-chat-header-menu {
    position: absolute;
    top: 100%;
    left: 12px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 6px 0;
    min-width: 185px;
    z-index: 10;
    animation: medAiMenuFadeIn 0.15s ease-out;
}

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

.med-ai-chat-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    color: #374151;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}

.med-ai-chat-menu-item:hover,
.med-ai-chat-menu-item:focus,
.med-ai-chat-menu-item:active {
    background: #667eea;
    color: white;
}

.med-ai-chat-menu-item:hover svg,
.med-ai-chat-menu-item:focus svg,
.med-ai-chat-menu-item:active svg {
    color: white;
}

.med-ai-chat-menu-item svg {
    color: #6b7280;
    flex-shrink: 0;
}

.med-ai-chat-history-list {
    position: absolute;
    top: 100%;
    left: 5%;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 8px 0;
    width: 90%;
    max-height: 320px;
    overflow-y: auto;
    z-index: 10;
    animation: medAiMenuFadeIn 0.15s ease-out;
}

#med-ai-chat-widget.med-ai-chat-fullscreen-mode .med-ai-chat-history-list {
    width: 60%;
    left: 0;
}

.med-ai-chat-history-item {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    color: #374151;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    border-bottom: 1px solid #f3f4f6;
}

.med-ai-chat-history-item:hover,
.med-ai-chat-history-item:focus,
.med-ai-chat-history-item:active {
    background: #667eea;
    color: white;
}

.med-ai-chat-history-item:hover .hist-date,
.med-ai-chat-history-item:focus .hist-date,
.med-ai-chat-history-item:active .hist-date {
    color: rgba(255,255,255,0.8);
}

.med-ai-chat-history-item:hover .hist-preview,
.med-ai-chat-history-item:focus .hist-preview,
.med-ai-chat-history-item:active .hist-preview {
    color: rgba(255,255,255,0.9);
}

.med-ai-chat-history-item .hist-date {
    color: #6b7280;
    font-size: 12px;
    display: block;
    margin-top: 2px;
}

.med-ai-chat-history-item .hist-preview {
    color: #6b7280;
    font-size: 13px;
    display: block;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.med-ai-chat-history-back {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 16px;
    border: none;
    background: none;
    color: #6b7280;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 4px;
}

.med-ai-chat-history-back:hover,
.med-ai-chat-history-back:focus,
.med-ai-chat-history-back:active {
    background: #667eea;
    color: white;
}

.med-ai-chat-hospital-name {
    font-size: 13px;
    font-weight: 500;
    opacity: 0.9;
    max-width: 160px;
    text-align: right;
    margin-left: auto;
    margin-right: 4px;
}

.med-ai-chat-avatar {
    width: 48px;
    height: 48px;
    background: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.med-ai-chat-avatar img.med-ai-chat-avatar-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 50%;
}

.med-ai-chat-avatar svg {
    width: 32px;
    height: 32px;
}

.med-ai-chat-info {
    flex: 1;
}

.med-ai-chat-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.med-ai-chat-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.med-ai-chat-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

#med-ai-chat-close {
    background: transparent;
    border: none;
    color: white;
    padding: 4px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#med-ai-chat-close:focus-visible,
#med-ai-chat-fullscreen:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

#med-ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 全屏按钮 */
#med-ai-chat-fullscreen {
    background: transparent;
    border: none;
    color: white;
    padding: 4px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}

#med-ai-chat-fullscreen:hover {
    background: rgba(255, 255, 255, 0.2);
}

#med-ai-chat-fullscreen svg {
    width: 20px;
    height: 20px;
}

/* 全屏模式 */
#med-ai-chat-widget.med-ai-chat-fullscreen-mode {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    bottom: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
    z-index: 9999999 !important;
}

#med-ai-chat-widget.med-ai-chat-fullscreen-mode .med-hospital-cards-row {
    max-width: 100%;
    padding-left: 44px;
    margin-left: 0;
}

#med-ai-chat-widget.med-ai-chat-fullscreen-mode .med-hospital-card {
    flex: 1 1 300px;
    max-width: 420px;
}

#med-ai-chat-widget.med-ai-chat-fullscreen-mode .med-hospital-cards-row .med-hospital-card:only-child {
    max-width: 420px;
}

#med-ai-chat-close svg {
    width: 24px;
    height: 24px;
}

#med-ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.med-ai-chat-welcome {
    text-align: center;
    padding: 40px 20px;
    background: white;
    border-radius: 12px;
    margin: auto 0;
}

.med-ai-chat-welcome-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
}

.med-ai-chat-welcome-icon svg {
    width: 100%;
    height: 100%;
}

.med-ai-chat-welcome h3 {
    margin: 0 0 8px;
    font-size: 20px;
    color: #1e293b;
}

.med-ai-chat-welcome p {
    margin: 0;
    color: #64748b;
    font-size: 14px;
}

.med-ai-chat-disclaimer {
    margin-top: 20px;
    padding: 12px 16px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    text-align: left;
}

.med-ai-chat-disclaimer p {
    margin: 0;
    font-size: 12px;
    line-height: 1.6;
    color: #92400e;
}

.med-ai-chat-message {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    max-width: 85%;
    animation: messageIn 0.3s ease;
}


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

.med-ai-chat-message.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.med-ai-chat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.med-ai-chat-message.user .med-ai-chat-message-avatar {
    background: #64748b;
}

:root {
    --medical-primary: #165DFF;
    --warning-color: #F53F3F;
    --note-color: #FF7D00;
    --text-primary: #333333;
    --text-secondary: #666666;
    --bg-light: #F5F5F5;
    --border-color: #EEEEEE;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
}

.med-ai-chat-message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    overflow-wrap: anywhere;
    word-break: normal;
    max-width: 100%;
}

.med-ai-chat-message-content .module-title {
    color: var(--medical-primary);
    font-size: 17px;
    font-weight: 700;
    margin: var(--spacing-lg) 0 var(--spacing-md);
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 4px;
}

.med-ai-chat-message-content .subtitle {
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    margin: var(--spacing-md) 0 var(--spacing-sm);
}

.med-ai-chat-message-content .medical-keyword {
    color: var(--text-primary);
    font-weight: 600;
    border-bottom: none;
    cursor: default;
}

.med-ai-chat-message-content strong {
    font-weight: 600;
    color: var(--text-primary);
}

.med-ai-chat-message-content strong.medical-keyword {
    color: var(--text-primary);
    border-bottom: none;
    cursor: default;
}

.med-ai-chat-message-content .note-text {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 400;
    font-style: normal;
}

.med-ai-chat-message-content .bullet-list {
    margin: var(--spacing-sm) 0;
    padding-left: 20px;
}

.med-ai-chat-message-content .bullet-list .med-list-item {
    list-style-type: none;
    position: relative;
    margin-bottom: 4px;
    line-height: 1.6;
    padding-left: 0;
}

.med-ai-chat-message-content .bullet-list .med-list-item::before {
    content: '•';
    color: var(--medical-primary);
    font-weight: bold;
    position: absolute;
    left: -16px;
    font-size: 1.1em;
}

.med-ai-chat-message-content .numbered-list {
    margin: var(--spacing-sm) 0;
    padding-left: 24px;
}

.med-ai-chat-message-content .numbered-list .med-list-item {
    margin-bottom: 4px;
    line-height: 1.6;
}

.med-ai-chat-message-content .numbered-list .med-list-item::marker {
    color: var(--medical-primary);
    font-weight: 600;
}

.med-ai-chat-message-content .module-divider {
    border: none;
    border-top: 1px dashed var(--border-color);
    margin: 20px 0;
    height: 0;
}

.med-ai-chat-message-content .blockquote {
    border-left: 4px solid var(--medical-primary);
    background-color: var(--bg-light);
    padding: var(--spacing-md);
    margin: var(--spacing-md) 0;
    border-radius: 4px;
    line-height: 1.6;
}

.med-ai-chat-message-content .blockquote.warning {
    border-left-color: var(--warning-color);
    background-color: rgba(245, 63, 63, 0.05);
}

.med-ai-chat-message-content .blockquote.note {
    border-left-color: var(--note-color);
    background-color: rgba(255, 125, 0, 0.05);
}

.med-ai-chat-message-content blockquote.med-ai-chat-brief-summary {
    border-left: 4px solid #ff7d00;
    background: linear-gradient(135deg, rgba(255, 125, 0, 0.10) 0%, rgba(255, 125, 0, 0.04) 100%);
    padding: var(--spacing-md) var(--spacing-lg);
    margin: var(--spacing-md) 0;
    border-radius: 8px;
    line-height: 1.7;
    font-style: italic;
    color: var(--text-secondary);
}

.med-ai-chat-message-content blockquote.med-ai-chat-brief-summary p {
    margin: 0 0 var(--spacing-xs) 0;
    font-style: italic;
}

.med-ai-chat-message-content blockquote.med-ai-chat-brief-summary p:last-child {
    margin-bottom: 0;
}

/* 决策意图高亮提示 — 显著蓝色背景，区分于普通内容 */
.med-ai-chat-message-content .decision-prompt {
    background: linear-gradient(135deg, rgba(22, 93, 255, 0.22) 0%, rgba(22, 93, 255, 0.12) 100%);
    border: 2px solid rgba(22, 93, 255, 0.5);
    border-left: 5px solid var(--medical-primary);
    border-radius: 10px;
    padding: 14px 18px;
    margin: 14px 0 10px;
    line-height: 1.8;
    font-size: 15px;
    font-weight: 700;
    color: #1d4ed8;
    box-shadow: 0 3px 12px rgba(22, 93, 255, 0.12);
    white-space: pre-line;
}

.med-ai-chat-message-content .decision-prompt strong {
    color: #1e40af;
    font-weight: 800;
}

.med-ai-chat-message-content .decision-buttons {
    display: flex;
    gap: 14px;
    margin-top: 14px;
    justify-content: flex-start;
}

.med-ai-chat-message-content .decision-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.3px;
}

.med-ai-chat-message-content .decision-btn.decision-yes {
    background: var(--medical-primary, #165DFF);
    color: #fff;
    box-shadow: 0 2px 8px rgba(22, 93, 255, 0.25);
}

.med-ai-chat-message-content .decision-btn.decision-yes:hover {
    background: var(--medical-primary-dark, #1249cc);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(22, 93, 255, 0.3);
}

.med-ai-chat-message-content .decision-btn.decision-no {
    background: transparent;
    color: #64748b;
    border: 1.5px solid #cbd5e1;
}

.med-ai-chat-message-content .decision-btn.decision-no:hover {
    background: #f1f5f9;
    color: #475569;
    border-color: #94a3b8;
}

.med-ai-chat-message-content .form-summary-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 16px;
    margin-top: 10px;
}

.med-ai-chat-message-content .form-summary-row {
    display: flex;
    align-items: baseline;
    padding: 6px 0;
    border-bottom: 1px solid #f1f5f9;
    gap: 12px;
}

.med-ai-chat-message-content .form-summary-row:last-child {
    border-bottom: none;
}

.med-ai-chat-message-content .form-summary-row.form-summary-full {
    flex-direction: column;
    gap: 4px;
}

.med-ai-chat-message-content .form-summary-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
    min-width: 80px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.med-ai-chat-message-content .form-summary-value {
    font-size: 14px;
    color: #1e293b;
    font-weight: 500;
    word-break: break-word;
}

.med-ai-chat-message-content .form-summary-full .form-summary-value {
    font-weight: 400;
    line-height: 1.6;
    white-space: pre-wrap;
}

.med-ai-chat-message-content .medical-table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--spacing-md) 0;
    font-size: 14px;
}

.med-ai-chat-message-content .medical-table th {
    background-color: #F9F9F9;
    font-weight: 600;
    text-align: left;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
}

.med-ai-chat-message-content .medical-table td {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    vertical-align: top;
}

.med-ai-chat-message-content .medical-table .price-cell {
    text-align: right;
    font-family: 'Monaco', 'Menlo', monospace;
}

.med-ai-chat-message-content .medical-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    background-color: white;
}

.med-ai-chat-message-content .medical-card .card-title {
    font-weight: 600;
    color: var(--medical-primary);
    margin-bottom: var(--spacing-sm);
    font-size: 15px;
}

.med-ai-chat-message-content .medical-card .card-row {
    display: flex;
    margin-bottom: 4px;
    font-size: 14px;
}

.med-ai-chat-message-content .medical-card .card-label {
    color: var(--text-secondary);
    min-width: 60px;
    margin-right: var(--spacing-sm);
    font-weight: 500;
}

.med-ai-chat-message-content .med-paragraph {
    margin: 6px 0;
    line-height: 1.6;
}

.med-ai-chat-message-content li > .med-paragraph {
    margin: 0;
    display: inline;
}


.med-ai-chat-message-content .med-hospital-link,
.med-ai-chat-message-content a.med-hospital-link,
.med-ai-chat-message-content .medical-keyword .med-hospital-link,
.med-ai-chat-message-content .medical-keyword a.med-hospital-link {
    color: #2563eb;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
    word-break: break-word;
    border-bottom: none;
    font-weight: 600;
}

.med-ai-chat-message-content .med-hospital-link:hover,
.med-ai-chat-message-content a.med-hospital-link:hover,
.med-ai-chat-message-content .medical-keyword .med-hospital-link:hover,
.med-ai-chat-message-content .medical-keyword a.med-hospital-link:hover {
    color: #1d4ed8;
    text-decoration-color: #1d4ed8;
}

.med-ai-chat-message-content .med-code-block {
    background: var(--bg-light);
    border-radius: 4px;
    padding: var(--spacing-md);
    overflow-x: auto;
    margin: var(--spacing-sm) 0;
    font-size: 13px;
}

.med-ai-chat-message-content .med-code-inline {
    background: var(--bg-light);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
}

@media (max-width: 768px) {
    .med-ai-chat-message-content .module-title { font-size: 16px; }
    .med-ai-chat-message-content .subtitle { font-size: 14px; }
    .med-ai-chat-message-content .medical-table { display: none; }
}

@media (min-width: 769px) {
    .med-ai-chat-message-content .medical-card { display: none; }
}

.med-ai-chat-message.user .med-ai-chat-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.med-ai-chat-message-time {
    font-size: 11px;
    color: #64748b;
    margin-top: 4px;
}

/* 元信息行：时间 + 反馈按钮同行显示 */
.med-ai-chat-message-meta {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-top: 4px;
    padding-left: 44px;
    flex-basis: 100%;
}

.med-ai-chat-message.user .med-ai-chat-message-meta {
    padding-left: 0;
    padding-right: 44px;
    justify-content: flex-end;
}

/* 反馈按钮在元信息行内的内联样式 */
.med-ai-chat-message-meta .med-msg-feedback {
    flex-basis: auto;
    padding-left: 0;
    margin-top: 0;
    display: flex;
    gap: 10px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.med-ai-chat-message-meta .med-msg-feedback:hover {
    opacity: 1;
}

.med-ai-chat-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    width: fit-content;
}

.med-ai-chat-typing-dot {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.med-ai-chat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.med-ai-chat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* 浮窗提示气泡 */
.med-ai-chat-prompt-bubble {
    position: absolute;
    bottom: 100%;
    right: 0; /* 右边缘对齐到 toggle 按钮的右边缘 */
    transform: translateY(-10px);
    background: white;
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    font-weight: 500;
    color: #667eea;
    white-space: nowrap;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    margin-bottom: 10px;
    z-index: 10000;
}

.med-ai-chat-prompt-bubble.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.med-ai-chat-prompt-bubble:hover {
    background: #f8fafc;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

/* 提示气泡小三角 - 现在放在右边 */
.med-ai-chat-prompt-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 24px; /* 小三角在右边，对齐到 toggle 按钮的中心 */
    transform: none;
    border: 8px solid transparent;
    border-top-color: white;
}

.med-ai-chat-prompt-bubble:hover::after {
    border-top-color: #f8fafc;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .med-ai-chat-prompt-bubble {
        font-size: 13px;
        padding: 6px 14px;
        margin-bottom: 8px;
    }

    /* 移动端已经是全屏，隐藏全屏按钮 */
    #med-ai-chat-fullscreen {
        display: none !important;
    }
}

/* 打字指示器动画 */
@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

#med-ai-chat-input-area {
    padding: 16px;
    background: linear-gradient(180deg, #f0f2ff 0%, #e8ebf8 100%);
    border-top: 1px solid #dde3f0;
    flex-shrink: 0;
}

.med-ai-chat-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
}

#med-ai-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#med-ai-chat-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    outline: none;
}

#med-ai-chat-send {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

#med-ai-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#med-ai-chat-send svg {
    width: 20px;
    height: 20px;
}

#med-ai-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.med-ai-chat-form {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.med-ai-chat-form-group {
    margin-bottom: 12px;
}

.med-ai-chat-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 6px;
}

.med-ai-chat-form-group input,
.med-ai-chat-form-group select,
.med-ai-chat-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.med-ai-chat-form-group input:focus,
.med-ai-chat-form-group select:focus,
.med-ai-chat-form-group textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    outline: none;
}

.med-ai-chat-form-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.med-ai-chat-form-button {
    padding: 10px 16px;
    background: #f1f5f9;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.med-ai-chat-form-button:hover {
    background: #e2e8f0;
}

.med-ai-chat-form-button.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
    color: white;
}

.med-ai-chat-form-button.primary:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#med-ai-chat-toggle {
    width: auto;
    height: auto;
    padding: 14px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    white-space: nowrap;
}

.med-ai-chat-toggle-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: white;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

#med-ai-chat-toggle .med-ai-chat-icon-open {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

#med-ai-chat-toggle .med-ai-chat-icon-close {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

@keyframes medAiChatBounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-16px); }
    60% { transform: translateY(-8px); }
}

@keyframes medAiChatPulse {
    0% { box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4); }
    50% { box-shadow: 0 4px 30px rgba(102, 126, 234, 0.8), 0 0 0 12px rgba(102, 126, 234, 0.15); }
    100% { box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4); }
}

#med-ai-chat-toggle:not(.active) {
    animation: medAiChatPulse 2s infinite;
}

#med-ai-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.5);
}

#med-ai-chat-toggle svg {
    position: relative;
    transition: all 0.3s ease;
}

.med-ai-chat-icon-open {
    opacity: 1;
    transform: rotate(0deg);
}

.med-ai-chat-icon-close {
    opacity: 0;
    transform: rotate(-90deg);
    position: absolute;
}

#med-ai-chat-widget.active + #med-ai-chat-toggle .med-ai-chat-icon-open {
    opacity: 0;
    transform: rotate(90deg);
}

#med-ai-chat-widget.active + #med-ai-chat-toggle .med-ai-chat-icon-close {
    opacity: 1;
    transform: rotate(0deg);
}

/* 按钮始终保持方形带标签状态，点击后不变化 */
#med-ai-chat-widget.active + #med-ai-chat-toggle {
    /* 保持不变 */
}

@media (max-width: 768px) {
    /* 容器保持右下角，不拉满宽度，避免 toggle 按钮被推到左侧 */
    #med-ai-chat-container {
        bottom: 0;
        bottom: env(safe-area-inset-bottom, 0);
        right: 0;
        right: env(safe-area-inset-right, 0);
        /* 移除 left: 0，不让容器撑满全宽；全宽由 widget 自行处理 */
    }
    
    #med-ai-chat-widget {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        bottom: 0;
        right: 0;
        /* 聊天窗口打开时向右对齐展开，而非依赖容器撑宽 */
        position: fixed;
        left: 0;
    }
    
    #med-ai-chat-toggle {
        position: fixed;
        bottom: 20px;
        bottom: calc(20px + env(safe-area-inset-bottom, 0));
        right: 20px;
        right: calc(20px + env(safe-area-inset-right, 0));
        left: auto !important;
    }
}

.med-ai-chat-payment-prompt {
    background: #fffbeb;
    border: 2px solid #fbbf24;
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
}

.med-ai-chat-payment-prompt h4 {
    margin: 0 0 8px;
    color: #92400e;
    font-size: 14px;
}

.med-ai-chat-payment-prompt p {
    margin: 0 0 12px;
    color: #78350f;
    font-size: 13px;
}

.med-ai-chat-payment-buttons {
    display: flex;
    gap: 8px;
}

.med-ai-chat-payment-button {
    padding: 10px 16px;
    border: 2px solid #fbbf24;
    background: white;
    color: #333;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.med-ai-chat-payment-button.primary {
    background: linear-gradient(135deg, #52c234 0%, #061700 100%);
    border-color: transparent;
    color: white;
}

.med-ai-chat-payment-button:hover {
    transform: scale(1.02);
}

.med-ai-chat-form-prompt {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 14px;
}

.med-ai-chat-inline-controls {
    margin-top: 8px;
}

.med-ai-chat-inline-input {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
    margin-bottom: 6px;
}

.med-ai-chat-inline-input:focus {
    border-color: #667eea;
}

.med-ai-chat-inline-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    resize: vertical;
    transition: border-color 0.2s;
    box-sizing: border-box;
    margin-bottom: 6px;
    font-family: inherit;
}

.med-ai-chat-inline-textarea:focus {
    border-color: #667eea;
}

.med-ai-chat-inline-select {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    background: white;
    box-sizing: border-box;
    margin-bottom: 6px;
    cursor: pointer;
}

.med-ai-chat-inline-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.med-ai-chat-inline-btn {
    padding: 10px 22px;
    border: 1.5px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #333;
    min-width: 80px;
    text-align: center;
}

.med-ai-chat-inline-btn:hover {
    background: #f0f0ff;
    border-color: #667eea;
    transform: scale(1.02);
}

.med-ai-chat-inline-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
    color: white;
    margin-top: 4px;
}

.med-ai-chat-inline-btn.primary:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

/* 跳过按钮样式 */
.med-ai-chat-inline-btn.skip {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #92400e;
    margin-top: 6px;
}

.med-ai-chat-inline-btn.skip:hover {
    background: #fde68a;
    border-color: #d97706;
}

.med-ai-chat-inline-btn.speed-up {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    margin-top: 8px;
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s;
}

.med-ai-chat-inline-btn.speed-up:hover {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.med-ai-chat-fullform-title {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #6366f1;
}

.med-ai-chat-fullform-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.med-ai-chat-fullform-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.med-ai-chat-fullform-label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.med-ai-chat-fullform-input,
.med-ai-chat-fullform-select,
.med-ai-chat-fullform-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.med-ai-chat-fullform-input:focus,
.med-ai-chat-fullform-select:focus,
.med-ai-chat-fullform-textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.med-ai-chat-fullform-textarea {
    resize: vertical;
    min-height: 60px;
}

.med-ai-chat-fullform-radio-wrap {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.med-ai-chat-fullform-radio-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    cursor: pointer;
}

.med-ai-chat-fullform-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
}

.med-ai-chat-fullform-actions .med-ai-chat-inline-btn.primary {
    padding: 10px 24px;
    font-size: 15px;
    border-radius: 8px;
}

.med-ai-chat-fullform-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.4;
}


.med-ai-chat-session-marker {
    text-align: center;
    color: #94a3b8;
    font-size: 12px;
    padding: 8px 0;
    margin: 4px 0;
    border-top: 1px solid #e2e8f0;
    position: relative;
}

.med-ai-chat-session-marker::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 2px;
    background: #cbd5e1;
}

.med-ai-chat-header-bubble {
    position: absolute;
    bottom: -56px;
    left: 70%;
    transform: translateX(-50%) translateY(4px);
    background: #667eea;
    color: #fff;
    font-size: 13px;
    padding: 7px 16px;
    border-radius: 10px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    z-index: 20;
    box-shadow: 0 3px 12px rgba(102, 126, 234, 0.35);
}

.med-ai-chat-header-bubble::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 40%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #667eea;
}

.med-ai-chat-header-bubble-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ========== Crisis Intervention Overlay ========== */
.med-crisis-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99999999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: med-crisis-fadein 0.3s ease;
}

@keyframes med-crisis-fadein {
    from { opacity: 0; }
    to { opacity: 1; }
}

.med-crisis-card {
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px;
    z-index: 99999999;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-height: 85vh;
    overflow-y: auto;
}

.med-crisis-message {
    font-size: 14px;
    line-height: 1.7;
    color: #1e293b;
    text-align: left;
    margin-bottom: 20px;
}

.med-crisis-message strong {
    color: #dc2626;
}

.med-crisis-confirm-btn {
    display: block;
    width: 100%;
    padding: 12px 20px;
    background: #dc2626;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.med-crisis-confirm-btn:hover {
    background: #b91c1c;
}

.med-crisis-confirm-btn:focus-visible {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.3);
}

.med-crisis-pause-note {
    font-size: 12px;
    color: #64748b;
    margin-top: 12px;
}

.med-crisis-feedback {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
    font-size: 13px;
    color: #64748b;
}

.med-crisis-feedback-label {
    display: block;
    margin-bottom: 8px;
}

.med-crisis-feedback-btn {
    display: inline-block;
    padding: 6px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    color: #475569;
    font-size: 12px;
    cursor: pointer;
    margin: 0 4px;
    transition: all 0.15s;
}

.med-crisis-feedback-btn:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}

.med-crisis-feedback-no {
    color: #64748b;
}

.med-crisis-feedback-thanks {
    font-size: 12px;
    color: #10b981;
}

.med-crisis-care {
    border-left: 3px solid #f59e0b;
    padding-left: 12px;
    background: #fffbeb;
    border-radius: 0 8px 8px 0;
}

/* ========== Hospital Information Card ========== */
.med-hospital-cards-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 8px 0;
    padding-left: 44px;
}

.med-hospital-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    flex: 1 1 280px;
    max-width: 340px;
    min-width: 260px;
    margin: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* 折叠/展开头部 */
.med-hospital-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
    gap: 8px;
}
.med-hospital-card-header:hover {
    background: #f8fafc;
}
.med-hospital-card-header:focus {
    outline: none;
    background: #f1f5f9;
    box-shadow: inset 0 0 0 2px #3b82f6;
}
.med-hospital-card-header-name {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.med-hospital-card-toggle-text {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
    color: #3b82f6;
    background: #eff6ff;
    border: 1.5px solid #bfdbfe;
    border-radius: 6px;
    padding: 3px 10px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    user-select: none;
}
.med-hospital-card-toggle-text:hover {
    background: #3b82f6;
    color: #fff;
}

/* 折叠内容区 */
.med-hospital-card-body {
    max-height: 800px;
    overflow-y: auto;
    transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.3s ease;
    opacity: 1;
}

/* 折叠状态 */
.med-hospital-card-collapsed .med-hospital-card-body {
    max-height: 0 !important;
    opacity: 0;
    visibility: hidden;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.med-hospital-card-image-wrap {
    position: relative;
    width: 100%;
    max-height: 160px;
    overflow: hidden;
    background: #f1f5f9;
}

.med-hospital-card-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

.med-hospital-card-image-source {
    position: absolute;
    bottom: 6px;
    right: 8px;
    font-size: 10px;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 6px;
    border-radius: 3px;
}

.med-hospital-card-name {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    padding: 10px 12px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.med-hospital-card-intro {
    font-size: 12px;
    line-height: 1.6;
    color: #64748b;
    padding: 0 12px 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.med-hospital-card-departments {
    font-size: 12px;
    color: #475569;
    padding: 0 12px 8px;
    font-weight: 500;
}

.med-hospital-card-actions {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid #f1f5f9;
}

.med-hospital-card-link {
    display: inline-block;
    padding: 5px 14px;
    background: #3b82f6;
    color: #fff;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s;
}

.med-hospital-card-link:hover {
    background: #2563eb;
}

.med-hospital-card-verify-link {
    display: inline-block;
    padding: 5px 14px;
    background: #f8fafc;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    text-decoration: none;
    transition: all 0.15s;
}

.med-hospital-card-verify-link:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.med-hospital-card-disclaimer {
    padding: 6px 12px 10px;
    line-height: 1.5;
    border-top: 1px solid #f1f5f9;
}
.med-hospital-card-disclaimer-warning {
    font-size: 11px;
    font-weight: 600;
    color: #b45309;
    margin-bottom: 2px;
}
.med-hospital-card-disclaimer-source {
    font-size: 10px;
    font-weight: 400;
    color: #94a3b8;
}

/* WP 增强信息区块（追加在消息内部） */
.med-wp-enrichment-block {
    margin-top: 12px;
    padding: 0 0 0 44px;
    font-size: 14px;
    line-height: 1.7;
    color: #334155;
}
.med-wp-enrichment-block > *:first-child {
    margin-top: 0;
}
.med-wp-enrichment-block h2,
.med-wp-enrichment-block h3,
.med-wp-enrichment-block h4 {
    font-weight: 700;
    color: #1e293b;
    margin: 14px 0 6px;
}
.med-wp-enrichment-block h2 { font-size: 16px; }
.med-wp-enrichment-block h3 { font-size: 15px; }
.med-wp-enrichment-block h4 { font-size: 14px; }
.med-wp-enrichment-block p {
    margin: 6px 0;
}
.med-wp-enrichment-block ul,
.med-wp-enrichment-block ol {
    margin: 6px 0;
    padding-left: 20px;
}
.med-wp-enrichment-block li {
    margin: 3px 0;
}
.med-wp-enrichment-block img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 8px 0;
}
.med-wp-enrichment-block a {
    color: #2563eb;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.med-wp-enrichment-block strong {
    font-weight: 700;
    color: #1e293b;
}
.med-wp-enrichment-block blockquote {
    border-left: 3px solid #3b82f6;
    padding-left: 12px;
    margin: 8px 0;
    color: #64748b;
}
.med-wp-enrichment-block table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
}
.med-wp-enrichment-block th,
.med-wp-enrichment-block td {
    border: 1px solid #e2e8f0;
    padding: 6px 10px;
    font-size: 13px;
}
.med-wp-enrichment-block th {
    background: #f8fafc;
    font-weight: 600;
}

/* ========== Per-Message Feedback ========== */
.med-msg-feedback {
    display: flex;
    gap: 10px;
    margin-top: 4px;
    opacity: 0.65;
    transition: opacity 0.2s;
}

.med-ai-chat-message:hover .med-msg-feedback {
    opacity: 1;
}

.med-msg-feedback-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    color: #64748b;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    position: relative;
}

.med-msg-feedback-btn::after {
    content: attr(data-label);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #334155;
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    margin-bottom: 4px;
    z-index: 10;
}

.med-msg-feedback-btn:hover::after {
    opacity: 1;
}

.med-msg-feedback-btn:hover:not(.med-msg-feedback-disabled) {
    border-color: #64748b;
    background: #f1f5f9;
    color: #1e293b;
}

.med-msg-feedback-selected {
    border-color: #3b82f6 !important;
    color: #3b82f6 !important;
    background: #eff6ff !important;
}

.med-msg-feedback-disabled {
    cursor: default;
    opacity: 0.5 !important;
}

.med-msg-feedback-reason {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #f1f5f9;
}

.med-msg-feedback-reason-btn {
    padding: 3px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    color: #64748b;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.15s;
}

.med-msg-feedback-reason-btn:hover:not(.med-msg-feedback-disabled) {
    border-color: #94a3b8;
    opacity: 0.35;
    transition: opacity 0.2s;
}

.med-ai-chat-message.assistant .med-msg-feedback {
    padding-left: 44px;
}

.med-ai-chat-message.assistant .med-ai-chat-message-meta .med-msg-feedback {
    flex-basis: auto;
    padding-left: 0;
}

.med-hospital-cards-meta {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-basis: 100%;
    padding-left: 8px;
    margin-top: 8px;
}

.med-hospital-cards-meta .med-msg-feedback {
    padding-left: 0;
    margin-top: 0;
    opacity: 0.65;
    transition: opacity 0.2s;
}

.med-hospital-cards-meta .med-ai-chat-message-time {
    margin-top: 0;
}

.med-hospital-cards-meta:hover .med-msg-feedback {
    opacity: 1;
}

.med-wp-enrichment {
    margin-top: 12px;
    padding: 14px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
}

.med-wp-enrichment-intro {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: var(--color-text-secondary, #666);
}

.med-wp-enrichment-item {
    margin-bottom: 14px;
}

.med-wp-enrichment-item:last-child {
    margin-bottom: 0;
}

/* 快捷回复按钮容器：flex 布局 + 间距 */
.med-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0 4px 44px;
}

.med-quick-reply-btn {
    padding: 6px 14px;
    border: 1px solid #3b82f6;
    border-radius: 16px;
    background: #fff;
    color: #3b82f6;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.med-quick-reply-btn:hover {
    background: #3b82f6;
    color: #fff;
}

.med-quick-reply-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4);
    outline: none;
}

/* ========== Privacy Consent Panel ========== */
.med-privacy-panel {
    position: absolute;
    bottom: 0;
    right: 0;
    z-index: 9999999;
    animation: med-privacy-slidein 0.3s ease;
}

@keyframes med-privacy-slidein {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.med-privacy-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    width: 320px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    font-size: 13px;
}

.med-privacy-title {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
}

.med-privacy-desc {
    color: #64748b;
    margin-bottom: 12px;
    line-height: 1.5;
}

.med-privacy-option {
    display: block;
    padding: 8px 10px;
    margin-bottom: 6px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.4;
}

.med-privacy-option:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}

.med-privacy-option input[type="radio"] {
    margin-right: 6px;
    vertical-align: top;
    margin-top: 2px;
}

.med-privacy-option span {
    color: #475569;
    font-size: 12px;
}

.med-privacy-confirm {
    display: block;
    width: 100%;
    padding: 8px;
    margin-top: 10px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.med-privacy-confirm:hover {
    background: #2563eb;
}

/* ========== Leave Intent ========== */
.med-leave-intent {
    position: relative;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 10px 32px 10px 12px;
    margin: 8px 0;
    font-size: 13px;
    color: #1e40af;
    line-height: 1.5;
    animation: med-leave-fadein 0.3s ease;
}

@keyframes med-leave-fadein {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.med-leave-intent-close {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: #93c5fd;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.med-leave-intent-close:hover {
    color: #1e40af;
}

/* ========== Personalized Greeting ========== */
.med-personalized-greeting {
    background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
    border-left: 3px solid #3b82f6;
    border-radius: 0 8px 8px 0;
    padding: 2px 0;
}

/* ========== Print Styles ========== */
@media print {
    #med-ai-chat-widget,
    #med-ai-chat-toggle,
    .med-ai-chat-leave-intent,
    .med-privacy-panel,
    #med-ai-chat-input-container,
    .med-quick-replies,
    .med-msg-feedback {
        display: none !important;
    }
    .med-ai-chat-messages {
        overflow: visible !important;
        height: auto !important;
    }
    .med-ai-chat-message {
        break-inside: avoid;
    }
}

/* ========== Focus Visible Styles ========== */
.decision-btn:focus-visible,
.med-ai-chat-form-button:focus-visible,
.med-ai-chat-payment-button:focus-visible,
.med-ai-chat-inline-btn:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
}
