.floating-chat-btn {
    position: fixed;
    bottom: 32px;
    left: 300px;
    background: linear-gradient(135deg, var(--ios-primary) 0%, var(--ios-purple) 100%);
    color: white;
    border: none;
    border-radius: 30px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(28, 156, 252, 0.4);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 900;
    font-family: var(--ios-font);
}

body:not(.has-sidebar) .floating-chat-btn {
    left: 32px;
}

.floating-chat-btn:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 20px 40px rgba(28, 156, 252, 0.4);
}

.floating-chat-btn:active {
    transform: translateY(-2px) scale(1.02);
}

.floating-chat-btn i {
    font-size: 20px;
}

.chat-btn-label {
    font-weight: 600;
}

.floating-chat-btn.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(100px);
}

.chat-widget {
    position: fixed;
    bottom: 32px;
    left: 300px;
    width: 380px;
    height: 500px;
    background: var(--ios-card-bg);
    border-radius: var(--ios-radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 900;
    overflow: hidden;
}

body:not(.has-sidebar) .chat-widget {
    left: 32px;
}

.chat-widget.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

.chat-widget.minimized {
    height: 64px;
}

.chat-widget-header {
    background: #ffffff;
    color: #1d1d1f;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 1px solid #e5e5ea;
}

.chat-header-info {
    display: flex;
    flex-direction: row !important;
    align-items: center;
    gap: 14px;
    flex-wrap: nowrap;
}

.chat-avatar {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    border-radius: 50%;
    background: #f5f5f7;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: flex-start;
    overflow: hidden;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-avatar i {
    display: block;
    line-height: 1;
    font-size: 20px;
    color: #9b7bb8;
}

.chat-header-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    min-height: 42px;
}

.chat-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    padding: 0;
    line-height: 1.2;
    color: #9b7bb8;
    display: block;
}

.chat-status {
    font-size: 13px;
    margin: 0;
    padding: 0;
    font-weight: 500;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    line-height: 1;
    color: #34c759;
    flex-wrap: nowrap;
}

.chat-status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34c759;
    box-shadow: 0 0 6px rgba(52, 199, 89, 0.5);
    animation: pulse-status 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse-status {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 6px rgba(52, 199, 89, 0.5);
    }
    50% {
        opacity: 0.7;
        box-shadow: 0 0 10px rgba(52, 199, 89, 0.7);
    }
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f5f5f7;
    color: #6e6e73;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-action-btn:hover {
    background: #e5e5ea;
}

.chat-action-btn:active {
    transform: scale(0.9);
}

#ttsSpeakerBtn {
    color: var(--ios-green);
    background: rgba(52, 199, 89, 0.15);
}

#ttsSpeakerBtn:hover {
    background: rgba(52, 199, 89, 0.25);
}

#ttsSpeakerBtn .bi-volume-mute-fill {
    color: var(--ios-text-secondary);
}

.chat-action-btn.medical-mode-btn {
    background: #f5f5f7;
}

.chat-action-btn.medical-mode-btn:hover {
    background: #e5e5ea;
}

.chat-action-btn.medical-mode-btn.active {
    background: linear-gradient(135deg, #FF6B6B 0%, #EE5A5A 100%);
    box-shadow: 0 2px 8px rgba(238, 90, 90, 0.4);
}

.chat-action-btn.medical-mode-btn.active .medical-icon {
    filter: brightness(0) invert(1);
}

.chat-action-btn.medical-mode-btn .medical-icon {
    width: 20px;
    height: 20px;
    transition: filter 0.2s ease;
}

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

.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    height: 100%;
}

.welcome-message {
    background: #f5f5f7;
    border-radius: 18px;
    padding: 16px 24px;
    max-width: 280px;
}

.welcome-text {
    font-size: 16px;
    color: #1d1d1f;
    line-height: 1.5;
    display: block;
    text-align: center;
}

.chat-message {
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
}

.chat-message.user {
    flex-direction: row-reverse;
}

.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: var(--ios-radius);
    font-size: 15px;
    line-height: 1.4;
}

.chat-message.assistant .message-bubble {
    background: #ffffff;
    color: #1d1d1f;
    border-bottom-left-radius: 4px;
    border: 1px solid #e0e0e0;
}

.message-bubble::selection {
    background: #007aff;
    color: #ffffff;
}

.message-bubble::-moz-selection {
    background: #007aff;
    color: #ffffff;
}

.chat-message.assistant .message-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    background: #f5f5f7;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #9b7bb8;
    font-size: 1.1rem;
    overflow: hidden;
}

.chat-message.assistant .message-avatar .wilbur-mini-canvas {
    width: 40px;
    height: 40px;
}

.wilbur-welcome {
    margin-top: auto;
}

.wilbur-welcome .message-bubble {
    font-weight: 500;
}

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

.message-time {
    font-size: 11px;
    color: var(--ios-text-secondary);
    margin-top: 4px;
    text-align: right;
}

.message-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}

