@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* dParranda Global Chatbot - Premium Styles */

/* CSS Reset & Variables */
:root {
    /* Brand Colors - Modern Deep Red */
    --dum-primary: #dc2626;
    /* Red-600 */
    --dum-primary-dark: #b91c1c;
    /* Red-700 */
    --dum-primary-soft: rgba(220, 38, 38, 0.1);

    /* Neutral Colors */
    --dum-dark: #0f172a;
    /* Slate-900 */
    --dum-dark-soft: #1e293b;
    /* Slate-800 */
    --dum-gray: #475569;
    /* Slate-600 */
    --dum-light: #f8fafc;
    /* Slate-50 */
    --dum-white: #ffffff;

    /* UI Helper Colors */
    --dum-border: rgba(226, 232, 240, 0.8);
    --dum-border-hover: rgba(203, 213, 225, 0.8);

    /* Effects */
    --dum-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --dum-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --dum-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --dum-shadow-premium: 0 0 0 1px rgba(0, 0, 0, 0.03), 0 2px 8px rgba(0, 0, 0, 0.08), 0 12px 32px rgba(0, 0, 0, 0.12);

    --dum-glass-bg: rgba(255, 255, 255, 0.85);
    --dum-glass-border: rgba(255, 255, 255, 0.5);
    --dum-blur: blur(12px);

    --dum-transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    /* Smooth elastic feel */
}

/* Base Container & Reset */
#dum-global-chatbot-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    pointer-events: none;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

#dum-global-chatbot-container * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

#dum-global-chatbot-container>* {
    pointer-events: auto;
}

/* =========================================
   Floating Search Bar (The "Core" Widget)
   ========================================= */
#dum-global-search-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);

    /* Dynamic Width */
    width: 280px;
    /* Small Initial State */
    max-width: 90vw;
    height: 56px;

    /* Glassmorphism Style */
    background: var(--dum-glass-bg);
    backdrop-filter: var(--dum-blur);
    -webkit-backdrop-filter: var(--dum-blur);
    border: 1px solid var(--dum-white);

    border-radius: 9999px;
    box-shadow: var(--dum-shadow-premium);

    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;

    transition: var(--dum-transition);
    overflow: hidden;
}

/* Expanded State (On Focus or Active) */
#dum-global-search-bar.expanded,
#dum-global-search-bar:focus-within {
    width: 600px;
    /* "The size of now" */
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 255, 255, 0.8);
}

/* Toggle/Logo Button */
#dum-global-chat-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--dum-primary) 0%, var(--dum-primary-dark) 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--dum-transition);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

#dum-global-chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(220, 38, 38, 0.35);
}

#dum-global-chat-toggle:active {
    transform: scale(0.95);
}

/* Search Input */
#dum-global-quick-input {
    flex: 1;
    height: 100%;
    border: none;
    background: transparent;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    color: #0f172a !important;
    /* Force dark text */
    outline: none;
    min-width: 0;
    /* Important for flex shrinking */
    transition: opacity 0.2s;
}

#dum-global-quick-input::placeholder {
    color: #64748b !important;
    /* Force dark gray placeholder */
    font-weight: 400;
    opacity: 1;
    /* Optional: Hide long placeholder on small screen/collapsed if needed */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Action Buttons (Voice & Send) */
#dum-global-voice-btn,
#dum-global-quick-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--dum-transition);
}

/* Voice Button */
#dum-global-voice-btn {
    background: var(--dum-dark);
    color: white;
}

#dum-global-voice-btn:hover {
    background: var(--dum-primary);
    color: white;
    border-color: var(--dum-primary);
}

#dum-global-voice-btn.listening {
    background: var(--dum-primary-soft);
    color: var(--dum-primary);
    animation: pulse-ring 2s infinite;
}

/* Send Button */
#dum-global-quick-send {
    background: transparent;
    color: var(--dum-primary);
    opacity: 0;
    /* Hidden by default in collapsed state */
    width: 0;
    /* Collapsed width */
    margin: 0;
    pointer-events: none;
}

/* Show Send button only when expanded */
#dum-global-search-bar.expanded #dum-global-quick-send,
#dum-global-search-bar:focus-within #dum-global-quick-send {
    opacity: 1;
    width: 40px;
    margin-left: 4px;
    pointer-events: auto;
    background: var(--dum-dark);
    color: white;
    border: 1px solid var(--dum-dark);
}

