/* 
🎨 NORMAN AI ASSISTANT - ULTRA MODERN AFS CHATBOX V2.0
Enhanced positioning, responsive design, and beautiful message styling
*/

:root {
    --afs-primary: #007bff;
    --afs-secondary: #0056b3;
    --afs-tertiary: #4dabf7;
    --afs-accent: #74c0fc;
    
    /* Modern Gradients */
    --afs-gradient: linear-gradient(135deg, #007bff 0%, #4dabf7 50%, #0056b3 100%);
    --afs-gradient-reverse: linear-gradient(315deg, #007bff 0%, #4dabf7 50%, #0056b3 100%);
    --afs-gradient-light: linear-gradient(135deg, rgba(0, 123, 255, 0.08) 0%, rgba(77, 171, 247, 0.12) 100%);
    --afs-gradient-glow: linear-gradient(135deg, rgba(0, 123, 255, 0.4) 0%, rgba(77, 171, 247, 0.3) 50%, rgba(0, 86, 179, 0.4) 100%);
    
    /* Glass Effects */
    --glass-bg: rgba(255, 255, 255, 0.12);
    --glass-border: rgba(255, 255, 255, 0.25);
    --glass-shadow: 0 8px 32px rgba(0, 123, 255, 0.3);
    --glass-backdrop: blur(25px);
    
    /* Text Colors */
    --afs-text-light: #ffffff;
    --afs-text-dark: #1a1a1a;
    --afs-text-muted: #6c757d;
    
    /* Enhanced Shadows & Effects */
    --shadow-soft: 0 4px 20px rgba(0, 123, 255, 0.15);
    --shadow-medium: 0 8px 32px rgba(0, 123, 255, 0.25);
    --shadow-strong: 0 16px 48px rgba(0, 123, 255, 0.35);
    --shadow-glow: 0 0 30px rgba(0, 123, 255, 0.4);
    
    /* Animation Variables */
    --bounce-duration: 0.6s;
    --slide-duration: 0.4s;
    --fade-duration: 0.3s;
}

/* 🎯 STATIC CHAT BUBBLE - Right Side Fixed Position */
.norman-chat-bubble {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 68px;
    height: 68px;
    background: var(--afs-gradient);
    border-radius: 50%;
    cursor: pointer;
    z-index: 1000;
    box-shadow: var(--shadow-medium);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid rgba(255, 255, 255, 0.3);
    outline: none;
    overflow: hidden;
    animation: bubbleAttention 4s ease-in-out infinite;
}

@keyframes bubbleAttention {
    0%, 100% {
        transform: scale(1);
        box-shadow: var(--shadow-medium);
    }
    5% {
        transform: scale(1.15);
        box-shadow: 0 0 25px rgba(0, 123, 255, 0.6), var(--shadow-strong);
    }
    10% {
        transform: scale(1);
        box-shadow: var(--shadow-medium);
    }
    15% {
        transform: scale(1.15);
        box-shadow: 0 0 25px rgba(0, 123, 255, 0.6), var(--shadow-strong);
    }
    20%, 100% {
        transform: scale(1);
        box-shadow: var(--shadow-medium);
    }
}

/* Responsive bubble positioning */
@media (max-width: 1200px) {
    .norman-chat-bubble {
        bottom: 25px;
        right: 25px;
    }
}

@media (max-width: 768px) {
    .norman-chat-bubble {
        bottom: 20px;
        right: 20px;
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 480px) {
    .norman-chat-bubble {
        bottom: 20px;
        right: 10px;
        width: 60px;
        height: 60px;
    }
}

/* Removed floating animation for static positioning */

/* Magical Glow Effect */
.norman-chat-bubble::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(
        from 0deg,
        transparent,
        rgba(77, 171, 247, 0.4),
        transparent,
        rgba(0, 123, 255, 0.4),
        transparent
    );
    animation: rotateGlow 4s linear infinite;
    opacity: 0;
    transition: opacity var(--fade-duration) ease;
}

@keyframes rotateGlow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Simple Hover Effects - No Movement */
.norman-chat-bubble:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.norman-chat-bubble:hover::before {
    opacity: 1;
}

.norman-chat-bubble:active {
    transform: scale(0.98);
}

/* Bubble Logo Container */
.bubble-logo-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
}

.afs-logo-bubble {
    width: 35px;
    height: 35px;
    object-fit: contain;
    filter: brightness(0) invert(1) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    transition: all var(--slide-duration) ease;
    z-index: 4;
}

@media (max-width: 768px) {
    .afs-logo-bubble {
        width: 30px;
        height: 30px;
    }
}

@media (max-width: 480px) {
    .afs-logo-bubble {
        width: 28px;
        height: 28px;
    }
}

/* 🌟 STATIC CHAT CONTAINER - Right Aligned */
.norman-chat-container {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 420px;
    height: 580px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: var(--glass-backdrop);
    -webkit-backdrop-filter: var(--glass-backdrop);
    border-radius: 28px;
    box-shadow: var(--shadow-strong);
    z-index: 999;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.norman-chat-container.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* Responsive chat container */
@media (max-width: 1200px) {
    .norman-chat-container {
        right: 25px;
        bottom: 105px;
        width: 400px;
        height: 560px;
    }
}

@media (max-width: 768px) {
    .norman-chat-container {
        right: 20px;
        bottom: 90px;
        width: 360px;
        height: 520px;
        border-radius: 24px;
    }
}

@media (max-width: 480px) {
    .norman-chat-container {
        right: 10px;
        bottom: 85px;
        width: calc(100vw - 20px);
        height: 520px;
        border-radius: 20px;
        max-height: calc(100vh - 120px);
    }
}

/* 🎨 ENHANCED CHAT HEADER */
.norman-chat-header {
    background: var(--afs-gradient);
    padding: 28px 24px;
    color: white;
    display: flex;
    align-items: center;
    gap: 16px;
    border-radius: 28px 28px 0 0;
    position: relative;
    overflow: hidden;
    min-height: 80px;
}

@media (max-width: 768px) {
    .norman-chat-header {
        padding: 24px 20px;
        border-radius: 24px 24px 0 0;
        min-height: 70px;
    }
}

@media (max-width: 480px) {
    .norman-chat-header {
        padding: 20px 16px;
        border-radius: 20px 20px 0 0;
        min-height: 60px;
    }
}

/* Header shimmer effect */
.norman-chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: headerShimmer 3s infinite;
}

@keyframes headerShimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.norman-avatar {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.3);
    animation: avatarPulse 2s ease-in-out infinite;
    transition: all var(--slide-duration) ease;
}

