/* ===================================================================
   INTELLIWP THEME - Light Theme for Chat Widget
   File: intelliwp-theme.css
   Description: Clean, organized theme with IntelliWP branding colors
   =================================================================== */

/* ========== CSS VARIABLES & COLOR PALETTE ========== */
:root {
    /* Primary Green Colors - IntelliWP Brand */
    --green-50: #f0fbe8;
    --green-100: #dcf7cc;
    --green-200: #bfed9e;
    --green-300: #9ade70;
    --green-400: #8AD851;  /* Main logo color */
    --green-500: #6eba37;
    --green-600: #4d9c1f;
    --green-700: #3a791a;
    --green-800: #2b5c14;
    --green-900: #1d400f;

    /* Blue Colors - IntelliWP Secondary */
    --blue-50: #ecf7fd;
    --blue-100: #d0e9f7;
    --blue-200: #a3d4ef;
    --blue-300: #73B9E5;   /* Secondary logo color */
    --blue-400: #4ca0d8;
    --blue-500: #3088c3;
    --blue-600: #236fa3;
    --blue-700: #1a5580;
    --blue-800: #123c5d;
    --blue-900: #0b2539;

    /* Grayscale Palette */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --gray--special: #e5e7eb;

    /* Purple Scale (Legacy) */
    --purple-50: #f5f0ff;
    --purple-100: #ede0ff;
    --purple-200: #d9c2ff;
    --purple-300: #bfa3f8;
    --purple-400: #a485e8;
    --purple-500: #8c66d9;
    --purple-600: #6d4aaf;
    --purple-700: #4f3485;
    --purple-800: #341e5c;
    --purple-900: #24004a;

    /* Accent Colors */
    --accent-50: #f5f2ff;
    --accent-100: #ede5ff;
    --accent-200: #d6ccff;
    --accent-300: #bfb3ff;
    --accent-400: #a894ff;
    --accent-500: #8366ff;   /* Active Accent */
    --accent-600: #7052e6;
    --accent-700: #5d3fcc;
    --accent-800: #472db3;
    --accent-900: #342199;

    /* Legacy Variables for Backward Compatibility */
    --accent-pro-000: var(--accent-500);
    --accent-pro-100: var(--accent-600);
    --accent-pro-200: var(--accent-700);

    /* Semantic Colors */
    --primary-purple: #24004a;
    --active-accent: #8366ff;
    --primary-blue: #0066ff;
    --light-teal: #7dd2c7;
    --light-blue-bg: #ebf3ff;
    --text-color: #1f1c26;
    --text-dark: #1a1a1a;
    --text-gray: #666666;
    --secondary-text: #555555;
    --text-light: rgba(255, 255, 255, 0.7);
    --card-bg: #f9f9f9;

    /* Text Variables for Consistency */
    --text-100: var(--text-color);
    --text-300: var(--text-gray);
    --oncolor-100: #ffffff;
    --border-200: rgba(0, 0, 0, 0.1);
    --bg-200: var(--gray-100);
    --bg-300: var(--gray-200);
}

/* ========== FONT CONFIGURATION ========== */
:root {
    font-family: Inter, sans-serif;
    font-feature-settings: 'liga' 1, 'calt' 1;
}

@supports (font-variation-settings: normal) {
    :root {
        font-family: InterVariable, sans-serif;
    }
}

/* ========== GLOBAL STYLES ========== */
/* Disable page scroll when chat is in fullscreen */
body.fullscreen-chat {
    overflow: hidden;
}

/* ========== CHAT CONTAINER STATES ========== */
chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border-radius: 1rem;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    font-family: var(--font-primary);
}

/* Closed State */
chat-container.closed {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: white;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 10;
}

chat-container.closed::after {
    content: "💬";
    font-size: 24px;
    color: white;
}

/* Medium State (Default Modal) */
chat-container.medium {
    width: 400px;
    height: 500px;
    border-radius: 1rem;
}

/* Fullscreen State */
chat-container.fullscreen {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    overflow-y: auto;
}