.message-speaker-btn {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    font-size: 1rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.message-speaker-btn i {
    transition: all 0.2s ease;
}

.message-speaker-btn:hover:not(.playing):not(.loading) {
    background: #047e4d;
    border-color: #047e4d;
    color: white;
}

.message-speaker-btn:active {
    transform: scale(0.9);
}

.message-speaker-btn.playing {
    background: #047e4d;
    border-color: #047e4d;
    color: white;
    animation: pulse-btn 1.5s infinite;
}

.message-speaker-btn.loading {
    background: #f59e0b;
    border-color: #f59e0b;
    color: white;
    animation: spin-btn 1s linear infinite;
}

.message-speaker-btn.error {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
}

@keyframes pulse-btn {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(4, 126, 77, 0.7);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(4, 126, 77, 0);
    }
}

@keyframes spin-btn {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.chat-widget-input {
    padding: 12px 16px;
    background: var(--ios-card-bg);
    border-top: 1px solid var(--ios-separator);
    flex-shrink: 0;
}

.widget-attachment-preview {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 8px;
}

.widget-attachment-preview:has(.attachment-preview-item) {
    display: flex;
}

.attachment-preview-item {
    position: relative;
    background: #f5f5f7;
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.attachment-preview-item img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.pdf-preview-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pdf-preview-content i {
    color: #DC2626;
    font-size: 20px;
}

.pdf-filename {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdf-size {
    color: #6e6e73;
    font-size: 11px;
}

.remove-attachment-btn {
    background: rgba(0,0,0,0.1);
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    color: #666;
}

.remove-attachment-btn:hover {
    background: rgba(0,0,0,0.2);
}

.chat-input-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-left-actions,
.input-right-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.input-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--ios-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.input-action-btn svg {
    width: 20px;
    height: 20px;
}

.input-action-btn:hover {
    background: rgba(28, 156, 252, 0.1);
}

.input-action-btn:active {
    transform: scale(0.9);
}

.input-action-btn.recording {
    color: var(--ios-red);
    animation: pulse 1.5s ease-in-out infinite;
}

.input-action-btn.send-btn {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    right: 0;
}

.input-action-btn.send-btn.show {
    opacity: 1;
    pointer-events: all;
}

.input-action-btn.mic-btn.hide {
    opacity: 0;
    pointer-events: none;
}

.input-right-actions {
    position: relative;
    width: 36px;
    height: 36px;
}

.input-wrapper {
    flex: 1;
    min-width: 0;
}

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

.chat-input {
    flex: 1;
    border: none;
    background: #f5f5f7;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 15px;
    font-family: var(--ios-font);
    color: #1c1c1e;
    outline: none;
    -webkit-text-fill-color: #1c1c1e;
}

.chat-input::placeholder {
    color: var(--ios-text-secondary);
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ios-text-secondary);
    animation: typing 1.4s infinite;
}

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

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

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

.medical-mode-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.medical-mode-modal.active {
    display: flex;
}

.medical-mode-modal-content {
    background: white;
    border-radius: 20px;
    max-width: 420px;
    width: 90%;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: medicalModalSlideIn 0.3s ease;
}

@keyframes medicalModalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.medical-mode-modal-header {
    padding: 24px 24px 16px;
    text-align: center;
    background: linear-gradient(135deg, #FFF5F5 0%, #FFF 100%);
    border-bottom: 1px solid rgba(238, 90, 90, 0.1);
}

.medical-modal-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
}

.medical-mode-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1d1d1f;
}

.medical-mode-modal-body {
    padding: 20px 24px;
}

.medical-mode-modal-body p {
    margin: 0 0 16px;
    color: #3c3c43;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.medical-mode-modal-body ul {
    margin: 0 0 16px;
    padding-left: 20px;
}

.medical-mode-modal-body li {
    color: #3c3c43;
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 8px;
}

.medical-disclaimer-box {
    background: #FEF3C7;
    border: 1px solid #F59E0B;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 0.8125rem;
    color: #92400E;
    line-height: 1.5;
}

.medical-mode-modal-footer {
    padding: 16px 24px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.dont-show-again {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.8125rem;
    color: #6e6e73;
}

.dont-show-again input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--ios-primary);
}

.medical-mode-modal-footer .btn-primary {
    padding: 12px 28px;
    font-size: 0.9375rem;
    border-radius: 12px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--ios-primary), var(--ios-indigo));
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(28, 156, 252, 0.3);
    transition: all 0.2s ease;
}

.medical-mode-modal-footer .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(28, 156, 252, 0.4);
}

.medical-mode-modal-footer .btn-primary:active {
    transform: translateY(0);
}

@media (max-width: 768px) {
    .chat-widget {
        width: calc(100vw - 32px);
        left: 16px;
        bottom: 16px;
    }

    .floating-chat-btn {
        bottom: 16px;
        left: 16px;
    }

    body.has-sidebar .chat-widget,
    body.has-sidebar .floating-chat-btn {
        left: 16px;
    }
}

@media (max-width: 480px) {
    .chat-widget {
        height: calc(100vh - 100px);
    }
}
