/* ============================================
   ENTERPRISE LIVE SUPPORT CHAT WIDGET
   Industrial-Grade Premium Design
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Enterprise Color System */
    --primary-color: #33B9C6;
    --primary-hover: #2a9aa5;
    --primary-light: #e6f7f9;
    --primary-gradient: linear-gradient(135deg, #33B9C6 0%, #2ea5b3 100%);
    
    --success-color: #059669;
    --success-light: #d1fae5;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    
    --border-light: #e2e8f0;
    --border-medium: #cbd5e1;
    
    --agent-bg: #f8fafc;
    --user-bg: #4f46e5;
    
    /* Enterprise Shadow System */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: #f3f4f6;
}

/* Demo Page Styles */
.demo-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 60px 20px;
}

.demo-page h1 {
    font-size: 2.5rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.demo-page p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

/* ============================================
   FLOATING CHAT BUTTON
   ============================================ */

.chat-button {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 68px;
    height: 68px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-2xl);
    transition: all var(--transition-slow);
    z-index: 9998;
    border: 0;
    outline: none;
}

.chat-button::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    padding: 2px;
    background: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.6;
}

.chat-button:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 30px 60px -15px rgba(51, 185, 198, 0.5);
}

.chat-button:active {
    transform: translateY(0) scale(0.98);
}

.chat-icon {
    width: 34px;
    height: 34px;
    color: white;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Pulse Animation */
.pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: pulse 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    opacity: 0;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Tooltip */
.chat-button-tooltip {
    position: absolute;
    right: 80px;
    background: var(--text-primary);
    color: white;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
    box-shadow: var(--shadow-lg);
    letter-spacing: -0.01em;
}

.chat-button-tooltip::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid var(--text-primary);
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

.chat-button:hover .chat-button-tooltip {
    opacity: 1;
}

/* ============================================
   CHAT WINDOW
   ============================================ */

.chat-window {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 420px;
    height: 600px;
    background: var(--bg-primary);
    border-radius: 20px;
    box-shadow: var(--shadow-2xl);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-light);
    backdrop-filter: blur(20px);
}

.chat-window.active {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================
   CHAT HEADER
   ============================================ */

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: var(--primary-gradient);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.agent-avatar {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    border: 2.5px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), inset 0 1px 3px rgba(255, 255, 255, 0.3);
}

.agent-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.status-indicator {
    display: none;
}

.agent-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.agent-name {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.02em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.agent-status {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13.5px;
    opacity: 0.95;
    font-weight: 500;
}

.status-dot {
    width: 7px;
    height: 7px;
    background: var(--success-color);
    border-radius: 50%;
    animation: statusPulse 2s ease-in-out infinite;
    box-shadow: 0 0 4px rgba(5, 150, 105, 0.6);
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.9);
    }
}

.status-text {
    font-weight: 500;
}

.close-button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    padding: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: all var(--transition-base);
    opacity: 0.9;
    backdrop-filter: blur(10px);
}

.close-button:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
    transform: scale(1.05);
}

.close-button:active {
    transform: scale(0.95);
}

.close-button svg {
    width: 22px;
    height: 22px;
    stroke-width: 2.5;
}

/* ============================================
   MESSAGES AREA
   ============================================ */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 18px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 7px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
    margin: 8px 0;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 10px;
    transition: background var(--transition-base);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Message Styles */
.message {
    display: flex;
    animation: messageSlide 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.agent-message {
    justify-content: flex-start;
}

.user-message {
    justify-content: flex-end;
}

.message-content {
    max-width: 80%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.message-text {
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.65;
    word-wrap: break-word;
    font-weight: 400;
    letter-spacing: -0.01em;
}

.message-text p {
    margin: 0;
    line-height: 1.65;
}

.message-text p + p {
    margin-top: 12px;
}

.message-text br {
    display: block;
    margin: 3px 0;
    content: "";
    line-height: 1.65;
}

.agent-message .message-text {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-bottom-left-radius: 6px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.user-message .message-text {
    background: var(--user-bg);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: var(--shadow-md);
}

.message-time {
    font-size: 11.5px;
    color: var(--text-tertiary);
    padding: 0 6px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.agent-message .message-time {
    text-align: left;
}

.user-message .message-time {
    text-align: right;
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.typing-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 0 24px 12px 24px;
    background: var(--bg-secondary);
}

.typing-indicator.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border-radius: 18px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.typing-dots span {
    width: 7px;
    height: 7px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

.typing-text {
    font-size: 13.5px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ============================================
   INPUT AREA
   ============================================ */

.chat-input {
    padding: 20px 24px;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border-top: 1px solid var(--border-light);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid transparent;
    border-radius: 28px;
    padding: 4px 6px 4px 20px;
    transition: all var(--transition-base);
    box-shadow: 0 2px 8px rgba(51, 185, 198, 0.08), 
                inset 0 0 0 1px rgba(51, 185, 198, 0.1);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.input-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 28px;
    padding: 2px;
    background: linear-gradient(135deg, var(--primary-color) 0%, rgba(51, 185, 198, 0.3) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.input-wrapper:focus-within::before {
    opacity: 1;
}

.input-wrapper:focus-within {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 4px 20px rgba(51, 185, 198, 0.15),
                0 0 0 4px rgba(51, 185, 198, 0.08),
                inset 0 1px 2px rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.emoji-button {
    display: none;
}

.message-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 15px;
    color: var(--text-primary);
    padding: 14px 12px;
    font-family: inherit;
    font-weight: 400;
    letter-spacing: -0.01em;
    line-height: 1.5;
}

.message-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
    letter-spacing: -0.005em;
}

.send-button {
    background: var(--primary-gradient);
    border: none;
    color: white;
    cursor: pointer;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-base);
    min-width: 48px;
    min-height: 48px;
    box-shadow: 0 4px 12px rgba(51, 185, 198, 0.3),
                0 2px 4px rgba(51, 185, 198, 0.2),
                inset 0 -1px 2px rgba(0, 0, 0, 0.1),
                inset 0 1px 2px rgba(255, 255, 255, 0.3);
    position: relative;
}

.send-button::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 100%);
    opacity: 1;
    transition: opacity var(--transition-base);
}

.send-button:hover {
    background: linear-gradient(135deg, #2ea5b3 0%, #33B9C6 100%);
    transform: translateY(-2px) scale(1.08);
    box-shadow: 0 8px 20px rgba(51, 185, 198, 0.4),
                0 4px 8px rgba(51, 185, 198, 0.3),
                inset 0 -1px 2px rgba(0, 0, 0, 0.15),
                inset 0 1px 3px rgba(255, 255, 255, 0.4);
}

.send-button:hover::before {
    opacity: 0.8;
}

.send-button:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(51, 185, 198, 0.3),
                inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.send-button:disabled {
    background: var(--border-medium);
    cursor: not-allowed;
    transform: scale(1);
    opacity: 0.5;
}

.send-button svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
}

/* ============================================
   CHAT FOOTER
   ============================================ */

.chat-footer {
    padding: 10px 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
    text-align: center;
}

.footer-text {
    font-size: 12px;
    color: var(--text-tertiary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.footer-text::before {
    content: '';
    width: 12px;
    height: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2' ry='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    display: inline-block;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 480px) {
    .chat-window {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
        border: none;
    }

    .chat-button {
        bottom: 24px;
        right: 24px;
        width: 60px;
        height: 60px;
    }

    .chat-icon {
        width: 30px;
        height: 30px;
    }

    .message-content {
        max-width: 85%;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .chat-button,
    .send-button {
        border: 2px solid currentColor;
    }
    
    .message-text {
        border: 2px solid currentColor;
    }
}
