/* V2.0 AI PLATFORM STYLES */

:root {
    --cgi-bg: #343541;
    --cgi-sidebar: #202123;
    --cgi-card: #444654;
    --cgi-text: #ececf1;
    --cgi-text-dim: #c5c5d2;
    --cgi-primary: #10a37f;
    --cgi-primary-hover: #1a7f64;
    --cgi-user-msg: #343541;
    --cgi-bot-msg: #444654;
}

html,
body {
    overflow: auto !important;
    /* Force scroll */
    height: auto !important;
}

/* CONTAINER - Full height relative to viewport is tricky in WP, so we use min-height */
/* CONTAINER */
#cgi-app-container {
    display: flex;
    flex-direction: row;
    height: 650px;
    /* Safe Fixed Height */
    background-color: var(--cgi-bg);
    color: var(--cgi-text);
    font-family: 'Inter', sans-serif;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    margin: 20px auto;
    width: 100%;
    max-width: 1400px;
}



/* SIDEBAR */
#cgi-sidebar {
    width: 280px;
    background-color: var(--cgi-sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    padding: 0;
}

.cgi-sidebar-header {
    padding: 15px 20px;
    flex-shrink: 0;
}

.cgi-sidebar-header h3,
.cgi-sidebar-header h4 {
    margin: 0;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* assistants Area (Top of Sidebar) */
#cgi-assistants-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* ACCORDION STYLES (PREMIUM) */
.cgi-category-group {
    margin-bottom: 8px;
    border-bottom: 0;
    /* Removing border for cleaner look */
}

/* Category Headers - DISTINCT & LARGE */
.cgi-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    /* Larger clickable area */
    cursor: pointer;
    color: var(--cgi-primary);
    font-size: 14px;
    /* Larger Text */
    font-weight: 800;
    /* Extra Bold */
    text-transform: uppercase;
    letter-spacing: 1.2px;
    transition: all 0.2s ease;
    border-radius: 8px;
    user-select: none;
    margin: 15px 5px 8px 5px;
    /* Separation */
    background: rgba(255, 255, 255, 0.04);
    /* Subtle background */
    border: 1px solid rgba(255, 255, 255, 0.08);
    /* Define structure */
}

.cgi-category-header:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.cgi-category-header.open {
    background: rgba(35, 226, 134, 0.15);
    /* Active Green Tint */
    border-color: rgba(35, 226, 134, 0.4);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Active/Open state brighter */
}

.cgi-cat-caret {
    margin-right: 10px;
    font-size: 14px;
    transition: transform 0.2s ease;
    opacity: 0.5;
}

.cgi-category-header:hover .cgi-cat-caret {
    opacity: 1;
}

.cgi-category-header.open .cgi-cat-caret {
    transform: rotate(90deg);
    opacity: 1;
    color: var(--cgi-primary);
    /* Highlight caret when open */
}

.cgi-cat-title {
    flex: 1;
    white-space: normal;
    /* Allow wrapping nicely if needed */
    line-height: 1.3;
}

.cgi-cat-count {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 12px;
    min-width: 24px;
    text-align: center;
    margin-left: 10px;
    font-weight: 600;
    flex-shrink: 0;
}

.cgi-category-content {
    padding-left: 0;
    /* Flush alignment */
    padding-top: 5px;
    display: none;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Tweak buttons inside accordion spacing */
.cgi-category-content .cgi-assistant-btn {
    margin-left: 10px;
    /* Slight indent */
    width: calc(100% - 20px);
    background: transparent;
    /* Cleaner inside list */
    border: 1px solid transparent;
    padding: 8px 10px;
}

.cgi-category-content .cgi-assistant-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.cgi-assistant-btn {
    background: #40414f;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    /* Flex for avatar + content */
    align-items: center;
    text-align: left;
    width: 100%;
}

.cgi-assistant-btn:hover {
    background: #505260;
    transform: translateX(2px);
    border-color: var(--cgi-primary);
}

.cgi-btn-content {
    display: flex;
    align-items: center;
    width: 100%;
}

.cgi-btn-avatar {
    object-fit: cover;
    flex-shrink: 0;
}

.cgi-btn-text {
    font-weight: 500;
    font-size: 14px;
    margin-left: 2px;
}

/* Hide Desc in default view to save space, or style it if needed. 
   Currently the new HTML structure put name inside .cgi-btn-text directly.
*/

/* History Area (Bottom of sidebar) */
#cgi-thread-list {
    flex: 0 0 30%;
    /* Fixed height portion */
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
}

/* Thread Row - Flex Layout for Safety */
.cgi-thread-row {
    display: flex;
    justify-content: space-between;
    /* Space between text and X */
    align-items: center;
    margin-bottom: 4px;
    padding-right: 5px;
    /* Little gap at end */
    position: relative;
}

