/* ADIB Assistant - Premium Glassmorphism UI */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --chat-accent: #6366F1;
    --chat-accent-glow: rgba(99, 102, 241, 0.4);
    --chat-gradient: linear-gradient(135deg, #6366F1 0%, #818CF8 100%);
    --chat-dark: #0F172A;
    --chat-glass-bg: rgba(255, 255, 255, 0.45);
    --chat-glass-border: rgba(255, 255, 255, 0.5);
    --chat-dark-glass: rgba(15, 23, 42, 0.75);
    --chat-text: #0F172A;
    --chat-muted: #475569;
    --chat-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.3);
    
    --chat-font-main: 'Outfit', sans-serif;
    --chat-font-heading: 'Playfair Display', serif;
}

#chatbot-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 10000;
    font-family: var(--chat-font-main);
    -webkit-font-smoothing: antialiased;
}

/* Trigger Button (Ultra-Premium) */
.chat-trigger {
    width: 68px;
    height: 68px;
    background: var(--chat-gradient);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 
        0 15px 35px var(--chat-accent-glow),
        inset 0 -4px 8px rgba(0,0,0,0.1),
        inset 0 4px 8px rgba(255,255,255,0.3);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    z-index: 2;
}

.chat-trigger:hover {
    transform: scale(1.15) translateY(-5px);
    box-shadow: 0 20px 45px var(--chat-accent-glow);
}

.chat-trigger i {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
    transition: transform 0.4s ease;
}

.chat-trigger:hover i {
    transform: scale(1.1) rotate(10deg);
}

/* Glass Ring around trigger */
.chat-trigger::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: -1;
    transition: all 0.4s ease;
}

.chat-trigger:hover::before {
    inset: -12px;
    background: rgba(255, 255, 255, 0.15);
}

.chat-trigger::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--chat-accent);
    opacity: 0.4;
    z-index: -2;
    animation: premium-pulse 2.5s infinite;
}

@keyframes premium-pulse {
    0% { transform: scale(1); opacity: 0.4; }
    50% { opacity: 0.2; }
    100% { transform: scale(2.2); opacity: 0; }
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 420px;
    height: 620px;
    max-height: calc(100vh - 160px); /* Increased safety margin at top */
    max-width: calc(100vw - 40px);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.3));
    backdrop-filter: blur(30px) saturate(200%);
    -webkit-backdrop-filter: blur(30px) saturate(200%);
    border-radius: 32px;
    box-shadow: 
        var(--chat-shadow), 
        inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(15, 23, 42, 0.1);
    display: flex;
    flex-direction: column;
    transform-origin: bottom right;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8) translateY(30px);
    overflow: hidden;
}

.chat-window.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

/* Premium Header */
.chat-header {
    background: linear-gradient(to bottom, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.7));
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    color: white;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.3), transparent);
}

.chat-avatar {
    width: 44px;
    height: 44px;
    background: var(--chat-gradient);
    border-radius: 14px; /* Squircle style */
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.chat-header-info {
    flex: 1;
}

.chat-header-name {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.chat-header-status {
    font-family: var(--chat-font-main);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-weight: 400;
}

.chat-header-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #10B981;
    border-radius: 50%;
    box-shadow: 0 0 8px #10B981;
}

.chat-close {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 8px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chat-close:hover {
    background: #EF4444;
    border-color: #EF4444;
    transform: scale(1.1);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.08), transparent 70%);
}

.chat-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.1);
    border-radius: 10px;
}

/* Animation for messages */
@keyframes msgAppear {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.msg {
    max-width: 85%;
    padding: 0.9rem 1.25rem;
    font-size: 1rem;
    line-height: 1.6;
    animation: msgAppear 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    letter-spacing: -0.01em;
}

.msg-user {
    align-self: flex-end;
    background: var(--chat-gradient);
    color: white;
    border-radius: 24px 24px 4px 24px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
    font-weight: 500;
}

.msg-bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--chat-text);
    border-radius: 24px 24px 24px 8px;
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.04), inset 0 0 0 1px rgba(255, 255, 255, 0.6);
    border: none;
    font-weight: 400;
}

.msg-time {
    font-size: 0.7rem;
    color: var(--chat-muted);
    margin-top: 4px;
    opacity: 0.8;
}

.msg-user + .msg-time { align-self: flex-end; }

/* Typing Indicator (Human-like) */
.typing {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    background: white;
    border-radius: 20px 20px 20px 4px;
    width: fit-content;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #CBD5E1;
    border-radius: 50%;
    animation: typing-wave 1.2s infinite ease-in-out;
}

@keyframes typing-wave {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); background: var(--chat-accent); }
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* Floating Chips */
.chat-chips {
    display: flex;
    gap: 0.6rem;
    padding: 0 1.5rem 1rem;
    overflow-x: auto;
}

.chat-chips::-webkit-scrollbar { display: none; }

.chip {
    background: white;
    border: 1px solid rgba(99, 102, 241, 0.15);
    color: var(--chat-text);
    border-radius: 14px;
    padding: 0.6rem 1.1rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.chip:hover {
    background: var(--chat-accent);
    color: white;
    border-color: var(--chat-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--chat-accent-glow);
}

/* Rich Media Cards */
.rich-card {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    overflow: hidden;
    margin: 8px 0;
    width: 100%;
    max-width: 320px;
    align-self: flex-start;
    animation: msgAppear 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.card-img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.card-content {
    padding: 1rem;
}

.card-content h3 {
    font-family: var(--chat-font-heading);
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: var(--chat-text);
}

.card-content p {
    font-size: 0.85rem;
    color: var(--chat-muted);
    margin-bottom: 0.75rem;
}

.card-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--chat-accent);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}

.timeline-card .card-content {
    background: rgba(255, 255, 255, 0.3);
}

.timeline-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.timeline-item:last-child { border: none; }

.timeline-item span {
    font-weight: 700;
    color: var(--chat-accent);
}

/* Premium Input Area */
.chat-input-row {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-top: 1px solid rgba(15, 23, 42, 0.05);
    display: flex;
    gap: 1rem;
    align-items: center;
}

#chat-input {
    flex: 1;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    font-family: var(--chat-font-main);
    resize: none;
    outline: none;
    transition: all 0.3s ease;
    max-height: 120px;
    line-height: 1.5;
    font-weight: 400;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

#chat-input:focus {
    border-color: var(--chat-accent);
    box-shadow: 0 0 0 3px var(--chat-accent-glow);
}

.chat-send {
    width: 48px;
    height: 48px;
    background: var(--chat-gradient);
    color: white;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px var(--chat-accent-glow);
}

.chat-send:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 18px var(--chat-accent-glow);
}

.chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
}

/* Tooltip */
.chat-tooltip {
    position: absolute;
    right: 80px;
    background: var(--chat-dark);
    color: white;
    padding: 0.6rem 1rem;
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(10px);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.chat-trigger:hover .chat-tooltip {
    opacity: 1;
    transform: translateX(0);
}

/* Mobile Overrides */
@media (max-width: 580px) {
    #chatbot-container {
        bottom: 1rem;
        right: 1rem;
    }
    .chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 120px);
        bottom: 85px;
        right: -10px; /* Slight offset for mobile trigger alignment */
        border-radius: 28px;
    }
    .chat-header {
        padding: 1rem;
    }
    .chat-messages {
        padding: 1rem;
    }
    .chat-input-row {
        padding: 1rem;
    }
}
