/**
 * AI Smart Chatbot - Frontend Styles
 * Modern, premium chatbot UI design
 */

/* ========================================
   Variables & Reset
   ======================================== */
:root {
    --dd-primary: #2563eb;
    --dd-secondary: #1e293b;
    --dd-success: #10b981;
    --dd-danger: #ef4444;
    --dd-bg-light: #f8fafc;
    --dd-bg-dark: #1e293b;
    --dd-text-dark: #0f172a;
    --dd-text-light: #64748b;
    --dd-border: #e2e8f0;
    --dd-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    --dd-shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.15);
    --dd-radius: 16px;
    --dd-radius-sm: 12px;
    --dd-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Container & Positioning
   ======================================== */
.dd-chatbot-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.dd-chatbot-container.bottom-right {
    bottom: 24px;
    right: 24px;
}

.dd-chatbot-container.bottom-left {
    bottom: 24px;
    left: 24px;
}

/* ========================================
   Chat Button
   ======================================== */
.dd-chat-button {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--dd-primary);
    border: none;
    cursor: pointer;
    box-shadow: var(--dd-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--dd-transition);
    position: relative;
    overflow: hidden;
}

.dd-chat-button:hover {
    transform: scale(1.1);
    box-shadow: var(--dd-shadow-lg);
}

.dd-chat-button:active {
    transform: scale(0.95);
}

.dd-chat-button svg {
    width: 28px;
    height: 28px;
    color: white;
    transition: var(--dd-transition);
}

.dd-chat-button .dd-close-icon {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg);
}

.dd-chat-button.open .dd-chat-icon {
    opacity: 0;
    transform: rotate(90deg);
}

.dd-chat-button.open .dd-close-icon {
    opacity: 1;
    transform: rotate(0deg);
}

/* Pulse animation */
@keyframes dd-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 var(--dd-primary);
    }

    50% {
        box-shadow: 0 0 0 12px transparent;
    }
}

.dd-chat-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    animation: dd-pulse 2s infinite;
}

/* ========================================
   Chat Window
   ======================================== */
.dd-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: var(--dd-radius);
    box-shadow: var(--dd-shadow-lg);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: var(--dd-transition);
    overflow: hidden;
}

.dd-chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ========================================
   Chat Header
   ======================================== */
.dd-chat-header {
    background: var(--dd-primary);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--dd-radius) var(--dd-radius) 0 0;
}

.dd-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dd-bot-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    backdrop-filter: blur(10px);
}

.dd-bot-avatar img,
.dd-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.dd-chat-icon-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.dd-header-text h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.dd-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dd-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--dd-success);
    border-radius: 50%;
    display: inline-block;
    animation: dd-pulse-status 2s infinite;
}

@keyframes dd-pulse-status {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.dd-minimize-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--dd-transition);
}

.dd-minimize-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.dd-minimize-btn svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* ========================================
   Messages Area
   ======================================== */
.dd-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--dd-bg-light);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

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

.dd-chat-messages::-webkit-scrollbar-thumb {
    background: var(--dd-border);
    border-radius: 3px;
}

.dd-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--dd-secondary);
}

/* ========================================
   Message Bubbles
   ======================================== */
.dd-message {
    display: flex;
    gap: 12px;
    opacity: 0;
    transform: translateY(10px);
    transition: var(--dd-transition);
}

.dd-message.visible {
    opacity: 1;
    transform: translateY(0);
}

.dd-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.dd-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: var(--dd-radius-sm);
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

/* Bot messages */
.dd-message-bot .dd-message-avatar {
    background: var(--dd-primary);
}

