/* static/dashboard.css */

/* --- 1. THEME MAPPING --- 
   This bridges your global style-tog.css variables to this specific dashboard layout 
*/
:root {
    --primary-color: var(--card-bg, #ffffff);       /* Sidebar/Chat backgrounds */
    --secondary-color: var(--primary, #2563eb);     /* Buttons/Accents */
    --text-font-color: var(--text-color, #1a1a1a);       /* Text */
    --border-color: var(--card-border, #e1e4e8);    /* Borders */
    --control-background: var(--bg-color, #f8f9fa); /* Input/Item backgrounds */
    --sidebar-width: 300px;
}

/* Fix for the main container to take full height/width, overriding landing page styles */
body {
    overflow: hidden; /* Prevent double scrollbars */
}

/* --- 2. LAYOUT & GRID --- */
.main-layout-wrapper {
    display: grid;
    /* Default: Hidden Sidebars */
    grid-template-columns: 0 1fr 0;
    height: calc(100vh - 70px); /* Subtract Header Height */
    margin-top: 4rem;           /* Push below fixed header */
    width: 100vw;
    transition: grid-template-columns 0.3s ease-in-out;
    position: relative;
    overflow: hidden;
}

/* Desktop layout states */
.main-layout-wrapper[data-sidebar-open="true"] { 
    grid-template-columns: var(--sidebar-width) 1fr 0; 
}
.main-layout-wrapper[data-sidebar2-open="true"] { 
    grid-template-columns: 0 1fr var(--sidebar-width); /* Using variable for consistency */
}
.main-layout-wrapper[data-sidebar-open="true"][data-sidebar2-open="true"] { 
    grid-template-columns: var(--sidebar-width) 1fr var(--sidebar-width); 
}

/* --- 3. SIDEBARS & CONTAINERS --- */
.sidebar-wrapper {
    grid-column: 1;
    background-color: var(--primary-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    color: var(--text-font-color);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    height: 100%;
}

.chatbot-container {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--control-background); /* Slightly different contrast for chat area */
    position: relative;
    overflow: hidden;
}

.chatbot-container2 {
    grid-column: 3;
    background-color: var(--primary-color);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    color: var(--text-font-color);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    height: 100%;
}

/* Visibility logic */
.main-layout-wrapper[data-sidebar-open="true"] .sidebar-wrapper,
.main-layout-wrapper[data-sidebar2-open="true"] .chatbot-container2 {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-toggle-btn { left: -25px !important;
    transform: rotate(-90deg) translateY(-50%); }
.sidebar-toggle-btn2 { right: 0; margin-right:-25px; transform: rotate(90deg) translateY(-50%); }
/* --- 4. TOGGLE BUTTONS --- */
.sidebar-toggle-btn, .sidebar-toggle-btn2 {
    position: absolute; /* Changed from fixed to absolute relative to container */
    top: 50%;
    z-index: 100;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 0 0 8px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transform-origin: top center;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
}


/* Hover Effects */
.sidebar-toggle-btn:hover, .sidebar-toggle-btn2:hover { 
    filter: brightness(1.1); 

}

/* --- 5. CHAT AREA STYLES --- */
.chat-input-div {
    padding: 1rem;
    background: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.chat-input-div h2 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
    color: var(--text-font-color);
}

.chat-input-area {
    display: flex;
    gap: 10px;
}

#user-input {
    flex-grow: 1;
    background: var(--control-background);
    color: var(--text-font-color);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
}

#send-button, #clear-button {
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0 20px;
    cursor: pointer;
    font-weight: 600;
}

.ghost-chat-window {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem 10%; /* Center chat content slightly */
    scroll-behavior: smooth;
}

/* --- 6. MESSAGE BUBBLES --- */
.chat-entry {
    margin-bottom: 1.5rem;
    max-width: 100%;
    animation: fadeIn 0.3s ease;
}

.chat-entry.user-message {
    text-align: right;
}

.chat-entry.user-message .message-content {
    background: var(--secondary-color);
    color: white;
    display: inline-block;
    padding: 10px 15px;
    border-radius: 15px 15px 0 15px;
    text-align: left;
}

.chat-entry.bot-message .message-content {
    background: var(--primary-color);
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 15px 15px 15px 0;
    color: var(--text-font-color);
}

/* Markdown Styles inside Bot Messages */
.message-content pre {
    background: #1e1e1e;
    color: #f8f8f2;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
}




/* --- 7. RESPONSIVE MOBILE --- */
@media (max-width: 768px) {
    .main-layout-wrapper {
        grid-template-columns: 0fr !important; /* Stack everything */
    }
    .nav-links{
        gap:0;
        display:grid;
        justify-items: center;

    }
    .sidebar-toggle-btn,.sidebar-toggle-btn2 {
        z-index: 1001;
    }
    .token-balance-display {
        grid-column: 1;
        grid-row: 1;
    }
    .header-control {
        grid-column: 1;
        grid-row: 2;    
    }
    .theme-toggle {
        grid-column: 2;
    }
    .main-layout-wrapper {
        margin-top: 7rem;
    }
    /* When sidebars are "open" on mobile, they slide over as overlays */
    .sidebar-wrapper, .chatbot-container2 {
        position: fixed;
        top: 70px;
        bottom: 0;
        width: 80%;
        z-index: 1000;
        box-shadow: 0 0 10px rgba(0,0,0,0.5);
    }
    
    .sidebar-wrapper { left: 0; transform: translateX(-100%); transition: transform 0.3s; opacity: 0; }
    .chatbot-container2 { right: 0; transform: translateX(100%); transition: transform 0.3s; opacity: 0; }
    
    /*.main-layout-wrapper[data-sidebar-open="true"] .chatbot-container2 { transform: translateX(100);}
    .main-layout-wrapper[data-sidebar2-open="true"] .sidebar-wrapper { transform: translateX(100);}*/

    .main-layout-wrapper[data-sidebar-open="true"] .sidebar-wrapper { transform: translateX(0); } 
    .main-layout-wrapper[data-sidebar2-open="true"] .chatbot-container2 { transform: translateX(0); }

    #user-input {
    grid-column: span 3;
    }
    #send-button {
        height: 3rem;
        grid-column: 2 / span 2;
        grid-row: 2;
        }
    #clear-button {
        display: none;
    }
    .chat-input-area {
        display: grid;
        grid-template-columns: 1fr 2fr;

    }
    
}

/*------guest popup-------*/
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.75); display: flex; justify-content: center; align-items: center; z-index: 10000; backdrop-filter: blur(4px); }

.modal-content-guest { background: var(--control-background); color: var(--text-font-color); padding: 2rem; border-radius: 12px; max-width: 550px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); border: 1px solid var(--border-color); }
.modal-button-guest {border-radius: 10px;
    padding: 1em;
    background:var(--accent)
}
/* --- THEME TOGGLE BUTTON & ADDITIONAL THEMES --- */
.theme-toggle { grid-row:1; background: none; border: none; color: var(--text-font-color); cursor: pointer; font-size: 1.4rem; padding: 0.4rem; margin-left: 0.5rem; opacity: 0.8; transition: color 0.3s ease, opacity 0.3s ease; border-radius: 50%;}
.theme-toggle:hover { color: var(--secondary-color); opacity: 1; background-color: var(--control-background); }

/* --- 8. UTILITIES --- */
.spinner-small { width: 1em; height: 1em; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }