/* Enhanced Reformix Chat CSS - Modern Design */

/* Reformix Message Bubbles */
.reformix-msg {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
    animation: reformixMessageSlide 0.3s ease-out;
}

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

.reformix-msg.reformix-user {
    align-items: flex-end;
}

.reformix-msg.reformix-admin {
    align-items: flex-start;
}

.reformix-msg-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 20px;
    position: relative;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
}

.reformix-msg.reformix-user .reformix-msg-content {
    background: linear-gradient(135deg, var(--reformix-primary-color, #667eea) 0%, var(--reformix-primary-dark, #5a67d8) 100%);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.reformix-msg.reformix-admin .reformix-msg-content {
    background: white;
    color: #374151;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.reformix-msg-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    padding: 0 8px;
}

.reformix-msg.reformix-user .reformix-msg-time {
    text-align: right;
}

.reformix-msg.reformix-admin .reformix-msg-time {
    text-align: left;
}

.reformix-welcome-msg {
    text-align: center;
    color: #94a3b8;
    font-style: italic;
    padding: 60px 20px;
    font-size: 15px;
}

/* Message States */
.reformix-msg.reformix-sending .reformix-msg-content {
    opacity: 0.7;
    position: relative;
}

.reformix-msg.reformix-sending .reformix-msg-content::after {
    content: '';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: reformixSpin 1s linear infinite;
}

@keyframes reformixSpin {
    to { transform: translateY(-50%) rotate(360deg); }
}

.reformix-msg.reformix-error .reformix-msg-content {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.reformix-msg.reformix-error .reformix-msg-content::before {
    content: '⚠️ ';
    margin-right: 4px;
}

/* Reformix Chat Toggle System */
.reformix-chat-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--reformix-primary-color, #667eea) 0%, var(--reformix-primary-dark, #5a67d8) 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 24px;
    border: 4px solid white;
}

.reformix-chat-toggle:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.6);
}

.reformix-chat-toggle:active {
    transform: scale(0.95);
}

.reformix-unread-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    border: 3px solid white;
    animation: reformixBounce 2s infinite;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

@keyframes reformixBounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0) scale(1); }
    40% { transform: translateY(-8px) scale(1.1); }
    60% { transform: translateY(-4px) scale(1.05); }
}

.reformix-chat-popup {
    position: fixed;
    bottom: 120px;
    right: 30px;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: 24px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.15);
    z-index: 999;
    overflow: hidden;
    display: none;
    animation: reformixSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #e2e8f0;
}

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

/* Reformix Chat Container Support */
.reformix-chat-container {
    margin-top: 30px;
    border-radius: 20px;
    background: white;
    box-shadow: 0 15px 50px rgba(0,0,0,0.1);
    overflow: hidden;
    border: 1px solid #e2e8f0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.reformix-chat-header {
    background: linear-gradient(135deg, var(--reformix-primary-color, #667eea) 0%, var(--reformix-primary-dark, #5a67d8) 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
}

.reformix-chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="white" opacity="0.1"/><circle cx="75" cy="75" r="1" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    opacity: 0.3;
}

.reformix-chat-info {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
}

.reformix-chat-close {
    position: relative;
    z-index: 1;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reformix-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.reformix-chat-messages {
    height: 450px;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
    -webkit-overflow-scrolling: touch;
}

.reformix-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.reformix-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.reformix-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 3px;
}

.reformix-chat-input {
    padding: 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.reformix-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    border-radius: 25px;
    padding: 8px;
    transition: all 0.2s;
}

.reformix-chat-file-input {
    display: none;
}

.reformix-attach-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: #64748b;
}

.reformix-attach-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
    transform: scale(1.05);
}

#reformix-chat-message {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 16px;
    font-size: 14px;
    resize: none;
    outline: none;
    min-height: 20px;
    max-height: 100px;
    font-family: inherit;
}

#reformix-chat-message::placeholder {
    color: #94a3b8;
}

.reformix-send-btn {
    background: linear-gradient(135deg, var(--reformix-primary-color, #667eea) 0%, var(--reformix-primary-dark, #5a67d8) 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.reformix-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.reformix-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.reformix-file-preview {
    display: none;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    animation: reformixSlideDown 0.3s ease-out;
}

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

.reformix-remove-file-btn {
    float: right;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.reformix-remove-file-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* Enhanced Responsive Design */
@media (max-width: 768px) {
    .reformix-chat-popup {
        width: calc(100vw - 40px);
        height: calc(100vh - 140px);
        bottom: 120px;
        right: 20px;
        left: 20px;
        border-radius: 20px;
    }
    
    .reformix-chat-toggle {
        width: 60px;
        height: 60px;
        bottom: 20px;
        right: 20px;
        font-size: 20px;
    }
    
    .reformix-chat-messages {
        height: calc(100vh - 300px);
        padding: 16px;
    }
    
    .reformix-msg-content {
        max-width: 85%;
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .reformix-input-row {
        padding: 6px;
    }
    
    .reformix-attach-btn,
    .reformix-send-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }
    
    #reformix-chat-message {
        padding: 10px 14px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .reformix-chat-popup {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 10px;
        left: 10px;
        border-radius: 16px;
    }
    
    .reformix-chat-toggle {
        width: 56px;
        height: 56px;
        bottom: 15px;
        right: 15px;
        font-size: 18px;
    }
    
    .reformix-chat-header {
        padding: 16px 20px;
    }
    
    .reformix-chat-messages {
        height: calc(100vh - 280px);
        padding: 12px;
    }
    
    .reformix-msg-content {
        max-width: 90%;
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .reformix-chat-input {
        padding: 16px;
    }
    
    .reformix-input-row {
        padding: 4px;
    }
    
    .reformix-attach-btn,
    .reformix-send-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
    }
    
    #reformix-chat-message {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* Enhanced Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .reformix-chat-popup,
    .reformix-chat-container {
        background: #1e293b;
        border-color: #334155;
    }
    
    .reformix-chat-messages {
        background: #0f172a;
    }
    
    .reformix-msg.reformix-admin .reformix-msg-content {
        background: #334155;
        color: #e2e8f0;
        border-color: #475569;
    }
    
    .reformix-input-row {
        background: #334155;
    }
    
    .reformix-input-row:focus-within {
        background: #475569;
    }
    
    #reformix-chat-message {
        color: #e2e8f0;
    }
    
    #reformix-chat-message::placeholder {
        color: #94a3b8;
    }
    
    .reformix-attach-btn {
        background: #475569;
        border-color: #64748b;
        color: #e2e8f0;
    }
    
    .reformix-attach-btn:hover {
        background: #64748b;
    }
    
    .reformix-welcome-msg {
        color: #94a3b8;
    }
    
    .reformix-msg-time {
        color: #64748b;
    }
}

/* Touch-friendly improvements */
@media (max-width: 768px) {
    .reformix-attach-btn, 
    .reformix-send-btn {
        min-height: 44px !important;
        min-width: 44px !important;
        touch-action: manipulation !important;
    }
    
    .reformix-chat-toggle {
        min-height: 60px !important;
        min-width: 60px !important;
        touch-action: manipulation !important;
    }
    
    .reformix-remove-file-btn {
        min-height: 32px !important;
        min-width: 32px !important;
        touch-action: manipulation !important;
    }
}

/* Ensure proper scrolling on mobile */
@media (max-width: 768px) {
    .reformix-chat-messages {
        -webkit-overflow-scrolling: touch !important;
        overflow-y: auto !important;
    }
    
    .reformix-chat-popup {
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
    }
}