#dum-global-quick-send:hover {
    background: var(--dum-primary);
    color: white;
    transform: scale(1.05);
}

/* =========================================
   Chat Window (Glass Panel)
   ========================================= */
#dum-global-chat-window {
    position: fixed;
    bottom: 90px;
    /* Above the bar */
    left: 50%;
    transform: translateX(-50%) scale(0.95);

    width: 550px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(85vh - 100px);

    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);

    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

    display: flex;
    flex-direction: column;
    overflow: hidden;

    transition: var(--dum-transition);
    opacity: 0;
    visibility: hidden;
    transform-origin: bottom center;
}

/* Visible State */
#dum-global-chat-window.dum-chat-visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
    bottom: 100px;
    /* Slight float up */
}

/* Header */
.dum-chat-header {
    background: white;
    border-bottom: 1px solid var(--dum-border);
    padding: 16px 20px !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Optional gradient header or clean white */
}

.dum-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dum-chat-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--dum-primary) 0%, var(--dum-primary-dark) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    box-shadow: 0 4px 6px rgba(220, 38, 38, 0.2);
}

.dum-chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--dum-dark);
}

.dum-chat-header p {
    margin: 2px 0 0 0;
    font-size: 12px;
    color: var(--dum-gray);
}

.dum-chat-header-actions {
    display: flex;
    gap: 8px;
}

.dum-chat-header-actions button {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--dum-gray);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.dum-chat-header-actions button:hover {
    background: var(--dum-light);
    color: var(--dum-dark);
}

#dum-chat-close,
#dum-chat-clear {
    background: var(--dum-dark);
    color: white;
    border: 1px solid var(--dum-dark);
}

#dum-chat-close:hover,
#dum-chat-clear:hover {
    background: var(--dum-primary);
    color: white;
    border-color: var(--dum-primary);
}

/* Messages Area */
#dum-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
    /* Very subtle grey/white pattern if needed */
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Scrollbar Styling */
#dum-chat-messages::-webkit-scrollbar {
    width: 5px;
}

#dum-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* Message Bubbles */
.dum-chat-message {
    display: flex;
    gap: 12px;
    animation: messagePop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes messagePop {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.dum-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.dum-bot-message .dum-message-avatar {
    background: white;
    border: 1px solid var(--dum-border);
    color: var(--dum-primary);
}

.dum-user-message {
    flex-direction: row-reverse;
}

.dum-user-message .dum-message-avatar {
    background: var(--dum-dark);
    color: white;
}

.dum-message-content {
    max-width: 85%;
    padding: 6px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    box-shadow: var(--dum-shadow-sm);
}

.dum-bot-message .dum-message-content {
    background: white;
    border-radius: 4px 16px 16px 16px;
    color: #0f172a !important;
    /* Force dark text */
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.dum-bot-message .dum-message-content p,
.dum-bot-message .dum-message-content strong,
.dum-bot-message .dum-message-content span {
    color: #0f172a !important;
}

.dum-user-message .dum-message-content {
    background: linear-gradient(135deg, var(--dum-dark) 0%, #2d3748 100%);
    color: white !important;
    border-radius: 16px 4px 16px 16px;
}

.dum-user-message .dum-message-content * {
    color: white !important;
}

/* Typography in Messages */
.dum-message-content p {
    margin: 0;
    padding: 10px !important;
}

.dum-message-content p:last-child {
    margin-bottom: 0;
}

.dum-message-content strong {
    font-weight: 600;
}

/* News Cards in Chat */
.dum-news-title {
    background: white;
    border: 1px solid var(--dum-border);
    border-radius: 12px;
    padding: 12px !important;
    margin-top: 4px !important;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--dum-shadow-sm);
}

.dum-news-title:hover {
    border-color: var(--dum-primary);
    transform: translateY(-2px);
    box-shadow: var(--dum-shadow);
}

.dum-news-title-text strong {
    color: var(--dum-primary);
    font-size: 15px;
    display: block;
    margin-bottom: 4px;
}

.dum-news-subtitle {
    color: var(--dum-gray);
    font-size: 13px;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Chat Input Footer */
.dum-chat-input-container {
    background: white;
    padding: 16px;
    border-top: 1px solid var(--dum-border);
}

.dum-chat-input-wrapper {
    display: flex;
    gap: 8px;
    background: var(--dum-light);
    border-radius: 14px;
    padding: 6px !important;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.dum-chat-input-wrapper:focus-within {
    background: white;
    box-shadow: none;
    border-color: transparent;
}

#dum-chat-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 12px;
    font-size: 14px;
    resize: none;
    outline: none;
    max-height: 100px;
    font-family: inherit;
    color: #0f172a !important;
    /* Force dark text */
}

#dum-chat-input::placeholder {
    color: #64748b !important;
    opacity: 1;
}

.dum-chat-voice-btn,
#dum-chat-send {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.dum-chat-voice-btn {
    background: transparent;
    color: var(--dum-gray);
}

.dum-chat-voice-btn:hover {
    color: var(--dum-primary);
    background: rgba(0, 0, 0, 0.05);
}

#dum-chat-send {
    background: var(--dum-primary);
    color: white;
}

#dum-chat-send:hover {
    background: var(--dum-primary-dark);
    transform: scale(1.05);
}

