/* static/css/style.css */

:root {
    --google-blue: #4285F4;
    --google-red: #DB4437;
    --google-yellow: #F4B400;
    --google-green: #0F9D58;
    --anymcp-glass: rgba(0, 0, 0, 0.6);
    --sidebar-width: 250px;
    --chat-panel-bg: #1c1c1e;
    --chat-input-bg: #2c2c2e;
    --chat-border-color: #343a40;
}

body {
    background-color: black;
    overflow-x: hidden;
    letter-spacing: 0.6px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* --- Sidebar Styles --- */
.sidebar {
    height: 100vh;
    width: var(--sidebar-width);
    position: fixed;
    top: 0;
    left: 0;
    padding-top: 20px;
    transition: all 0.3s;
    z-index: 1030;
    border-right: 1px solid #343a40;
    font-weight: 600;
    background-color: var(--anymcp-glass);
    overflow-y: auto;
    scrollbar-width: thin;
}

.sidebar-header {
    padding: 0 1.5rem 1rem;
}

.sidebar .nav-link {
    padding: 1rem 1.5rem;
    transition: background-color 0.2s;
    font-size: large;
    font-weight: 100;
}

.sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* --- Nav Drawers --- */
.sidebar .nav-link .bi-chevron-down {
    transition: transform 0.3s;
}

.sidebar .nav-link[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

.sidebar .nav-link.active[data-bs-toggle="collapse"] {
    color: #fff;
}

.sidebar .nav-link.active:not([data-bs-toggle="collapse"]),
.sidebar .nav-link.active-child {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar .collapse .nav-link {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    font-size: medium;
}

.sidebar .nav-link.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* --- Main Content & Layout --- */
.main-content {
    position: relative;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s, width 0.3s;
}

.main-content.no-sidebar {
    margin-left: 0;
    width: 100%;
}

.main-content .navbar {
    border-bottom: 1px solid #343a40;
    height: 5rem;
    padding: 1rem;
    background-color: var(--anymcp-glass);
}

.content-area {
    padding: 2rem;
    background-color: var(--anymcp-glass) !important;
}

/* --- Video Background --- */
#bg-video {
    position: fixed;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: -100;
    transform: translateX(-50%) translateY(-50%);
    object-fit: cover;
    opacity: 0.6;
}

.video-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

/* --- Mobile Responsiveness --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1029;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* --- Component Styling --- */
.card {
    background-color: unset !important;
    border: 1px solid #343a40;
}
.card-header, .modal-header, .modal-footer {
    border-color: #343a40;
}
table {
    --bs-table-bg: unset !important;
}
.form-control, .form-select {
    background-color: unset;
    color: #fff !important;
    border: 1px solid #495057;
}
.form-control:focus, .form-select:focus {
    background-color: unset;
}
option { color: black !important; }
.modal-content {
    background-color: #212529;
    border: 1px solid #343a40;
}

/* --- Color & Text Helpers --- */
.gblue { color: var(--google-blue) }
.ggreen { color: var(--google-green) }
.gred { color: var(--google-red) }
.gyellow { color: var(--google-yellow) }
h1, h2, h3, h4, h5, .h1, .h2, .h3, .h4, .h5 {
    color: var(--google-blue) !important;
    margin-bottom: 0.1rem !important;
    font-weight: 100 !important;
}

/* --- Utility Styles --- */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.password-wrapper .form-control {
    padding-right: 3rem;
}
.password-toggle-icon {
    position: absolute;
    right: 0.75rem;
    cursor: pointer;
    z-index: 5;
    color: #adb5bd;
}
.btn.btn-loading {
    position: relative;
    color: transparent !important;
}
@keyframes spinner-animation { to { transform: rotate(360deg); } }
.btn.btn-loading::after {
    content: '';
    box-sizing: border-box;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1.2em;
    height: 1.2em;
    margin-top: -0.6em;
    margin-left: -0.6em;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: #ffffff;
    animation: spinner-animation .6s linear infinite;
}

/* --- CHAT UI STYLES --- */
.chat-page-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 7rem);
    padding-bottom: 1rem;
}