.dd-message-bot .dd-message-content {
    background: white;
    color: var(--dd-text-dark);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* User messages */
.dd-message-user {
    flex-direction: row-reverse;
}

.dd-message-user .dd-message-avatar {
    background: var(--dd-secondary);
}

.dd-message-user .dd-message-content {
    background: var(--dd-primary);
    color: white;
    margin-left: auto;
}

/* ========================================
   Typing Indicator
   ======================================== */
.dd-typing-indicator .dd-message-content {
    display: flex;
    gap: 6px;
    padding: 16px;
}

.dd-typing-indicator .dd-message-content span {
    width: 8px;
    height: 8px;
    background: var(--dd-secondary);
    border-radius: 50%;
    animation: dd-typing 1.4s infinite;
}

.dd-typing-indicator .dd-message-content span:nth-child(2) {
    animation-delay: 0.2s;
}

.dd-typing-indicator .dd-message-content span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dd-typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ========================================
   Input Area
   ======================================== */
.dd-chat-input-area {
    background: white;
    border-top: 1px solid var(--dd-border);
    padding: 16px;
}

.dd-input-wrapper {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.dd-chat-input {
    flex: 1;
    border: 2px solid var(--dd-border);
    border-radius: var(--dd-radius-sm);
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: var(--dd-transition);
}

.dd-chat-input:focus {
    border-color: var(--dd-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.dd-send-btn {
    width: 44px;
    height: 44px;
    background: var(--dd-primary);
    border: none;
    border-radius: var(--dd-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--dd-transition);
    flex-shrink: 0;
}

.dd-send-btn:hover {
    filter: brightness(0.9);
    transform: scale(1.05);
}

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

.dd-send-btn svg {
    width: 20px;
    height: 20px;
    color: white;
}

.dd-powered-by {
    text-align: center;
    font-size: 11px;
    color: var(--dd-text-light);
    margin-top: 4px;
}

/* ========================================
   Lead Form
   ======================================== */
.dd-lead-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.dd-form-input {
    border: 2px solid var(--dd-border);
    border-radius: var(--dd-radius-sm);
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: var(--dd-transition);
    width: auto !important;
}

textarea.dd-form-input {
    height: 60px !important;
}

.dd-form-input:focus {
    border-color: var(--dd-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.dd-form-buttons {
    display: flex;
    gap: 8px;
}

.dd-form-skip {
    flex: 1;
    background: var(--dd-bg-light);
    color: var(--dd-text-dark);
    border: 2px solid var(--dd-border);
    border-radius: var(--dd-radius-sm);
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--dd-transition);
}

.dd-form-skip:hover {
    background: var(--dd-border);
    border-color: var(--dd-secondary);
}

.dd-form-skip:active {
    transform: scale(0.98);
}

.dd-form-submit {
    flex: 1;
    background: var(--dd-primary);
    color: white;
    border: none;
    border-radius: var(--dd-radius-sm);
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--dd-transition);
}

.dd-form-submit:hover {
    filter: brightness(0.9);
    transform: translateY(-2px);
    box-shadow: var(--dd-shadow);
}

.dd-form-submit:active {
    transform: translateY(0);
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 480px) {
    .dd-chatbot-container {
        bottom: 0;
        right: 0;
        left: 0;
    }

    .dd-chat-button {
        position: fixed;
        bottom: 16px;
        right: 16px;
    }

    .dd-chat-window {
        width: 100%;
        height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    .dd-chat-window.open {
        transform: translateY(0);
    }

    .dd-chat-header {
        border-radius: 0;
    }
}

/* ========================================
   Human Takeover Contact Buttons
   ======================================== */
.dd-contact-options {
    padding: 12px !important;
    background: transparent !important;
    box-shadow: none !important;
}

.dd-contact-buttons {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 4px;
}

.dd-contact-btn {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--dd-transition);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    text-decoration: none;
    border: none;
}

.dd-contact-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

.dd-contact-btn svg {
    width: 22px;
    height: 22px;
    color: white;
}

/* Tooltip implementation */
.dd-contact-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    background: var(--dd-secondary);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: var(--dd-transition);
    z-index: 100;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.dd-contact-btn[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Specific button styles */
.dd-phone-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.dd-messenger-btn {
    background: linear-gradient(135deg, #0084ff 0%, #0066cc 100%);
}

.dd-viber-btn {
    background: linear-gradient(135deg, #7360f2 0%, #5929a1 100%);
}

.dd-resume-btn {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
}

/* ========================================
   Accessibility
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible for keyboard navigation */
.dd-chat-button:focus-visible,
.dd-send-btn:focus-visible,
.dd-minimize-btn:focus-visible {
    outline: 3px solid var(--dd-primary);
    outline-offset: 2px;
}