/* Newdoor Chat - Frontend Styles */

/* Chat Widget Button */
.newdoor-chat-trigger {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    background: #0073aa;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

.newdoor-chat-trigger:hover {
    transform: scale(1.1);
    background: #005a87;
    box-shadow: 0 6px 25px rgba(0,0,0,0.3);
}

.newdoor-chat-trigger.active {
    border-radius: 12px;
    background: #dc3545;
}

.chat-trigger-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5em;
    transition: all 0.3s ease;
}

.chat-trigger-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

/* Notification Badge */
.chat-notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    font-weight: 600;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Chat Modal */
.newdoor-chat-modal {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    z-index: 999998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.newdoor-chat-modal.show {
    display: flex;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
    color: white;
    padding: 20px;
    text-align: center;
    position: relative;
}

.chat-header h3 {
    margin: 0 0 5px 0;
    font-size: 1.2em;
    font-weight: 600;
}

.chat-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.9em;
}

.chat-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.chat-close:hover {
    background: rgba(255,255,255,0.3);
}

/* Initial Form */
.chat-initial-form {
    padding: 25px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #333;
    font-size: 0.9em;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0,115,170,0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.chat-start-btn {
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-top: auto;
}

.chat-start-btn:hover {
    background: #005a87;
}

/* Chat Interface */
.chat-interface {
    display: none;
    flex-direction: column;
    height: 100%;
}

.chat-interface.active {
    display: flex;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

.chat-message {
    margin-bottom: 15px;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    position: relative;
}

.message-user .message-bubble {
    background: #0073aa;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.message-admin .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e9ecef;
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.7em;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.message-user .message-time {
    color: rgba(255,255,255,0.8);
}

.message-admin .message-time {
    color: #666;
    text-align: left;
}

/* Read Receipts */
.message-status {
    font-size: 0.7em;
    opacity: 0.7;
    margin-top: 2px;
    text-align: right;
}

.status-sent::after {
    content: '✓';
}

.status-delivered::after {
    content: '✓✓';
}

.status-read::after {
    content: '✓✓';
    color: #0073aa;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    padding: 10px 20px;
    color: #666;
    font-size: 0.9em;
    font-style: italic;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.typing-indicator.show {
    display: block;
}

.typing-animation {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-right: 8px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #999;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Message Input */
.chat-input-area {
    padding: 15px 20px;
    border-top: 1px solid #e9ecef;
    background: white;
}

.input-group {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    border: 2px solid #e9ecef;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 80px;
    min-height: 40px;
    transition: border-color 0.2s ease;
}

.chat-input:focus {
    outline: none;
    border-color: #0073aa;
}

.send-btn {
    background: #0073aa;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 1.2em;
}

.send-btn:hover {
    background: #005a87;
    transform: scale(1.05);
}

.send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* PM Interface Styles */
.newdoor-pm-container {
    max-width: 900px;
    margin: 20px auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Responsive Design */
@media (max-width: 768px) {
    .newdoor-chat-trigger {
        bottom: 15px;
        right: 15px;
        width: 55px;
        height: 55px;
    }
    
    .newdoor-chat-modal {
        bottom: 85px;
        right: 15px;
        left: 15px;
        width: auto;
        max-height: 70vh;
    }
    
    .chat-initial-form {
        padding: 20px;
    }
    
    .chat-messages {
        padding: 15px;
    }
    
    .chat-input-area {
        padding: 12px 15px;
    }
    
    .newdoor-pm-container {
        margin: 10px;
        border-radius: 8px;
    }
}

@media (max-width: 480px) {
    .newdoor-chat-modal {
        bottom: 80px;
        right: 10px;
        left: 10px;
        height: 400px;
    }
    
    .message-bubble {
        max-width: 90%;
    }
    
    .input-group {
        gap: 8px;
    }
    
    .send-btn {
        width: 36px;
        height: 36px;
        font-size: 1em;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .newdoor-chat-modal {
        background: #2c3e50;
        color: white;
    }
    
    .chat-messages {
        background: #34495e;
    }
    
    .message-admin .message-bubble {
        background: #3a4a5c;
        color: white;
        border-color: #4a5a6c;
    }
    
    .chat-input-area {
        background: #2c3e50;
        border-color: #4a5a6c;
    }
    
    .chat-input {
        background: #3a4a5c;
        color: white;
        border-color: #4a5a6c;
    }
    
    .typing-indicator {
        background: #34495e;
        border-color: #4a5a6c;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .newdoor-chat-trigger {
        border: 2px solid white;
    }
    
    .message-bubble {
        border: 2px solid;
    }
    
    .chat-input {
        border-width: 3px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .newdoor-chat-trigger:hover {
        transform: none;
    }
    
    .send-btn:hover {
        transform: none;
    }
}

/* Print Styles */
@media print {
    .newdoor-chat-trigger,
    .newdoor-chat-modal {
        display: none !important;
    }
}

/* Accessibility Improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus Indicators */
.newdoor-chat-trigger:focus,
.chat-close:focus,
.chat-start-btn:focus,
.send-btn:focus {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
}

/* Loading States */
.chat-loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

.chat-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error States */
.chat-error {
    background: #f8d7da;
    color: #721c24;
    padding: 10px 15px;
    border-radius: 6px;
    margin: 10px 0;
    border: 1px solid #f5c6cb;
}

/* Success States */
.chat-success {
    background: #d4edda;
    color: #155724;
    padding: 10px 15px;
    border-radius: 6px;
    margin: 10px 0;
    border: 1px solid #c3e6cb;
}

/* Smooth Scrolling */
.chat-messages {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