#chat-window {
    flex-grow: 1;
    overflow-y: auto;
    background-color: rgba(12, 26, 46, 0.5);
    border: 1px solid var(--chat-border-color) !important;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0.375rem;
}

.chat-panel {
    flex-shrink: 0;
    padding: 0.5rem;
    background-color: var(--chat-panel-bg);
    border: 1px solid var(--chat-border-color);
    border-radius: 0.5rem;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.chat-panel-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding: 0 0.5rem;
}

.chat-panel-top-row .form-select {
    max-width: 250px;
    font-size: 0.8rem;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

#context-memory-bar-container {
    flex-grow: 1;
    margin-left: 1rem;
}

#context-memory-text {
    font-size: 0.75rem;
}

.chat-input-area {
    background-color: var(--chat-input-bg);
    border: 1px solid var(--chat-border-color);
    border-radius: 0.5rem;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    margin-bottom: 0.5rem;
    position: relative;
    transition: all 0.2s;
}

/* --- Drag & Drop Styles --- */
.chat-input-area.drag-over {
    border: 2px dashed var(--google-blue);
    background-color: rgba(66, 133, 244, 0.1);
}

.chat-input-area.drag-over::after {
    content: "Drop files here";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--google-blue);
    font-weight: 600;
    font-size: 1.2rem;
    background-color: rgba(28, 28, 30, 0.8);
    border-radius: 0.5rem;
    pointer-events: none;
    z-index: 10;
}

#attachment-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 8px;
}
#attachment-container:not(:empty) {
     border-bottom: 1px solid var(--chat-border-color);
     margin-bottom: 8px;
}

#chat-input {
    background: transparent;
    border: none;
    color: #fff;
    width: 100%;
    resize: none;
    overflow-y: hidden;
    max-height: 200px;
    line-height: 1.5;
    padding: 0.25rem;
    overflow-y: scroll;
}

#chat-input:focus {
    outline: none;
    box-shadow: none;
}

.chat-actions-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.25rem;
}

.chat-actions-left {
    display: flex;
    gap: 0.5rem;
}

.chat-icon-btn {
    background: none;
    border: none;
    color: #adb5bd;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    transition: color 0.2s, background-color 0.2s;
}

.chat-icon-btn:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
}

#chat-button {
    color: var(--google-blue);
}

#chat-button:hover {
    background-color: rgba(66, 133, 244, 0.2);
}

#stop-icon {
    color: var(--google-red);
}