/* Legacy State Classes for Backward Compatibility */
chat-container.chat-closed {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-pro-100);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

chat-container.chat-closed::after {
    content: "💬";
    font-size: 24px;
    color: white;
}

chat-container.chat-medium {
    width: 400px;
    height: 500px;
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
}

chat-container.chat-fullscreen {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
}

/* ========== CHAT CONTROLS ========== */
.controls {
    display: flex;
    justify-content: flex-end;
    padding: 15px;
    background: var(--primary-blue);
    box-shadow: 0px 0px 15px rgba(0, 102, 255, 0.8);
    
}

.controls button {
    background: transparent;
    color: #fff;
    border: none;
    margin-left: 5px;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    height: 24px;
}

.controls button:hover {
    background: rgba(255, 255, 255, 1);
    color: var(--primary-blue)!important;
}

.controls button:hover svg {
    fill: var(--primary-blue)!important;
}

.content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.hidden {
    display: none;
}

/* Legacy Close Button */
.chat-close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent-pro-100);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    z-index: 10000;
}

.chat-close-button:hover {
    background: var(--accent-pro-000);
}

/* ========== MESSAGES CONTAINER ========== */
.container-messages {
    position: relative;
    flex: 1;
    width: 100%;
    margin: 0 auto;
    padding: 0;
    height: 98%;
    overflow: auto;
}

chat-messages {
    display: flex;
    flex-direction: column;
    padding: 20px 10px;
    width: 100%;
    max-width: 700px;
    margin: auto;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    box-sizing: border-box;
    justify-content: flex-start;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2);
    scroll-behavior: smooth;
}

/* Messages Container States */
.medium chat-messages {
    height: 90%;
    top: -60px;
}

.fullscreen chat-messages {
    overflow-y: auto;
    width: 100%;
    max-width: 100%;
}

/* Wrapper for fullscreen centering */
.fullscreen chat-messages .messages-content-wrapper {
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
}

/* ========== SCROLL INDICATOR ========== */
chat-messages .scroll-indicator {
    position: absolute;
    top: 20px;
    right: 10px;
    background: var(--blue-50);
    color: var(--blue-800);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    font-size: 14px;
}

chat-messages .scroll-indicator.visible {
    opacity: 1;
    transform: translateY(0);
}

chat-messages .scroll-indicator:hover {
    background: var(--primary-blue);
    color: white;
    transform: scale(1.05);
}

/* ========== LOADING INDICATORS ========== */
chat-messages .loading-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0.7;
}

chat-messages .loading-indicator.active {
    display: flex;
}

chat-messages .loading-dots {
    display: flex;
    gap: 4px;
}

chat-messages .loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    animation: loadingPulse 1.4s infinite ease-in-out;
}

chat-messages .loading-dot:nth-child(1) { 
    animation-delay: -0.32s; 
}

chat-messages .loading-dot:nth-child(2) { 
    animation-delay: -0.16s; 
}

@keyframes loadingPulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========== CHAT MESSAGES ========== */
chat-message {
    position: relative;
    width: 100%;
    margin-bottom: 15px;
    display: flex;
    min-height: auto;
    animation: messageSlideIn 0.3s ease-out;
}

chat-message:last-child {
    margin-bottom: 0;
}

chat-message[sender="user"] {
    justify-content: flex-end;
}

chat-message[sender="bot"] {
    justify-content: flex-start;
}

/* Message Animation */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== MESSAGE CONTENT ========== */
.message-content {
    padding: 12px 15px;
    max-width: 75%;
    border-radius: 6px;
    position: relative;
    margin: 0 50px;
    display: inline-block;
    word-break: break-word;
    border: 1px solid var(--border-200);
    line-height: 1.4rem;
    font-size: 1rem;
}

/* User Messages */
chat-message[sender="user"] .message-content {
    background-color: var(--green-50);
    color: var(--green-800);
    text-align: right;
}

/* Bot Messages */
chat-message[sender="bot"] .message-content {
    background-color: var(--blue-50);
    color: var(--blue-800);
    text-align: left;
}

