/* SmartCS Widget Styles */
#smartcs-root { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; z-index: 999999; }
.smartcs-pos-right { position: fixed; bottom: 20px; right: 20px; }
.smartcs-pos-left  { position: fixed; bottom: 20px; left: 20px; }

.smartcs-toggle {
    width: 80px !important; height: 80px !important; border-radius: 50%;
    background: transparent; border: none; cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s;
    position: relative; z-index: 2;
    overflow: hidden;
    padding: 0;
}
.smartcs-toggle:hover { transform: scale(1.1); }

/* Red badge */
.smartcs-badge {
    position: absolute; top: -2px; right: -2px;
    width: 18px; height: 18px; border-radius: 50%;
    background: #ff3b30; border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    z-index: 3; pointer-events: none;
}
.smartcs-badge.count {
    width: auto; min-width: 18px; height: 18px;
    padding: 0 5px; border-radius: 9px;
    color: white; font-size: 11px; font-weight: 700;
    line-height: 18px; text-align: center;
    white-space: nowrap;
}
.smartcs-toggle img {
    width: 100%; height: 100%; object-fit: cover;
    border-radius: 50%;
}

.smartcs-panel {
    position: absolute; bottom: 66px; right: 0;
    width: 370px; height: 540px; max-height: calc(100vh - 120px);
    background: white; border-radius: 16px; box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    display: none; flex-direction: column; overflow: hidden;
}
.smartcs-pos-left .smartcs-panel { right: auto; left: 0; }
#smartcs-root.open .smartcs-panel { display: flex; }
#smartcs-root.open .smartcs-toggle { display: none; }

.smartcs-header {
    padding: 14px 18px; color: white; display: flex; align-items: center; gap: 8px;
}
.smartcs-title { font-weight: 600; font-size: 15px; flex: 1; }
.smartcs-status { font-size: 11px; opacity: 0.85; }
.smartcs-close-btn { background: none; border: none; color: white; font-size: 18px; cursor: pointer; opacity: 0.7; padding: 4px; }

.smartcs-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; background: #f5f7fa; }
.smartcs-msg { margin-bottom: 10px; display: flex; }
.smartcs-msg.user { justify-content: flex-end; }
.smartcs-bubble {
    max-width: 80%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5;
    word-wrap: break-word; white-space: pre-wrap;
}
.smartcs-msg.assistant .smartcs-bubble { background: white; color: #333; border: 1px solid #e0e0e0; }
.smartcs-msg.user .smartcs-bubble { background: #0073aa; color: white; }

.smartcs-sender { font-size: 11px; color: #888; margin-bottom: 2px; padding: 0 4px; }

.smartcs-tools { padding: 8px 14px; border-top: 1px solid #e8e8e8; background: white; display: flex; flex-shrink: 0; }
.smartcs-tool-btn {
    padding: 6px 14px; border: 1px solid #ddd; border-radius: 20px;
    background: white; cursor: pointer; font-size: 13px; color: #555;
}
.smartcs-tool-btn:hover { background: #f0f0f0; }

.smartcs-input-wrap {
    display: flex; padding: 10px 12px; border-top: 1px solid #e0e0e0; background: white; gap: 8px; flex-shrink: 0;
}
.smartcs-input {
    flex: 1; padding: 10px 14px; border: 1px solid #ddd; border-radius: 20px; font-size: 14px; outline: none;
}
.smartcs-input:focus { border-color: #0073aa; }
.smartcs-send-btn {
    width: 40px; height: 40px; border-radius: 50%; background: #0073aa;
    border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.smartcs-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* ====== Media Buttons ====== */
.smartcs-input-actions {
    display: flex; align-items: center; gap: 4px;
    padding: 0 0 0 8px;
}
.smartcs-media-btn, .smartcs-voice-btn {
    background: none; border: none; cursor: pointer;
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #0073aa; opacity: 0.65; transition: opacity 0.2s, background 0.2s;
    flex-shrink: 0; padding: 0;
}
.smartcs-media-btn:hover, .smartcs-voice-btn:hover {
    opacity: 1; background: rgba(0,115,170,0.08);
}
.smartcs-voice-btn.recording {
    opacity: 1; background: #ff4444; color: white; animation: smartcs-pulse 1s infinite;
}
@keyframes smartcs-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255,68,68,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(255,68,68,0); }
}
.recording-dot {
    display: inline-block; width: 12px; height: 12px;
    background: white; border-radius: 50%; animation: smartcs-blink 0.5s infinite;
}
#smartcs-voice-timer {
    font-size: 11px; color: #ff4444; font-weight: 600;
    display: none; margin: 0 2px; min-width: 35px; text-align: center;
}

/* ====== Media Messages ====== */
.smartcs-media-bubble {
    padding: 4px; max-width: 70%; overflow: hidden;
}
.smartcs-image-msg {
    max-width: 100%; max-height: 240px; border-radius: 10px;
    cursor: pointer; display: block;
    transition: transform 0.2s;
}
.smartcs-image-msg:hover {
    transform: scale(1.02);
}
.smartcs-voice-msg {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 0;
}
.smartcs-voice-play {
    width: 36px; height: 36px; border-radius: 50%;
    background: #0073aa; color: white; border: none;
    cursor: pointer; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: transform 0.15s;
}
.smartcs-voice-play:hover { transform: scale(1.1); }
.smartcs-voice-label {
    font-size: 13px; color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.smartcs-system-msg {
    background: #fef3e2; color: #8b6914; border: 1px solid #ffeeba; text-align: center;
    font-size: 12px;
}

.smartcs-footer { padding: 8px 16px; text-align: center; background: #f5f5f5; font-size: 11px; color: #999; flex-shrink: 0; }

/* 支付截图上传 */
.smartcs-screenshot-upload {
    display: flex; flex-direction: column; gap: 10px; align-items: center;
    margin: 10px 16px; padding: 14px; background: #fff8f0;
    border: 1px dashed #ffb37a; border-radius: 8px; animation: smartcs-fadein 0.3s ease;
}
.smartcs-screenshot-tip {
    font-size: 13px; color: #8b6914; text-align: center; line-height: 1.5;
}
.smartcs-screenshot-btn {
    display: inline-block; padding: 8px 18px; background: #ff6b35; color: #fff;
    border-radius: 6px; cursor: pointer; font-size: 14px; text-align: center;
    transition: background 0.2s;
}
.smartcs-screenshot-btn:hover { background: #e55a2b; }
.smartcs-screenshot-btn.disabled { background: #ccc; pointer-events: none; }
.smartcs-screenshot-status { font-size: 12px; color: #666; text-align: center; }

/* Scrollbar */
.smartcs-msgs::-webkit-scrollbar { width: 4px; }
.smartcs-msgs::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* Animations */
@keyframes smartcs-fadein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.smartcs-msg { animation: smartcs-fadein 0.3s ease; }
.smartcs-typing .smartcs-bubble:after { content: "▊"; animation: smartcs-blink 1s infinite; }
@keyframes smartcs-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Admin */
.smartcs-admin .smartcs-section { background: white; padding: 16px 24px; margin: 0 0 20px; border: 1px solid #c3c4c7; border-radius: 8px; }
.smartcs-admin .smartcs-section h2 { margin-top: 0; padding-bottom: 12px; border-bottom: 1px solid #f0f0f1; }
.smartcs-test-result { margin-left: 10px; font-weight: 500; }
.smartcs-lvl-error { color: #d63638; font-weight: 600; }
.smartcs-lvl-info { color: #2271b1; }