/* --- Message Bubbles --- */
.message { display: flex; flex-direction: column; position: relative; }
.message-bubble { 
    padding: 8px 15px; 
    border-radius: 20px; 
    max-width: 80%;
    word-wrap: break-word;
    position: relative;
}
.user { align-items: flex-end; }
.user .message-bubble { background-color: #0d6efd; color: white; }
.assistant { align-items: flex-start; }
.assistant .message-bubble {
    background-color: unset;
    border: unset;
    padding: unset;
    border-radius: unset;
    max-width: unset;
    word-wrap: unset;
}

/* Typing Indicator */
.typing-indicator { display: flex; align-items: center; padding: 5px 0; }
.typing-indicator span {
    height: 8px; width: 8px; background-color: #8c96a5;
    border-radius: 50%; display: inline-block; margin: 0 2px;
    animation: pulse 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.48s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(3) { animation-delay: -0.16s; }
.typing-indicator span:nth-child(4) { animation-delay: 0s; }
@keyframes pulse { 0%, 80%, 100% { transform: scale(0); opacity: 0.5; } 40% { transform: scale(1.0); opacity: 1; } }

/* Markdown Formatting */
.message-bubble h1, .message-bubble h2, .message-bubble h3, .message-bubble h4 { margin-top: 0.5em; margin-bottom: 0.5em; }
.message-bubble ul, .message-bubble ol { padding-left: 1.5em; margin-bottom: 0.5em; }

.menu-icon {
    border: solid;
    border-width: 1px;
    padding: 0px;
    padding-left: 5px;
    padding-right: 5px;
}

.login-container {
        padding-bottom: 10rem;
}

/* --- Agent Step / Thought Process Styles --- */
.agent-step { display: flex; margin: 10px 0; }
.agent-step-bubble {
    background-color: var(--anymcp-glass);
    color: #c0c8d1;
    border: 1px solid #495057;
    align-items: flex-start;
    font-size: 0.85rem;
    padding: 2px 15px;
    border-radius: 15px;
    max-width: 80%;
}
.agent-step-summary { display: flex; width: 100%; align-items: center; }
.agent-step-icon { margin-right: 8px; font-size: 1rem; color: var(--google-blue); }
.agent-step-message { font-style: italic; flex-grow: 1; font-size: 12px; }
.agent-step-message strong { font-weight: 600; color: #fff; }
.agent-step-details-toggle { font-size: 11px; }

/* --- Multimodal Attachment Styles --- */
.attachment-pill {
    display: inline-flex;
    align-items: center;
    background-color: #343a40;
    border: 1px solid #495057;
    border-radius: 15px;
    padding: 4px 10px;
    font-size: 0.85rem;
    color: #e9ecef;
    max-width: 100%;
}
.attachment-pill .bi { margin-right: 6px; font-size: 1.1rem; }
.attachment-pill .file-info {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.attachment-pill .file-tokens { color: #adb5bd; margin-left: 8px; font-style: italic; }
.attachment-pill .remove-file-btn {
    background: none; border: none; color: #adb5bd;
    margin-left: 8px; padding: 0 4px; cursor: pointer;
    font-size: 1.1rem; line-height: 1;
}
.attachment-pill .remove-file-btn:hover { color: #fff; }

.history-attachment-pill {
    display: flex;
    align-items: center;
    background-color: var(--anymcp-glass);
    border: 1px solid #5e5e60;
    border-radius: 10px;
    padding: 4px 10px;
    font-size: 0.8rem;
    color: #fff;
    margin-bottom: 5px;
    width: fit-content;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.history-attachment-pill i { margin-right: 6px; color: #9ca3af; }

/* --- Message Actions --- */
.message-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}
.message-row.user-row {
    justify-content: flex-end;
}

.delete-msg-btn {
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s;
    float: right;
    color: black;
    font-size: 1.5rem;
    padding: 0px;
    margin-top: -10px;
    margin-right: -10px;
}
.delete-msg-btn:hover { 
    color: var(--google-red); 
    opacity: 1;
}

/* --- Context Memory Bar --- */
#context-memory-bar {
    transition: width 0.4s ease-in-out, background-color 0.4s ease-in-out;
}
.progress-bar.bg-success { background-color: var(--google-green) !important; }
.progress-bar.bg-warning { background-color: var(--google-yellow) !important; }
.progress-bar.bg-danger { background-color: var(--google-red) !important; }

.bi-list { font-size: 25px !important; }
.bi-person-circle { margin-right: 1rem; font-size: 2.5rem !important; }

/* --- Agent Step Details & History Log --- */
.agent-step-details {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #495057;
    max-height: 15rem;
    overflow: scroll;
}

.agent-step-history-item {
    display: flex;
    align-items: flex-start;
    padding: 5px 0;
    font-size: 0.75rem;
    color: #adb5bd;
}

.agent-step-history-item .agent-step-icon {
    margin-right: 8px;
    font-size: 0.9rem;
    color: #adb5bd;
    margin-top: 2px;
}

.agent-step-history-item pre {
    background-color: rgba(0,0,0,0.2);
    border-radius: 5px;
    padding: 10px;
    font-family: monospace;
    white-space: pre-wrap;
    word-break: break-all;
    font-size: 0.75rem;
    margin-top: 5px;
    width: 100%;
}

/* --- Debug Error Styles --- */
.agent-step-bubble.debug-step-error {
    border-color: var(--google-red);
    color: #ffc9c9;
}
.agent-step-bubble.debug-step-error .agent-step-icon {
    color: var(--google-red);
}
.debug-error-content {
    background-color: rgba(50, 0, 0, 0.4);
    border: 1px solid rgba(219, 68, 55, 0.3);
    padding: 10px;
    border-radius: 5px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.75rem;
    color: #ff8888;
    white-space: pre-wrap;
    margin-bottom: 10px;
    overflow-x: auto;
}

/* --- Service Status Indicators --- */
.status-dot {
    height: 15px;
    width: 15px;
    background-color: #bbb;
    border-radius: 50%;
    display: inline-block;
    vertical-align: middle;
}
.status-green { background-color: var(--google-green); box-shadow: 0 0 5px var(--google-green); }
.status-red { background-color: var(--google-red); box-shadow: 0 0 5px var(--google-red); }
.status-yellow { background-color: var(--google-yellow); box-shadow: 0 0 5px var(--google-yellow); }

/* --- Chart Container Styling (Unified) --- */
.chat-chart-container {
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 350px;
    max-height: 600px;
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid #495057;
    border-radius: 8px;
    margin-top: 10px;
    margin-bottom: 10px;
}
.message-bubble.has-chart {
    width: 100%;
    max-width: 100%;
}

/* --- Schedule Proposal Card --- */
.schedule-proposal-card {
    background-color: var(--chat-input-bg);
    border: 1px solid var(--google-blue);
    border-radius: 12px;
    padding: 12px;
    min-width: 250px;
    max-width: 400px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.schedule-proposal-card .proposal-header {
    font-weight: bold;
    color: var(--google-blue);
    margin-bottom: 8px;
    border-bottom: 1px solid #495057;
    padding-bottom: 5px;
}

.schedule-proposal-card .proposal-body {
    font-size: 0.9rem;
    color: #e9ecef;
}

.schedule-proposal-card .proposal-actions {
    margin-top: 12px;
    display: flex;
    gap: 10px;
}

/* --- EMBED MODE OVERRIDES --- */
body.embed-mode {
    background-color: transparent !important;
    overflow: hidden;
    height: 100vh;
    padding: 0;
    margin: 0;
}
body.embed-mode #bg-video, 
body.embed-mode .video-overlay {
    display: none !important;
}
body.embed-mode .chat-page-container {
    height: 100vh;
    padding: 0.5rem;
}
body.embed-mode #chat-window {
    margin-bottom: 0.5rem;
}
body.embed-mode .chat-panel {
    padding: 0.25rem;
}

/* --- Media Queries --- */
@media (max-width: 991.98px) {
    .sidebar { left: calc(-1 * var(--sidebar-width)); background-color: rgba(0, 0, 0, 0.9); }
    .sidebar.active { left: 0; }
    .main-content { margin-left: 0; width: 100%; }
    .login-container { padding-bottom: 13rem; }
    .content-area { padding: 1rem; }
    
    /* Consolidated padding fix */
    /* .content-area {padding: 0px; padding-bottom: 0px;} */
    /* .container-fluid {padding: 0px;} */
    
    .agent-step-message, .agent-step-details-toggle { font-size: 10px; }
    .message { font-size: 13px; }
    .chat-page-container {height: calc(100vh - 7.5rem);}
    
    .dropdown-menu.show { font-size: 13px; }
    .main-content .navbar { height: unset; padding: unset; }
    .menu-icon { margin-left: 1rem; }
    .bi-list { font-size: 19px !important; }
    .bi-person-circle { margin-right: 1rem; font-size: 2.5rem !important; }
    .attachment-pill { font-size: 0.65rem; }
    .attachment-pill .bi { font-size: 1rem; }
    .user .message-actions { right: auto; left: -30px; margin-right: 0; }
}