/* Chat Widget */
#med-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Toggle Button */
#med-chat-toggle {
    width: 60px;
    height: 60px;
    background: #0066cc;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    color: white;
}

#med-chat-toggle:hover {
    background: #0052a3;
    transform: scale(1.05);
}

#med-chat-toggle.chat-open {
    display: none;
}

/* Chat Box */
#med-chat-box {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#med-chat-box.show {
    display: flex !important;
}

/* Header */
.med-chat-header {
    background: linear-gradient(135deg, #0066cc 0%, #0052a3 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.med-chat-title {
    font-weight: 600;
    font-size: 16px;
    flex: 1;
}

.med-chat-status {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.med-chat-status.authenticated {
    background: #059669;
}

.med-chat-status.guest {
    background: #f59e0b;
}

.med-chat-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.med-chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Body */
.med-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f9fafb;
}

#med-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Footer */
.med-chat-footer {
    padding: 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
}

#med-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#med-chat-input:focus {
    border-color: #0066cc;
}

#med-chat-input:disabled {
    background: #f3f4f6;
    cursor: not-allowed;
}

#med-chat-send {
    padding: 10px 20px;
    background: #0066cc;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

#med-chat-send:hover:not(:disabled) {
    background: #0052a3;
}

#med-chat-send:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #med-chat-box {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        bottom: 80px;
    }
}/* ========================================
   MEDICAL PLATFORM - CHAT WIDGET CSS
   Performance-optimized with GPU acceleration
   ======================================== */

/* Container */
#med-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    pointer-events: none;
    z-index: 10000;
}

#med-chat-toggle,
#med-chat-box {
    pointer-events: auto !important;
}

/* Toggle Button */
#med-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    color: white;
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

#med-chat-toggle:hover {
    transform: scale(1.1) translateZ(0);
    box-shadow: 0 6px 16px rgba(13, 148, 136, 0.3);
}

#med-chat-toggle.chat-open {
    display: none;
}

#med-chat-toggle svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Chat Box */
#med-chat-box {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 550px;
    max-height: calc(100vh - 124px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform: translateZ(0);
    will-change: transform, opacity;
    backface-visibility: hidden;
}

#med-chat-box.show {
    display: flex;
}

/* Header */
.med-chat-header {
    background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
    color: white;
    padding: 7px 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.med-header-left {
    flex: 1;
    min-width: 0;
}

.med-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.med-chat-header h3,
.med-chat-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.med-canvas-toggle,
.med-chat-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s ease;
    touch-action: manipulation;
    transform: translateZ(0);
}

.med-canvas-toggle:hover,
.med-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.med-chat-close {
    font-size: 28px;
    line-height: 1;
}

.med-chat-status {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.med-chat-status.authenticated {
    background: #059669;
}

.med-chat-status.guest {
    background: #f59e0b;
}

/* Messages Container */
.med-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    contain: layout style;
    will-change: scroll-position;
}

.med-chat-body::-webkit-scrollbar {
    width: 6px;
}

.med-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.med-chat-body::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.med-chat-body::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.med-chat-messages,
#med-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Messages */
.med-chat-message {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
    contain: layout style paint;
    content-visibility: auto;
    animation: messageSlideIn 0.3s ease;
    will-change: transform, opacity;
    transform: translateZ(0);
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translate3d(0, 10px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

.med-chat-message.user {
    background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.med-chat-message.assistant {
    background: #ffffff;
    color: #2d3748;
    margin-right: auto;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.med-chat-message img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-top: 8px;
    display: block;
}

.med-chat-message a {
    color: inherit;
    text-decoration: underline;
}

.med-chat-message.user a {
    color: #ccfbf1;
}

.med-chat-message.assistant a {
    color: #0d9488;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 18px 16px;
    background: #ffffff;
    border-radius: 12px;
    max-width: 85%;
    margin-right: auto;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e0;
    animation: typing 1.4s infinite;
    will-change: transform, opacity;
    transform: translateZ(0);
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translate3d(0, 0, 0);
        opacity: 0.7;
    }
    30% {
        transform: translate3d(0, -10px, 0);
        opacity: 1;
    }
}

/* Canvas Wrapper */
.med-canvas-wrapper {
    background: #1e1e1e;
    border-top: 1px solid #e2e8f0;
    position: relative;
    flex-shrink: 0;
    transform: translateZ(0);
    will-change: height;
}

.med-canvas-header {
    background: rgba(13, 148, 136, 0.1);
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(13, 148, 136, 0.2);
}

.med-canvas-title {
    color: #0d9488;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.med-visualizer {
    width: 100%;
    height: 100px;
    background-color: #1e1e1e;
    display: block;
    transform: translateZ(0);
}

/* Input Footer */
.med-chat-footer {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

#med-chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    transition: border-color 0.2s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    contain: layout style;
}

#med-chat-input:focus {
    outline: none;
    border-color: #0d9488;
}

#med-chat-input:disabled {
    background: #f7fafc;
    cursor: not-allowed;
}

#med-chat-input::-webkit-scrollbar {
    width: 4px;
}

#med-chat-input::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

.med-record-button,
#med-chat-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: #0d9488;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    touch-action: manipulation;
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.med-record-button:hover,
#med-chat-send:hover:not(:disabled) {
    background: #0f766e;
    transform: scale(1.05) translateZ(0);
}

.med-record-button:active,
#med-chat-send:active:not(:disabled) {
    transform: scale(0.95) translateZ(0);
}

.med-record-button.recording {
    background: #dc2626;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

#med-chat-send:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
}

/* Empty State */
.med-chat-messages:empty::before,
#med-chat-messages:empty::before {
    content: 'Inicia una conversación...';
    display: block;
    text-align: center;
    color: #a0aec0;
    padding: 40px 20px;
    font-size: 14px;
}

/* Responsive - Tablet */
@media (max-width: 1024px) {
    #med-chat-widget {
        z-index: 9994;
    }
    
    #med-chat-box {
        z-index: 9995;
    }
}

/* Responsive - Mobile */
@media (max-width: 767px) {
    #med-chat-widget {
        right: 10px;
        bottom: 70px;
    }
    
    #med-chat-box {
        width: 100vw;
        height: calc(100vh - 164px);
        right: 0;
        top: auto;
        bottom: 60px;
        left: 0;
        border-radius: 0;
        max-height: none;
    }
    
    .med-chat-message {
        max-width: 90%;
    }
}

/* Responsive - Desktop */
@media (min-width: 768px) and (max-width: 1024px) {
    #med-chat-box {
        width: 380px;
        z-index: 10000;
    }
    
    #med-chat-widget {
        z-index: 10000;
    }
}