/* Thread Item Style */
.cgi-thread-item {
    flex: 1;
    /* Take remaining space */
    padding: 10px 10px 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--cgi-text-dim);
    transition: background 0.2s, color 0.2s;
    min-width: 0;
    /* Crucial for flex truncation */
}

/* Global Delete Thread Button Style - FLEX FIX */
.cgi-delete-thread {
    position: static;
    /* No more absolute */
    flex-shrink: 0;
    /* Don't shrink */
    width: 24px;
    height: 24px;
    display: flex !important;
    /* Force Flex */
    align-items: center;
    justify-content: center;

    cursor: pointer;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.4);
    margin-left: 5px;
    border-radius: 50%;
    z-index: 20;
}

.cgi-delete-thread:hover {
    color: #ff4444 !important;
    background: rgba(255, 255, 255, 0.1);
}

.cgi-thread-row:hover .cgi-thread-item {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.cgi-thread-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Deprecated old flex hover rule, handled by row hover now */

/* MAIN AREA */
#cgi-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    background: var(--cgi-bg);
}

/* DASHBOARD GRID VIEW (Hidden by default now) */
#cgi-dashboard-view {
    display: none;
}


/* Chat Header with User Name */
.cgi-header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.cgi-user-name {
    color: white;
    font-weight: 500;
}

.cgi-new-chat-btn {
    padding: 8px 15px;
    background: var(--cgi-primary);
    color: white;
    border-radius: 5px;
    font-size: 13px;
    cursor: pointer;
    border: none;
    font-weight: 500;
}

.cgi-new-chat-btn:hover {
    background: var(--cgi-primary-hover);
}

/* CHAT VIEW */
#cgi-chat-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.cgi-chat-header {
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#cgi-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.cgi-msg {
    padding: 25px 40px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 16px;
    line-height: 1.6;
}

.cgi-msg.user {
    background: var(--cgi-user-msg);
}

.cgi-msg.bot {
    background: var(--cgi-bot-msg);
}

/* STARTER CHIPS (v8.5) */
.cgi-starter-chips {
    display: flex;
    gap: 10px;
    padding: 0 20px 15px 20px;
    background: var(--cgi-bg);
    overflow-x: auto;
    white-space: nowrap;
}

.cgi-chip {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--cgi-text);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.cgi-chip:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--cgi-primary);
}

/* Input Area - Larger */
#cgi-input-area {
    padding: 20px;
    background: var(--cgi-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

#cgi-input {
    width: 100%;
    background: #40414f;
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: white;
    padding: 15px;
    border-radius: 8px;
    font-size: 16px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    resize: none;
    height: 80px;
    /* Bigger */
    font-family: inherit;
}

#cgi-input:focus {
    border-color: var(--cgi-primary);
    outline: none;
}

/* Preview inside input area */
#cgi-file-preview {
    font-size: 12px;
    color: var(--cgi-primary);
    font-weight: bold;
    margin-bottom: 5px;
    /* above input */
    margin-left: 45px;
    /* align with text */
}

/* Send Button */
#cgi-send-btn {
    height: 50px;
    width: 50px;
    border-radius: 8px;
    margin-left: 10px;
}

#cgi-attach-btn {
    background: transparent;
    border: none;
    color: var(--cgi-text-dim);
    cursor: pointer;
    margin-right: 10px;
    padding: 5px;
}

#cgi-attach-btn:hover {
    color: white;
}

/* The original #cgi-input-area display flex rule was removed as it's now part of the new #cgi-input-area definition */

.error-msg {
    color: #ff6b6b;
}

.hidden {
    display: none !important;
}

/* --- FULL SCREEN MODE (v8.1 Hotelia Style) --- */
#cgi-app-container.cgi-fullscreen {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw !important;
    max-width: none !important;
    /* Ensure it stretches fully */
    height: 100vh !important;
    z-index: 2147483647;
    /* Maximum z-index */
    margin: 0 !important;
    border-radius: 0 !important;
    /* No rounded corners in fullscreen */
    display: flex;
    flex-direction: row;
    background-color: var(--cgi-bg);
}

/* Hide WP Admin Bar if visible (optional) */
/* html.wp-toolbar { margin-top: 0 !important; }
   #wpadminbar { display: none !important; } */

/* Update Sidebar for Full Height */
#cgi-sidebar {
    height: 100vh;
    z-index: 1000000;
    /* Ensure on top */
    position: relative;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

/* Update Chat View for Full Height */
#cgi-chat-view {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

