/* DTIO Chat Widget Styles */
#dtio-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1040;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    width: 350px;
    max-width: calc(100vw - 40px);
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Widget Toggle Button */
.dtio-chat-toggle {
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: visible;
    position: relative;
}

/* Hide toggle when chat is open */
.dtio-chat-widget-open .dtio-chat-toggle {
    display: none;
}

.dtio-chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4);
}

.dtio-chat-toggle-content {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: white;
    position: relative;
}

.dtio-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
    margin-right: 10px;
    flex-shrink: 0;
}

.dtio-chat-toggle-text {
    flex: 1;
    min-width: 0;
}

.dtio-chat-agent-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dtio-chat-status {
    font-size: 12px;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dtio-chat-toggle-icon {
    margin-left: 10px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

/* Notification Badge */
.dtio-chat-notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.dtio-chat-widget-open .dtio-chat-toggle-icon {
    transform: rotate(180deg);
}

/* Chat Container */
.dtio-chat-container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    margin-top: 15px;
    overflow: hidden;
    position: relative;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    height: 0;
}

.dtio-chat-widget-open .dtio-chat-container {
    opacity: 1;
    transform: translateY(0) scale(1);
    height: 480px;
}

/* Chat Header */
.dtio-chat-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
}

.dtio-chat-header-info {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.dtio-chat-header-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
    margin-right: 8px;
    flex-shrink: 0;
}

.dtio-chat-header-text {
    flex: 1;
    min-width: 0;
}

.dtio-chat-header-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dtio-chat-header-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
}

.dtio-chat-header-status:before {
    content: '';
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    margin-right: 6px;
}