@keyframes avatarPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(255, 255, 255, 0); }
}

@media (max-width: 768px) {
    .norman-avatar {
        width: 45px;
        height: 45px;
    }
}

@media (max-width: 480px) {
    .norman-avatar {
        width: 40px;
        height: 40px;
    }
}

.header-afs-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    transition: all var(--slide-duration) ease;
}

@media (max-width: 768px) {
    .header-afs-logo {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 480px) {
    .header-afs-logo {
        width: 26px;
        height: 26px;
    }
}

.norman-avatar:hover .header-afs-logo {
    transform: scale(1.1) rotate(5deg);
    filter: brightness(0) invert(1) drop-shadow(0 0 8px rgba(255, 255, 255, 0.8));
}

.norman-info h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.norman-info p {
    margin: 0;
    font-size: 13px;
    opacity: 0.9;
}

@media (max-width: 768px) {
    .norman-info h3 {
        font-size: 16px;
    }
    .norman-info p {
        font-size: 12px;
    }
}

.norman-status {
    margin-left: auto;
    width: 10px;
    height: 10px;
    background: #00ff88;
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(0, 255, 136, 0.6);
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* 💬 ENHANCED CHAT MESSAGES */
.norman-chat-messages {
    height: 400px;
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
    background: linear-gradient(180deg, rgba(0, 123, 255, 0.02) 0%, rgba(255, 255, 255, 0.05) 100%);
}

@media (max-width: 768px) {
    .norman-chat-messages {
        height: 350px;
        padding: 20px 16px;
        gap: 18px;
    }
}

@media (max-width: 480px) {
    .norman-chat-messages {
        height: 360px;
        padding: 16px 12px;
        gap: 16px;
    }
}

/* Enhanced scrollbar */
.norman-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.norman-chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 123, 255, 0.08);
    border-radius: 3px;
}

.norman-chat-messages::-webkit-scrollbar-thumb {
    background: var(--afs-gradient);
    border-radius: 3px;
    transition: all 0.2s ease;
}

.norman-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--afs-gradient-reverse);
}