/* Legacy Message Classes */
.chat-message {
    position: relative;
    width: 100%;
    margin-bottom: 15px;
    display: flex;
    min-height: auto;
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.bot {
    justify-content: flex-start;
}

.chat-message .message-content {
    padding: 12px 15px;
    max-width: 75%;
    border-radius: 1rem;
    position: relative;
    margin: 0 50px;
    display: inline-block;
    word-break: break-word;
    line-height: 1.4rem;
}

.chat-message.user .message-content {
    background-color: var(--accent-pro-200, hsl(251, 40%, 45.1%));
    color: #ffffffb3;
    font-size: 1rem;
}

.chat-message.bot .message-content {
    background-color: rgba(89, 69, 161, 0.2);
    color: #ffffffb3;
    text-align: left;
    font-size: 1rem;
}

.chat-message.bot .message-content li {
    list-style-position: inside;
}

/* ========== MESSAGE AVATARS ========== */
.icon-user,
.icon-bot {
    position: absolute;
    top: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    z-index: 2;
    border: 1px solid var(--border-200);
}

.icon-user {
    background-color: var(--green-50);
    color: var(--green-800);
    right: 0;
}

.icon-bot {
    background-color: var(--blue-50);
    color: var(--blue-800);
    left: 0;
}

/* Legacy avatar styles */
.chat-message .icon-user,
.chat-message .icon-bot {
    position: absolute;
    top: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    z-index: 2;
}

.chat-message .icon-user {
    background-color: var(--green-50);
    color: var(--green-800);
    right: 0;
}

.chat-message .icon-bot {
    background-color: var(--blue-50);
    color: var(--blue-800);
    left: 0;
}

/* ========== LINKS AND FORMATTING ========== */
chat-message a {
    color: var(--primary-blue);
    text-decoration: none;
}

chat-message a:hover {
    text-decoration: underline;
}

/* Lists in bot messages */
chat-message[sender="bot"] ul,
chat-message[sender="bot"] ol,
chat-message ul,
chat-message ol {
    padding-left: 1rem;
    margin: 0.5rem 0;
}

chat-message[sender="bot"] li,
chat-message li {
    margin: 0.25rem 0;
}

/* ========== CHAT INPUT ========== */
chat-input {
    position: absolute;
    bottom: 0;
    background-color: var(--primary-blue);
    color: var(--blue-800);
    padding: 0;
    display: none;
    z-index: 10;
    max-width: 100%;
    width: 100%;
    border-radius: 1rem;
    margin: auto;
}

/* Input States */
.medium chat-input,
.fullscreen chat-input,
chat-container.medium chat-input,
chat-container.fullscreen chat-input {
    display: block !important;
}

.fullscreen chat-input {
    border-radius: 0 !important;
}

.fullscreen chat-input button {
    height: 44px;
}

/* ========== INPUT CONTAINER ========== */
.container-input {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    box-sizing: border-box;
    gap: 10px;
}

/* ========== INPUT FIELD ========== */
chat-input input {
    flex: 1;
    padding: 8px;
    border: 2px solid transparent;
    border-radius: 1rem;
    margin-right: 0px;
    background-color: #fff;
    color: var(--text-100);
    font-size: 16px;
}

chat-input input:focus {
    outline: 1px solid #fff;
    outline-offset: 1px;
}

/* ========== INPUT BUTTONS ========== */
chat-input button {
    background-color: white;
    border: none;
    padding: 8px 16px;
    font-weight: 600;
    border-radius: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    height: 44px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

chat-input button:hover {
    background-color: white;
}

chat-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Button Icon States */
chat-input button svg.icon {
    fill: #6b7280;
    transition: fill 0.2s ease;
}

/* Send Button State */
chat-input button.btn-send svg.icon {
    fill: var(--primary-blue)!important;
}

chat-input button.btn-send:hover svg.icon {
    fill: var(--green-600);
}

/* Stop Button State */
chat-input button.btn-stop svg.icon {
    fill: #9ca3af!important;
}

chat-input button.btn-stop:hover svg.icon {
    fill: #dc2626;
}

/* Default Button State */
chat-input button.btn-default svg.icon,
chat-input button:not(.btn-send):not(.btn-stop) svg.icon {
    fill: #3b82f6;
}

chat-input button.btn-default:hover svg.icon,
chat-input button:not(.btn-send):not(.btn-stop):hover svg.icon {
    fill: #2563eb;
}

/* ========== TYPING INDICATORS ========== */
.typing-indicator {
    display: inline-block;
}

.chat-message .typing-indicator {
    display: inline-block;
}

/* Typing Overlay */
.typing-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: transparent;
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    border-radius: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.typing-overlay.active {
    opacity: 1;
}

/* Spinner Animation */
.spinner {
    width: 10px;
    height: 10px;
    border: 2px solid rgba(0, 0, 0, 0.384);
    border-radius: 50%;
    border-top-color: var(--primary-blue);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========== DISCLAIMER & STATUS ========== */
.disclaimer {
    max-width: 700px;
    margin: auto;
    font-size: 12px;
    text-align: center;
    color: #94a3b8;
    padding-bottom: 10px;
    opacity: 0.4;
}

.disclaimer a {
    color: var(--primary-blue);
    text-decoration: none;
}

#status-indicator {
    font-size: 12px;
    color: var(--text-300);
    text-align: center;
    padding: 5px;
    font-style: italic;
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    z-index: 5;
    pointer-events: none;
    display: none;
}

/* ========== ERROR MESSAGES ========== */
.ftc-chat-error {
    background-color: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 5px;
    border-left: 5px solid #f5c6cb;
    margin: 20px 0;
}

/* ========== HTML CONTENT FORMATTING ========== */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    color: var(--text-100);
    margin: 0.8em 0 0.4em 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-content h1 { font-size: 1.5em; }
.message-content h2 { font-size: 1.3em; }
.message-content h3 { font-size: 1.1em; }
.message-content h4 { font-size: 1em; font-weight: 600; }
.message-content h5 { font-size: 0.9em; font-weight: 600; }
.message-content h6 { font-size: 0.8em; font-weight: 600; }

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

.message-content em,
.message-content i {
    font-style: italic;
}

.message-content a {
    color: var(--primary-blue);
    text-decoration: underline;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.message-content a:hover {
    opacity: 0.8;
}

.message-content ul,
.message-content ol {
    margin: 0.5em 0;
    padding-left: 1.2em;
}

.message-content li {
    margin: 0.2em 0;
    line-height: 1.4;
}

.message-content ul li {
    list-style-type: disc;
}

.message-content ol li {
    list-style-type: decimal;
}

.message-content blockquote,
.message-content cite {
    background-color: var(--bg-200);
    border-left-color: var(--primary-blue);
    color: var(--text-200);
    margin: 0.8em 0;
    padding: 0.5em 0.8em;
    border-left: 3px solid;
    font-style: italic;
    opacity: 0.9;
}

.message-content code {
    background-color: var(--bg-200);
    color: var(--primary-blue);
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    padding: 0.1em 0.3em;
    border-radius: 3px;
}

.message-content pre {
    background-color: var(--bg-200);
    color: var(--text-100);
    border: 1px solid var(--bg-300);
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    padding: 0.8em;
    border-radius: 5px;
    overflow-x: auto;
    margin: 0.5em 0;
}

.message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 0.5em 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message-content p {
    margin: 0.5em 0;
    line-height: 1.5;
}

.message-content br {
    line-height: 1.5;
}

/* ========== UTILITY CLASSES ========== */
.smooth-scroll {
    scroll-behavior: smooth;
}

.no-scroll {
    overflow: hidden;
}

svg.icon {
    width: 16px;
    height: auto;
    fill: currentColor;
}


/* ========== ACCESSIBILITY & REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
    chat-messages {
        scroll-behavior: auto;
    }
    
    chat-messages chat-message,
    chat-messages .scroll-indicator,
    .typing-overlay {
        animation: none !important;
        transition: none !important;
    }
}