.dtio-chat-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dtio-chat-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Messages Wrapper */
.dtio-chat-messages-wrapper {
    height: 340px;
    background: var(--bs-primary, #007bff);
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Messages Container */
.dtio-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dtio-chat-messages::-webkit-scrollbar {
    width: 4px;
}

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

.dtio-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

.dtio-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Individual Messages */
.dtio-chat-message {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: dtio-chat-fadeIn 0.3s ease;
}

.dtio-chat-message-agent {
    flex-direction: row;
}

.dtio-chat-message-user {
    flex-direction: row-reverse;
    margin-left: 50px;
}

.dtio-chat-message-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.dtio-chat-message-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dtio-chat-message-user .dtio-chat-message-content {
    align-items: flex-end;
}

.dtio-chat-message-text {
    background: white;
    padding: 10px 14px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 13px;
}

.dtio-chat-message-user .dtio-chat-message-text {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.dtio-chat-message-time {
    font-size: 11px;
    color: #64748b;
    padding: 0 8px;
}

/* Typing Indicator */
.dtio-chat-typing {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 16px 16px 16px;
    background: linear-gradient(transparent 0%, var(--bs-primary, #007bff) 20%);
    animation: dtio-chat-fadeIn 0.3s ease;
    z-index: 10;
}

.dtio-chat-typing-content {
    background: white;
    padding: 10px 14px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 75%;
}

.dtio-chat-typing-dots {
    display: flex;
    gap: 3px;
}

.dtio-chat-typing-dots span {
    width: 6px;
    height: 6px;
    background: #cbd5e0;
    border-radius: 50%;
    animation: dtio-chat-typing 1.4s infinite ease-in-out both;
}

.dtio-chat-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.dtio-chat-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

/* Input Container */
.dtio-chat-input-container {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.dtio-chat-form {
    margin: 0;
}

.dtio-chat-input {
    border: 1px solid #e2e8f0;
    padding: 10px 16px;
    font-size: 16px;
    transition: all 0.2s ease;
    background: #f8fafc;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

@media (max-width: 480px) {
    .dtio-chat-input {
        font-size: 16px !important;
        transform: translateZ(0);
    }
}

.dtio-chat-input:focus {
    border-color: var(--bs-primary, #007bff);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    background: white;
    outline: none;
}

.dtio-chat-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

.dtio-chat-send-btn:hover {
    transform: scale(1.05);
}

.dtio-chat-send-btn:active {
    transform: scale(0.95);
}

/* Notification */
.dtio-chat-notification {
    position: absolute;
    bottom: 100px;
    right: 0;
    background: white;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    padding: 15px 20px;
    cursor: pointer;
    max-width: 280px;
    animation: dtio-chat-slideIn 0.5s ease;
    border-left: 4px solid #667eea;
}

.dtio-chat-notification:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.dtio-chat-notification-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dtio-chat-notification-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.dtio-chat-notification-text {
    font-size: 14px;
    color: #374151;
    line-height: 1.4;
    flex: 1;
}

.dtio-chat-notification-bounce {
    animation: dtio-chat-bounce 0.6s ease;
}

/* Animations */
@keyframes dtio-chat-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes dtio-chat-slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes dtio-chat-bounce {
    0%, 20%, 53%, 80%, 100% {
        animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
        transform: translate3d(0, -10px, 0);
    }
    70% {
        animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
        transform: translate3d(0, -5px, 0);
    }
    90% {
        transform: translate3d(0, -2px, 0);
    }
}

@keyframes dtio-chat-typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.6;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 480px) {
    #dtio-chat-widget {
        width: calc(100vw - 20px);
        right: 10px;
        left: 10px;
        bottom: 10px;
    }
    
    .dtio-chat-widget-open .dtio-chat-container {
        height: calc(100vh - 140px);
        max-height: 560px;
    }
    
    .dtio-chat-messages-wrapper {
        height: calc(100vh - 280px);
        max-height: 400px;
    }
    
    .dtio-chat-messages {
        height: auto;
    }
    
    .dtio-chat-message-user {
        margin-left: 30px;
    }
    
    /* Hide notification popup on mobile, show badge instead */
    .dtio-chat-notification {
        display: none !important;
    }
    
    .dtio-chat-notification-badge {
        display: flex !important;
    }
}

/* Bootstrap 4.5.3 Compatibility - Remove conflicting styles */
.dtio-chat-input-container .input-group {
    border-radius: 0.375rem;
}

.dtio-chat-input-container .input-group .form-control {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
    margin-bottom: 0;
}

.dtio-chat-input-container .input-group-append {
    margin-left: -1px;
    display: flex;
}

.dtio-chat-input-container .input-group-append .btn {
    position: relative;
    z-index: 2;
    height: auto;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .dtio-chat-container {
        background: #1f2937;
        color: #f3f4f6;
    }
    
    .dtio-chat-messages-wrapper {
        background: #111827;
    }
    
    .dtio-chat-messages {
        background: transparent;
    }
    
    .dtio-chat-typing {
        background: linear-gradient(transparent 0%, #111827 20%);
    }
    
    .dtio-chat-message-text {
        background: #374151;
        color: #f3f4f6;
    }
    
    .dtio-chat-message-user .dtio-chat-message-text {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
    }
    
    .dtio-chat-input {
        background: #374151;
        border-color: #4b5563;
        color: #f3f4f6;
    }
    
    .dtio-chat-input:focus {
        background: #4b5563;
    }
    
    .dtio-chat-input-container {
        background: #1f2937;
        border-color: #4b5563;
    }
    
    .dtio-chat-typing-content {
        background: #374151;
    }
    
    .dtio-chat-notification {
        background: #1f2937;
        color: #f3f4f6;
    }
    
    .dtio-chat-notification-text {
        color: #f3f4f6;
    }

    .dtio-chat-limit-overlay {
        background: rgba(31, 41, 55, 0.95);
    }

    .dtio-chat-limit-overlay-content {
        background: #1f2937;
        border-color: #4b5563;
    }

    .dtio-chat-limit-overlay-title {
        color: #f3f4f6;
    }

    .dtio-chat-overlay-btn {
        background: var(--bs-primary, #007bff);
        color: white;
    }

    .dtio-chat-overlay-btn:hover {
        background: var(--bs-primary-dark, #0056b3);
    }
}

/* Chat Limit Overlay */
.dtio-chat-limit-overlay {
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
}

.dtio-chat-limit-overlay-content {
    background: white;
    padding: 30px 25px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    text-align: center;
    max-width: 280px;
    border: 1px solid #e2e8f0;
}

.dtio-chat-limit-overlay-title {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a202c;
    line-height: 1.4;
}

.dtio-chat-overlay-btn {
    background: var(--bs-primary, #007bff);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.dtio-chat-overlay-btn:hover {
    background: var(--bs-primary-dark, #0056b3);
    transform: translateY(-1px);
}

.dtio-chat-overlay-btn:active {
    transform: translateY(0);
}