/* =========================================
   Full Screen Modal (News Reader)
   ========================================= */
#dum-news-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: var(--dum-transition);
}

#dum-news-modal.dum-modal-visible {
    visibility: visible;
    opacity: 1;
}

.dum-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    /* Slate-900 60% */
    backdrop-filter: blur(8px);
}

.dum-modal-content {
    position: relative;
    width: 90%;
    max-width: 900px;
    height: 85vh;
    background: white;
    border-radius: 24px;
    box-shadow: 0 50px 100px -20px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95);
    transition: var(--dum-transition);
}

#dum-news-modal.dum-modal-visible .dum-modal-content {
    transform: scale(1);
}

/* Modal Header */
.dum-modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--dum-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.dum-modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--dum-dark);
    margin: 0;
}

#dum-modal-close {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 50% !important;
    border: 1px solid var(--dum-dark);
    background: var(--dum-dark);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
    box-shadow: none !important;
    box-sizing: border-box !important;
}

#dum-modal-close svg {
    display: none !important;
}

#dum-modal-close::before {
    content: "\00d7";
    font-size: 24px;
    line-height: 1;
    font-weight: 400;
    display: block;
    margin-top: -2px;
}

#dum-modal-close:hover {
    background: var(--dum-primary);
    color: white;
    transform: rotate(90deg);
    border-color: var(--dum-primary);
}

/* Modal Body */
.dum-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    font-size: 16px;
    line-height: 1.8;
    color: #334155;
    /* Slate-700 */
}

/* News Content Formatting */
#dum-news-content h1 {
    font-size: 36px;
    font-weight: 800;
    line-height: 1.2;
    color: var(--dum-dark);
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

#dum-news-content h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--dum-gray);
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--dum-border);
}

#dum-news-content h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--dum-primary);
    margin: 40px 0 16px 0;
}

.dum-modal-date {
    display: inline-block;
    padding: 6px 12px;
    background: var(--dum-light);
    border-radius: 6px;
    font-size: 13px;
    color: var(--dum-gray);
    margin-bottom: 24px !important;
    font-weight: 500;
}

@keyframes pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(220, 38, 38, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
    }
}

@media (max-width: 640px) {
    #dum-global-search-bar {
        width: 270px;
        /* Just the button initially on mobile */
        padding: 0;
        justify-content: center;
    }

    #dum-global-search-bar.expanded,
    #dum-global-search-bar:focus-within {
        width: 90%;
    }

    #dum-global-chat-window {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        bottom: 0;
        border-radius: 0;
    }

    #dum-global-chat-window.dum-chat-visible {
        bottom: 0;
        transform: translateX(0);
        left: 0;
    }
}

p.dum-news-subtitle {
    padding: 0px !important;
}

p.dum-news-date {
    padding: 0px !important;
    padding-top: 5px !important;
    padding-bottom: 5px !important;
}

/* Typing Indicator Animation */
.dum-typing-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 12px 18px;
    min-width: 60px;
    min-height: 24px;
}

.dum-typing-indicator span {
    display: block;
    width: 8px;
    height: 8px;
    background-color: var(--dum-gray);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
    opacity: 0.7;
}

.dum-typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.dum-typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}