/* Enhanced Message Bubbles */
.message {
    display: flex;
    gap: 12px;
    animation: messageSlideIn 0.4s ease-out;
    align-items: flex-end;
    margin-bottom: 20px;
    padding: 0 8px;
    width: 100%;
    box-sizing: border-box;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message.user {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.message.norman {
    justify-content: flex-start;
}

/* Better spacing between consecutive messages from same sender */
.message + .message.norman {
    margin-top: -8px;
}

.message + .message.user {
    margin-top: -8px;
}

.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
    transition: all 0.2s ease;
}

.message-avatar:hover {
    transform: scale(1.05);
}

@media (max-width: 480px) {
    .message-avatar {
        width: 34px;
        height: 34px;
    }
}

.message.norman .message-avatar {
    background: var(--afs-gradient);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-weight: 600;
    font-size: 13px;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
    font-weight: 500;
    font-size: 11px;
}

.message-bubble {
    width: 100%;
    max-width: 320px;
    min-width: 200px;
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    margin: 4px 0;
}

.message-bubble:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

@media (max-width: 768px) {
    .message-bubble {
        max-width: 280px;
        min-width: 180px;
        padding: 12px 16px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .message-bubble {
        max-width: 250px;
        min-width: 160px;
        padding: 12px 16px;
        font-size: 13px;
        border-radius: 18px;
    }
}

/* Norman's messages (left side) */
.message.norman .message-bubble {
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.08) 0%, rgba(77, 171, 247, 0.12) 100%);
    border: 1px solid rgba(0, 123, 255, 0.15);
    color: var(--afs-text-dark);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px 20px 20px 4px;
    margin-left: 12px;
}

/* Speech tail for Norman's messages (left side) */
.message.norman .message-bubble::before {
    content: '';
    position: absolute;
    left: -8px;
    bottom: 8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 12px 12px 0;
    border-color: transparent rgba(0, 123, 255, 0.12) transparent transparent;
    z-index: 1;
}

.message.norman .message-bubble::after {
    content: '';
    position: absolute;
    left: -7px;
    bottom: 8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 11px 11px 0;
    border-color: transparent rgba(0, 123, 255, 0.08) transparent transparent;
    z-index: 2;
}

/* User's messages (right side) */
.message.user .message-bubble {
    background: var(--afs-gradient);
    color: white;
    box-shadow: 0 3px 12px rgba(0, 123, 255, 0.25);
    border-radius: 20px 20px 4px 20px;
    margin-right: 12px;
}

/* Speech tail for User's messages (right side) */
.message.user .message-bubble::before {
    content: '';
    position: absolute;
    right: -8px;
    bottom: 8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 12px 12px;
    border-color: transparent transparent rgba(0, 123, 255, 0.8) transparent;
    z-index: 1;
}

.message.user .message-bubble::after {
    content: '';
    position: absolute;
    right: -7px;
    bottom: 8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 11px 11px;
    border-color: transparent transparent #007bff transparent;
    z-index: 2;
}

.message-time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 4px;
    text-align: right;
    color: #6c757d;
    font-weight: 400;
}

.message.norman .message-time {
    text-align: left;
}

.message.user .message-time {
    text-align: right;
    color: rgba(255, 255, 255, 0.8);
}

/* Message content improvements */
.message-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 320px;
    min-width: 200px;
}

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

.message.norman .message-content {
    align-items: flex-start;
}

/* Responsive message content sizing */
@media (max-width: 768px) {
    .message-content {
        max-width: 280px;
        min-width: 180px;
    }
}

@media (max-width: 480px) {
    .message-content {
        max-width: 250px;
        min-width: 160px;
    }
}

/* Message Feedback Buttons */
.message-feedback {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    opacity: 0.8;
}

.feedback-btn {
    background: rgba(0, 123, 255, 0.1);
    border: 1px solid rgba(0, 123, 255, 0.2);
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--afs-primary);
}

.feedback-btn:hover {
    background: rgba(0, 123, 255, 0.15);
    border-color: rgba(0, 123, 255, 0.3);
    transform: translateY(-1px);
}

.feedback-btn:active {
    transform: translateY(0);
}

.feedback-btn.selected {
    background: var(--afs-primary);
    color: white;
    border-color: var(--afs-primary);
}

/* Enhanced Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--afs-gradient-light);
    border-radius: 22px;
    max-width: 70%;
    border: 1px solid rgba(0, 123, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.typing-dots {
    display: flex;
    gap: 5px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--afs-primary);
    border-radius: 50%;
    animation: typingPulse 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingPulse {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* 📝 ENHANCED CHAT INPUT */
