/* ============================================
   ALWEFEQ COMPANY CHATBOT - STYLE SHEET
   Industrial Equipment Solutions
   "Driven by Quality. Powered by Performance."
   ============================================ */

/* ---------- CSS VARIABLES ---------- */
:root {
    /* Brand Colors */
    --primary-blue: #042e69;
    --primary-blue-dark: #021d44;
    --primary-blue-light: #0a4a9e;
    --accent-green: #7bdc2b;
    --accent-green-dark: #5fb31e;
    --accent-green-light: #9de85c;
    
    /* Neutrals */
    --white: #ffffff;
    --off-white: #f8f9fa;
    --gray-100: #f1f3f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    
    /* Semantic Colors */
    --success: #28a745;
    --warning: #ffc107;
    --error: #dc3545;
    
    /* Typography */
    --font-primary: 'Barlow', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Barlow Condensed', 'Barlow', sans-serif;
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(4, 46, 105, 0.05);
    --shadow-md: 0 4px 12px rgba(4, 46, 105, 0.1);
    --shadow-lg: 0 8px 24px rgba(4, 46, 105, 0.15);
    --shadow-xl: 0 16px 48px rgba(4, 46, 105, 0.2);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;
    
    /* Chatbot Dimensions */
    --chatbot-width: 420px;
    --chatbot-height: 650px;
    --toggle-size: 60px;
}

/* ---------- RESET & BASE STYLES ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-primary);
    font-weight: 400;
    line-height: 1.6;
    color: var(--gray-800);
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-dark) 100%);
    min-height: 100vh;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input {
    font-family: inherit;
    border: none;
    outline: none;
}

/* ---------- CHATBOT CONTAINER ---------- */
.chatbot-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: 9999;
    font-family: var(--font-primary);
}

/* ---------- TOGGLE BUTTON ---------- */
.chatbot-toggle {
    width: var(--toggle-size);
    height: var(--toggle-size);
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-light) 100%);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg), 0 0 0 4px rgba(123, 220, 43, 0.2);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.chatbot-toggle::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--accent-green) 0%, var(--accent-green-dark) 100%);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: var(--shadow-xl), 0 0 0 6px rgba(123, 220, 43, 0.3);
}

.chatbot-toggle:hover::before {
    opacity: 1;
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-toggle svg {
    width: 28px;
    height: 28px;
    position: relative;
    z-index: 1;
    transition: all var(--transition-base);
}

.chatbot-toggle .chat-icon {
    opacity: 1;
    transform: scale(1);
}

.chatbot-toggle .close-icon {
    position: absolute;
    opacity: 0;
    transform: scale(0.5) rotate(-90deg);
}

/* Toggle Active State */
.chatbot-container.active .chatbot-toggle .chat-icon {
    opacity: 0;
    transform: scale(0.5) rotate(90deg);
}

.chatbot-container.active .chatbot-toggle .close-icon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* Pulse Animation */
.chatbot-toggle::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--accent-green);
    animation: pulse 2s infinite;
    z-index: -1;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.4;
    }
    50% {
        transform: scale(1.3);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* ---------- CHATBOT WINDOW ---------- */
.chatbot-window {
    position: absolute;
    bottom: calc(var(--toggle-size) + var(--space-md));
    right: 0;
    width: var(--chatbot-width);
    height: var(--chatbot-height);
    max-height: calc(100vh - var(--toggle-size) - var(--space-md) - var(--space-lg));
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all var(--transition-slow) cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* ---------- HEADER ---------- */
.chatbot-header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-dark) 100%);
    color: var(--white);
    padding: var(--space-lg);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

/* Geometric Pattern Overlay */
.chatbot-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(123, 220, 43, 0.03) 10px,
        rgba(123, 220, 43, 0.03) 20px
    );
    pointer-events: none;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}

.company-logo {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon svg {
    width: 100%;
    height: 100%;
}

.logo-icon .logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.company-info h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    line-height: 1.2;
    margin-bottom: 2px;
}

.company-info .tagline {
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    background: rgba(255, 255, 255, 0.1);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-full);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-green);
    border-radius: var(--radius-full);
    animation: statusPulse 2s infinite;
}

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

.status-text {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-slogan {
    position: relative;
    z-index: 1;
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 0.8rem;
    font-style: italic;
    color: var(--accent-green);
    text-align: center;
    font-weight: 500;
}

/* ---------- CHAT MESSAGES ---------- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    background: var(--off-white);
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: var(--radius-full);
}

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

/* Message Bubbles */
.message {
    max-width: 85%;
    animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-bubble {
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    line-height: 1.5;
    position: relative;
}

/* Bot Messages */
.message.bot {
    align-self: flex-start;
}

.message.bot .message-bubble {
    background: var(--white);
    color: var(--gray-800);
    border-bottom-left-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

/* User Messages */
.message.user {
    align-self: flex-end;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-light) 100%);
    color: var(--white);
    border-bottom-right-radius: var(--radius-sm);
}

/* Message Meta */
.message-meta {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-top: var(--space-xs);
    font-size: 0.7rem;
    color: var(--gray-500);
}

.message.bot .message-meta {
    padding-left: var(--space-xs);
}

.message.user .message-meta {
    justify-content: flex-end;
    padding-right: var(--space-xs);
}

/* Bot Avatar */
.bot-avatar {
    width: 24px;
    height: 24px;
    background: var(--white);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: var(--space-xs);
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.bot-avatar svg {
    width: 14px;
    height: 14px;
    color: var(--accent-green);
}

.bot-avatar .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: var(--space-md) var(--space-lg);
    background: var(--white);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: var(--radius-sm);
    width: fit-content;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--primary-blue);
    border-radius: var(--radius-full);
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Message Content Formatting */
.message-bubble strong {
    color: var(--primary-blue);
    font-weight: 600;
}

.message.user .message-bubble strong {
    color: var(--accent-green-light);
}

.message-bubble ul {
    margin: var(--space-sm) 0;
    padding-left: var(--space-lg);
}

.message-bubble li {
    margin-bottom: var(--space-xs);
}

.message-bubble a {
    color: var(--accent-green);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.message-bubble a:hover {
    color: var(--accent-green-dark);
    text-decoration: underline;
}

.message.user .message-bubble a {
    color: var(--accent-green-light);
}

/* Suggestion Chips in Messages */
.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-md);
}