#cgi-messages {
    flex: 1;
    height: auto;
    padding-bottom: 20px;
    overflow-y: auto;
    /* Restore scrolling */
}

/* --- VOICE BUTTON --- */
#cgi-voice-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--cgi-text-dim);
    margin-right: 10px;
    padding: 10px;
    border-radius: 50%;
    transition: 0.2s;
    position: relative;
    z-index: 1000002;
    pointer-events: auto;
}

#cgi-voice-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

#cgi-voice-btn.recording {
    color: #ff4b4b;
    animation: cgi-pulse 1.5s infinite;
}

@keyframes cgi-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 75, 75, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(255, 75, 75, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 75, 75, 0);
    }
}

/* Fix Input Area and Z-Index */
#cgi-input-area {
    position: relative;
    z-index: 1000001;
}

#cgi-attach-btn {
    position: relative;
    z-index: 1000002;
    pointer-events: auto;
}

/* --- MARKDOWN STYLES (v4.1) --- */
.cgi-markdown {
    font-size: 16px;
    line-height: 1.6;
}

.cgi-markdown p {
    margin-bottom: 1em;
}

.cgi-markdown p:last-child {
    margin-bottom: 0;
}

.cgi-markdown code {
    background: #2a2b32;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

.cgi-markdown pre {
    background: #000;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
}

.cgi-markdown pre code {
    background: transparent;
    padding: 0;
    color: #e0e0e0;
}

.cgi-markdown ul,
.cgi-markdown ol {
    margin-left: 20px;
    margin-bottom: 1em;
}

.cgi-markdown blockquote {
    border-left: 3px solid var(--cgi-primary);
    margin: 10px 0;
    padding-left: 15px;
    color: var(--cgi-text-dim);
}

/* --- TYPING INDICATOR (v4.1) --- */
#cgi-loading-bubble {
    padding: 20px 40px;
    background: var(--cgi-bot-msg);
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #ccc;
    border-radius: 50%;
    margin-right: 5px;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* FADE IN ANIMATION for Messages */
.cgi-msg {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- WELCOME SCREEN (v9.0 Redesign) --- */
.cgi-welcome-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    padding: 20px;
}

.cgi-welcome-card {
    background: var(--cgi-card, #444654);
    backdrop-filter: blur(10px);
    padding: 50px 40px;
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 500px;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.08);
    /* Subtle border */
    animation: cgiSlideUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
    overflow: hidden;
}

/* Add a subtle top gradient line */
.cgi-welcome-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--cgi-primary), #00c6ff);
}

.theme-minimal .cgi-welcome-card {
    background: #ffffff;
    border: 1px solid #e5e5ea;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.06);
}

.cgi-welcome-emoji {
    font-size: 56px;
    display: inline-block;
    margin-bottom: 20px;
    animation: cgiWave 2.5s infinite;
    transform-origin: 70% 70%;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.1));
}

.cgi-welcome-header h2 {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 15px 0;
    color: var(--cgi-text, #fff);
}

.theme-minimal .cgi-welcome-header h2 {
    color: #1c1c1e;
    /* Apple darker grey */
}

.cgi-user-name-highlight {
    background: linear-gradient(90deg, #10a37f, #2dd4bf);
    /* Brand Green Gradient */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.theme-minimal .cgi-user-name-highlight {
    background: linear-gradient(90deg, #007aff, #5ac8fa);
    /* Apple Blue Gradient */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.cgi-welcome-text {
    font-size: 16px;
    line-height: 1.6;
    color: var(--cgi-text-dim, #acacbe);
    margin-bottom: 35px;
}

.theme-minimal .cgi-welcome-text {
    color: #6e6e73;
}

.cgi-welcome-action-hint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: rgba(16, 163, 127, 0.1);
    color: var(--cgi-primary);
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
}

.theme-minimal .cgi-welcome-action-hint {
    background: rgba(0, 122, 255, 0.1);
    color: #007aff;
}

.cgi-welcome-action-hint:hover {
    transform: translateX(-5px);
    background: rgba(16, 163, 127, 0.2);
}

.theme-minimal .cgi-welcome-action-hint:hover {
    background: rgba(0, 122, 255, 0.2);
}

/* Animations */
@keyframes cgiSlideUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cgiWave {
    0% {
        transform: rotate(0.0deg)
    }

    10% {
        transform: rotate(14.0deg)
    }

    20% {
        transform: rotate(-8.0deg)
    }

    30% {
        transform: rotate(14.0deg)
    }

    40% {
        transform: rotate(-4.0deg)
    }

    50% {
        transform: rotate(10.0deg)
    }

    60% {
        transform: rotate(0.0deg)
    }

    100% {
        transform: rotate(0.0deg)
    }
}