.norman-chat-input {
    padding: 24px 20px;
    border-top: 1px solid rgba(0, 123, 255, 0.12);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 0 0 28px 28px;
}

@media (max-width: 768px) {
    .norman-chat-input {
        padding: 20px 16px;
        border-radius: 0 0 24px 24px;
    }
}

@media (max-width: 480px) {
    .norman-chat-input {
        padding: 16px 12px;
        border-radius: 0 0 20px 20px;
    }
}

.input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    border: 2px solid rgba(0, 123, 255, 0.2);
    border-radius: 24px;
    padding: 14px 18px;
    font-size: 14px;
    resize: none;
    outline: none;
    background: rgba(255, 255, 255, 0.95);
    transition: all 0.3s ease;
    max-height: 120px;
    min-height: 48px;
    font-family: inherit;
    line-height: 1.4;
}

.message-input:focus {
    border-color: var(--afs-primary);
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.12);
    background: rgba(255, 255, 255, 1);
}

@media (max-width: 480px) {
    .message-input {
        padding: 12px 16px;
        font-size: 13px;
        border-radius: 20px;
    }
}

.send-button {
    width: 48px;
    height: 48px;
    background: var(--afs-gradient);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(0, 123, 255, 0.25);
}

.send-button:hover:not(:disabled) {
    transform: scale(1.1) translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.35);
}

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

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

@media (max-width: 480px) {
    .send-button {
        width: 44px;
        height: 44px;
    }
}

.send-button svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* 🎨 ENHANCED WELCOME MESSAGE */
.welcome-message {
    text-align: center;
    padding: 40px 24px;
    color: var(--afs-text-dark);
    font-size: 14px;
    animation: welcomeFadeIn 1s ease-out;
}

@keyframes welcomeFadeIn {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
    .welcome-message {
        padding: 30px 20px;
        font-size: 13px;
    }
}

.welcome-afs-logo {
    width: 90px;
    height: 90px;
    margin: 0 auto 24px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: welcomeLogoFloat 3s ease-in-out infinite;
}

@keyframes welcomeLogoFloat {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    25% { transform: translateY(-4px) rotate(1deg); }
    50% { transform: translateY(-2px) rotate(0deg); }
    75% { transform: translateY(-6px) rotate(-1deg); }
}

@media (max-width: 480px) {
    .welcome-afs-logo {
        width: 70px;
        height: 70px;
        margin-bottom: 20px;
    }
}

.welcome-logo-img {
    width: 75px;
    height: 75px;
    object-fit: contain;
    filter: drop-shadow(0 6px 16px rgba(0, 123, 255, 0.3));
    transition: all var(--slide-duration) ease;
    z-index: 2;
    position: relative;
}

@media (max-width: 480px) {
    .welcome-logo-img {
        width: 60px;
        height: 60px;
    }
}

.welcome-logo-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 110px;
    height: 110px;
    background: var(--afs-gradient-glow);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.3;
    animation: welcomeGlow 2s ease-in-out infinite alternate;
    z-index: 1;
}

@keyframes welcomeGlow {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.2; }
    100% { transform: translate(-50%, -50%) scale(1.3); opacity: 0.4; }
}

@media (max-width: 480px) {
    .welcome-logo-glow {
        width: 90px;
        height: 90px;
    }
}

.welcome-message h4 {
    margin: 0 0 12px 0;
    font-size: 20px;
    font-weight: 600;
    background: var(--afs-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

@media (max-width: 480px) {
    .welcome-message h4 {
        font-size: 18px;
    }
}

.welcome-message p {
    margin: 0;
    opacity: 0.8;
    line-height: 1.5;
}

/* Loading States */
.norman-chat-container.loading {
    pointer-events: none;
}

.norman-chat-container.loading .norman-chat-header::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    animation: loadingShimmer 1.5s infinite;
}

@keyframes loadingShimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .norman-chat-bubble,
    .norman-avatar,
    .welcome-afs-logo,
    .typing-dot {
        animation: none;
    }
    
    .norman-chat-container {
        transition: opacity 0.2s ease;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .norman-chat-container {
        border: 2px solid var(--afs-primary);
    }
    
    .message-bubble {
        border: 1px solid currentColor;
    }
}

/* Print styles */
@media print {
    .norman-chat-bubble,
    .norman-chat-container {
        display: none !important;
    }
}