.suggestion-chip {
    background: var(--gray-100);
    color: var(--primary-blue);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid var(--gray-200);
}

.suggestion-chip:hover {
    background: var(--primary-blue);
    color: var(--white);
    border-color: var(--primary-blue);
}

/* ---------- QUICK ACTIONS ---------- */
.quick-actions {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.quick-actions::-webkit-scrollbar {
    display: none;
}

.quick-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--off-white);
    color: var(--primary-blue);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all var(--transition-fast);
    border: 1px solid var(--gray-200);
}

.quick-btn svg {
    width: 16px;
    height: 16px;
}

.quick-btn:hover {
    background: var(--primary-blue);
    color: var(--white);
    border-color: var(--primary-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

/* ---------- INPUT AREA ---------- */
.chat-input-area {
    padding: var(--space-md);
    background: var(--white);
    border-top: 1px solid var(--gray-200);
}

.chat-form {
    display: flex;
    gap: var(--space-sm);
}

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--off-white);
    border-radius: var(--radius-lg);
    border: 2px solid var(--gray-200);
    padding: var(--space-xs);
    transition: all var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(4, 46, 105, 0.1);
}

.chat-input {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    font-size: 0.9rem;
    color: var(--gray-800);
}

.chat-input::placeholder {
    color: var(--gray-500);
}

.send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-light) 100%);
    color: var(--white);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

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

.send-btn:hover {
    background: linear-gradient(135deg, var(--accent-green) 0%, var(--accent-green-dark) 100%);
    transform: scale(1.05);
}

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

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

.powered-by {
    text-align: center;
    font-size: 0.65rem;
    color: var(--gray-500);
    margin-top: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---------- DEMO PAGE STYLES ---------- */
.demo-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    text-align: center;
}

.demo-content {
    max-width: 600px;
    color: var(--white);
}

.demo-content h1 {
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: 4px;
    margin-bottom: var(--space-md);
    text-transform: uppercase;
}

.demo-subtitle {
    font-size: 1.25rem;
    color: var(--accent-green);
    margin-bottom: var(--space-xl);
    font-weight: 500;
}

.demo-info {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-xl);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.demo-info p {
    margin-bottom: var(--space-sm);
    opacity: 0.9;
}

.demo-info p:last-child {
    margin-bottom: 0;
}

.demo-sectors {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    justify-content: center;
}

.demo-sectors span {
    background: var(--accent-green);
    color: var(--primary-blue-dark);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.85rem;
}

/* ---------- RESPONSIVE DESIGN ---------- */
@media (max-width: 768px) {
    .chatbot-container {
        bottom: var(--space-md);
        right: var(--space-md);
    }
    
    .chatbot-window {
        width: calc(100vw - var(--space-lg) * 2);
        height: calc(100vh - 120px);
        max-height: 600px;
        right: calc(-1 * var(--space-md));
        bottom: calc(var(--toggle-size) + var(--space-sm));
    }
    
    .demo-content h1 {
        font-size: 2.5rem;
    }
    
    .demo-info {
        padding: var(--space-lg);
    }
}

@media (max-width: 480px) {
    :root {
        --chatbot-width: 100vw;
        --toggle-size: 56px;
    }
    
    .chatbot-container {
        bottom: var(--space-md);
        right: var(--space-md);
    }
    
    .chatbot-window {
        position: fixed;
        width: calc(100vw - var(--space-md) * 2);
        height: calc(100vh - var(--toggle-size) - var(--space-md) * 3);
        max-height: calc(100vh - 100px);
        bottom: calc(var(--toggle-size) + var(--space-md));
        right: var(--space-md);
        border-radius: var(--radius-xl);
    }
    
    .quick-actions {
        padding: var(--space-sm);
    }
    
    .quick-btn {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.75rem;
    }
    
    .chat-input-area {
        padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0px));
    }
}

/* Extra small screens */
@media (max-width: 380px) {
    .chatbot-window {
        width: calc(100vw - var(--space-sm) * 2);
        right: var(--space-sm);
        height: calc(100vh - var(--toggle-size) - var(--space-md) * 3);
        bottom: calc(var(--toggle-size) + var(--space-md));
    }
    
    .chatbot-container {
        bottom: var(--space-sm);
        right: var(--space-sm);
    }
}

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

/* Focus Styles */
.chatbot-toggle:focus-visible,
.quick-btn:focus-visible,
.send-btn:focus-visible,
.suggestion-chip:focus-visible {
    outline: 2px solid var(--accent-green);
    outline-offset: 2px;
}

.chat-input:focus-visible {
    outline: none;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .message.bot .message-bubble {
        border: 2px solid var(--gray-800);
    }
    
    .quick-btn,
    .suggestion-chip {
        border: 2px solid var(--primary-blue);
    }
}
