/* static/css/styles.css */

/* Global Styles */
body {
    background-color: #121222; /* Dark fallback color */
    /*background-image: url('../wallpaper.webp'); /* Relative path */
    background-image: linear-gradient(rgba(5, 5, 15, 0.5), rgba(5, 5, 15, 0.7)),
                url("https://images.pexels.com/photos/110854/pexels-photo-110854.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center center;
    background-attachment: fixed;
    color: #e0e0e0; /* Default text color for dark theme */
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

/* Generic Label Styles */
label {
    display: inline-block;
    border-radius: 4px;
    margin-bottom: 0.3rem;
    font-weight: 500;
    background-color: transparent;
    padding: 0;
    color: #e0e0e0;
}

/* -------------------------------------------------- */
/* --- CHAT VIEW STYLES (DARK THEME) --- */
/* -------------------------------------------------- */

/* Main chat window container */
.chat-window {
    background-color: transparent !important;
    border: 1px solid rgba(80, 80, 100, 0.5);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    height: 90vh;
}

/* Chat Header */
.chat-header {
    background-color: rgba(28, 28, 48, 0.9) !important;
    color: #ffffff !important;
    padding: 0.65rem 1.1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 1px solid #3a3a5a !important;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    position: relative; /* Ensure z-index context */
    z-index: 10;
}
.chat-header a, .chat-header .btn {
    color: #ffffff;
}

/* Message Container */
#chatContainer {
    overflow-y: auto;
    padding: 1rem 1.2rem;
    border: none;
    background-color: rgba(15, 15, 30, 0.8);
    flex-grow: 1;
    min-height: 0;
}

/* Base Message Bubble Style */
.message-bubble {
    max-width: 88%;
    padding: 0.6rem 1rem;
    border-radius: 1.1rem;
    margin-bottom: 0.85rem;
    position: relative;
    line-height: 1.45;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* --- M19: Rich UI Cards --- */
.chat-card-wrapper {
    animation: slideUp 0.3s ease-out;
}

.chat-card {
    background: rgba(40, 40, 60, 0.7); /* Slightly translucent dark bg */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 20px;
    width: 100%;
    max-width: 600px; /* Increased for desktop grid view */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    color: #e0e0e0;
    margin: 0; /* Align left/right based on bubble */
    overflow: hidden; /* Contain children */
}

.chat-card h5 {
    font-size: 1.15rem;
    margin-bottom: 15px;
    font-weight: 600;
    color: #ffffff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 10px;
}

.chat-card .card-body {
    font-size: 0.95rem;
    margin-bottom: 15px;
}

.chat-card .card-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-card .btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: 10px;
    font-weight: 500;
    transition: transform 0.1s;
}

.chat-card .btn:active {
    transform: scale(0.98);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}
/* --------------------------- */


/* Timestamp inside bubble */
.message-bubble .timestamp {
    display: block;
    font-size: 0.68rem;
    color: #adb5bd;
    margin-top: 0.3rem;
    text-align: right;
    opacity: 0.8;
}

/* Make spinner inside message bubbles white for visibility */
.message-bubble .spinner-border {
    color: #ffffff !important;
}

/* Logged-in User Bubble */
.message-bubble.user {
    background-color: #004a77;
    color: #e8f7ff;
    align-self: flex-end;
    border-bottom-right-radius: 0.3rem;
}

/* Style for recipient mention in user's own message bubble */
.message-bubble.user .recipient-tag.text-muted {
    color: #a0d8ef !important; /* A light, visible cyan color. !important overrides Bootstrap's .text-muted */
    font-weight: 500;
    opacity: 0.95;
}

/* Other users' bubbles */
.message-bubble.other {
    background-color: #2a2a4a;
    color: #e0e0e0;
    align-self: flex-start;
    border-bottom-left-radius: 0.3rem;
    display: flex;
    gap: 0.75rem; /* Increased gap */
    align-items: flex-start;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    border: 1px solid #3a3a5a;
    max-width: 88%;
}

/* Assistant Bubble */
.message-bubble.assistant {
    background-color: #2E3A59; /* Changed from green to a calmer dark blue/grey */
    color: #e0e0e0; /* Adjusted text color for better contrast */
    align-self: flex-start;
    border-bottom-left-radius: 0.3rem;
    display: flex;
    gap: 0.75rem; /* Increased gap */
    align-items: flex-start;
    border: 1px solid #4a5a7a; /* Adjusted border color to match */
    max-width: 88%;
}

/* --- NEW: Markdown Content Styling --- */
.message-content h1, .message-content h2, .message-content h3, .message-content h4 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    line-height: 1.3;
}
.message-content h1 { font-size: 1.4em; }
.message-content h2 { font-size: 1.2em; }
.message-content h3 { font-size: 1.1em; }
.message-content h4 { font-size: 1.0em; }

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background-color: rgba(0, 0, 0, 0.1);
    border: 1px solid #4a5a7a;
}
.message-content th, .message-content td {
    border: 1px solid #4a4a6a;
    padding: 0.5rem 0.7rem;
    text-align: left;
}
.message-content th {
    background-color: rgba(0, 0, 0, 0.2);
    font-weight: 600;
}
.message-content tbody tr:nth-of-type(odd) {
    background-color: rgba(255, 255, 255, 0.03);
}

.message-content pre {
    background-color: rgba(0, 0, 0, 0.25);
    border: 1px solid #4a4a6a;
    padding: 0.8rem;
    border-radius: 0.5rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.88rem;
}
.message-content code {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.85em;
    font-family: "Courier New", Courier, monospace;
    color: #ffd54f; /* Brighter Amber/Yellow for high visibility */
}
.message-content pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}
.message-content blockquote {
    border-left: 4px solid #4a4a6a;
    padding-left: 1rem;
    margin-left: 0;
    margin-right: 0;
    color: #adb5bd;
    font-style: italic;
}
.message-content hr {
    border-top: 1px solid #4a4a6a;
    opacity: 0.25;
}
.message-content s, .message-content del {
    text-decoration: line-through;
    opacity: 0.7;
}
/* --- END: Markdown Content Styling --- */

/* --- NEW: Private Message Styling --- */
.message-bubble.message-private {
    /* A slightly different background to stand out */
    background-color: rgba(42, 42, 74, 0.8); 
    border: 1px solid #4a4a6a;
}

.private-message-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: #adb5bd;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid rgba(173, 181, 189, 0.2);
    display: block;
}

.private-message-header i {
    margin-right: 0.4rem;
    color: #6f42c1;
}
/* --- END: Private Message Styling --- */
/* --- NEW: Out of Context Message Styling --- */
.out-of-context-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: #adb5bd;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid rgba(173, 181, 189, 0.2);
    display: block;
}
.out-of-context-header i {
    margin-right: 0.4rem;
    color: #ffc107; /* Amber/Yellow for distinction */
}
/* --- END: Out of Context Message Styling --- */
/* Avatar - RESTORED TO 60px AS REQUESTED */
.message-bubble .avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background-color: #4a4a6a;
    background-image: linear-gradient(to bottom right, #4a4a6a, #3a3a5a);
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
}

/* Override background for AI span */
.message-bubble span.avatar.ai {
     background-image: linear-gradient(to bottom right, #20c997, #157347);
}

/* Styles for the image INSIDE the span.avatar */
.message-bubble .avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Message Content (Text and Inner Container) */
.message-content {
    flex-grow: 1;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    min-width: 0;
}

/* --- Mobile Optimization: Text Wrapping around Avatar --- */
@media (max-width: 768px) {
    /* Switch from Flexbox to Block display to allow floating */
    .message-bubble.assistant, 
    .message-bubble.other {
        display: block !important;
        position: relative;
    }

    /* Float the avatar to the left */
    .message-bubble.assistant .avatar, 
    .message-bubble.other .avatar {
        float: left;
        margin-right: 0.75rem;
        margin-bottom: 0.2rem;
        /* Ensure specific size is maintained */
        width: 50px; 
        height: 50px;
        font-size: 1rem;
    }

    /* Ensure content flows around the float */
    .message-content {
        display: block;
    }

    /* Clearfix to ensure bubble expands to contain floated avatar if text is short */
    .message-bubble.assistant::after, 
    .message-bubble.other::after {
        content: "";
        display: table;
        clear: both;
    }
    
    /* Slight adjustment for the Sender Name inside content when floating */
    .message-content > strong:first-child {
        margin-top: 0.2rem;
    }
}
/* This rule is now specific ONLY to the sender's name (the first strong tag, direct child of .message-content) */
.message-content > strong:first-child {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    color: #adb5bd;
    opacity: 0.9;
}

/* This rule resets all other strong/b tags (often inside <p> or <li>) to be inline and inherit their size/color */
.message-content p strong, .message-content li strong,
.message-content p b, .message-content li b {
    display: inline;
    font-size: inherit;
    font-weight: bold; /* 'bold' is often more reliable than a numeric weight */
    margin-bottom: 0;
    color: inherit;
    opacity: 1;
}
.message-content a:not(.btn) {
    color: #5dade2;
    text-decoration: underline;
}
.message-content a:not(.btn):hover {
    color: #8ecdee;
}

/* Style for recipient mention in user's own message bubble */
.message-bubble.user .recipient-tag {
    color: #a0d8ef; /* A light, visible cyan color */
    font-weight: 500;
    opacity: 0.95;
}

/* File and Audio Block */
.file-block, .audio-block {
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid #3a3a5a;
    border-radius: 0.6rem;
    padding: 0.7rem;
    margin-top: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}
.file-block i {
    font-size: 1.6rem;
}
.audio-block i {
    font-size: 1.6rem;
    color: #0dcaf0;
}

.file-info {
    flex-grow: 1;
    font-size: 0.9rem;
    overflow: hidden;
}
.file-info .filename {
    font-weight: 500;
    display: block;
    color: #5dade2;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-info .filename:hover {
    text-decoration: underline;
}
.file-info .filesize {
    font-size: 0.75rem;
    color: #adb5bd;
    opacity: 0.8;
    display: block;
}
.download-button {
    flex-shrink: 0;
}

/* Audio Transcription in audio block */
.audio-block .transcription {
    background-color: rgba(0,0,0, 0.1);
    border-left: 4px solid #004a77;
    padding: 0.4rem 0.8rem;
    font-style: italic;
    font-size: 0.88rem;
    margin-top: 0.5rem;
    color: #e0e0e0;
}
 /* File Content Preview in file block */
.file-block .file-content-preview {
    font-size: 0.85em;
    color: #e0e0e0;
    opacity: 0.9;
    max-height: 150px;
    overflow-y: auto;
    background-color: rgba(0,0,0, 0.1);
    padding: 0.5rem;
    border-radius: 0 0 0.6rem 0.6rem;
}

/* Image Preview Block */
.image-preview-block {
    margin-top: 0.4rem;
    max-width: 350px;
    cursor: pointer;
}
.chat-image-preview {
    max-height: 300px;
    width: auto;
    max-width: 100%;
    border: 1px solid #3a3a5a;
    background-color: #1c1c2c;
    display: block;
}

/* System Error */
.system-error-block {
    background-color: #491217;
    border-color: #f5c2c7 !important;
    color: #f8d7da;
    padding: 0.5rem 0.8rem;
    border-radius: 0.3rem;
    overflow-wrap: break-word;
}

/* Recipient Selector Bar */
.recipient-selector-bar {
    padding: 0.5rem 1.2rem;
    background-color: #1c1c2c;
    border-bottom: 1px solid #3a3a5a;
    flex-shrink: 0;
    font-size: 0.9rem;
    color: #e0e0e0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: nowrap;
}
.recipient-selector-bar label {
    margin-bottom: 0;
    font-weight: 500;
    display: inline-block;
    flex-shrink: 0;
}
.recipient-selector-bar select {
    display: inline-block;
    width: auto;
    min-width: 180px;
    border: 1px solid #3a3a5a;
    background-color: #2b2b4b;
    color: #e8e8e8;
    padding: 0.3rem 0.6rem;
    padding-right: 2rem;
    border-radius: 0.25rem;
    font-size: 0.9rem;
    line-height: 1.5;
    cursor: pointer;
    appearance: auto;
    background-image: none;
}
.recipient-selector-bar select:focus {
    outline: 0;
    border-color: #8d689c;
    box-shadow: 0 0 0 0.25rem rgba(141, 104, 156, 0.5);
}

/* Chat Input Area */
.chat-input-area-wrapper {
    position: relative;
}
.chat-input-area {
    padding: 0.6rem 1.2rem;
    background-color: #1c1c2c;
    /* border-top is now handled by the panel or this element directly */
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.input-row-top,
.input-row-bottom {
    display: flex;
    align-items: center;
    width: 100%;
}
.input-row-top {
    align-items: flex-end;
    gap: 0.5rem;
}
.input-row-top .form-control {
    flex-grow: 1;
    border-radius: 18px;
    padding: 0.5rem 1rem;
    min-height: 40px;
    max-height: 100px;
    resize: none;
    overflow-y: auto;
    background-color: #2b2b4b;
    border: 1px solid #3a3a5a;
    color: #e8e8e8;
    font-size: 1rem;
    line-height: 1.4;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.input-row-top textarea::-webkit-scrollbar {
    display: none;
}
.input-row-top textarea:focus {
    border-color: #8d689c;
    box-shadow: 0 0 0 0.2rem rgba(141, 104, 156, 0.25);
}
.input-row-top textarea::placeholder {
    color: #8a8a9a;
    opacity: 0.8;
}
.input-row-top #sendButton {
    flex-shrink: 0;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    font-size: 1.2rem;
    background-color: #2b2b4b;
    border: 1px solid #3a3a5a;
    color: #adb5bd;
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.input-row-top #sendButton:hover {
    background-color: #3a3a5a;
    color: #fff;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}
.input-row-top #sendButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #2b2b4b;
    color: #6c757d;
    box-shadow: none;
}
.input-row-top #sendButton.btn-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: white;
}
.input-row-top #sendButton.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}
.input-row-top #sendButton.btn-primary:disabled {
    background-color: #0d6efd;
    border-color: #0d6efd;
    opacity: 0.5;
}

.input-row-bottom {
    flex-shrink: 0;
    gap: 0.4rem;
    justify-content: space-between;
    min-height: 40px;
}
.input-actions-left,
.input-actions-right {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.recipient-selector-mobile-container {
    display: none;
}
.input-row-bottom .btn {
    flex-shrink: 0;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    font-size: 1.2rem;
    background-color: #2b2b4b;
    border: 1px solid #3a3a5a;
    color: #adb5bd;
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.input-row-bottom .btn:hover {
    background-color: #3a3a5a;
    color: #fff;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}
.input-row-bottom .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #2b2b4b;
    color: #6c757d;
    box-shadow: none;
}
.input-row-bottom .btn-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: white;
}
.input-row-bottom .btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}
.input-row-bottom .btn-primary:disabled {
    background-color: #0d6efd;
    border-color: #0d6efd;
    opacity: 0.5;
}
.input-row-bottom .btn-record.recording {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
}
.input-row-bottom .btn-record.recording:hover {
    background-color: #bb2d3b;
    border-color: #b02a37;
}

.chat-input-area .record-timer {
    font-size: 0.75rem;
    color: #dc3545;
    font-weight: 500;
    margin-left: 0.2rem;
    white-space: nowrap;
    flex-shrink: 0;
}

/* --- Chat Options Panel --- */
#chatOptionsPanel {
    position: absolute;
    bottom: 100%; /* Positioned right above the input area */
    left: 0;
    width: 100%;
    z-index: 20; /* BUG FIX: Increased z-index to be higher than the header (10) */
    background-color: #212134;
    border-top: 1px solid #3a3a5a;
    visibility: hidden;
    opacity: 0;
    transform: translateY(10px); /* Start slightly lower */
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

#chatOptionsPanel.active {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

/* FIX: Ensure help text in options panel wraps correctly and is visible */
#chatOptionsPanelDesktop .form-text, #chatOptionsPanelMobile .form-text {
    white-space: normal;
    word-wrap: break-word; /* For extra safety */
    color: #adb5bd; /* Ensure text is visible against dark panel */
}
.chat-options-btn {
    /* Base style for both desktop and mobile buttons */
    background-color: #2b2b4b !important;
    border-color: #3a3a5a !important;
    color: #adb5bd !important;
}

.chat-options-btn:hover {
    background-color: #3a3a5a !important;
    color: #fff !important;
}

.chat-options-btn.active {
    background-color: #8d689c !important;
    border-color: #8d689c !important;
    color: #fff !important;
}

/* -------------------------------------------------- */
/* --- GENERIC & DASHBOARD STYLES --- */
/* -------------------------------------------------- */

.section-title {
    font-weight: 600;
    color: #ffffff;
    position: relative;
    padding-bottom: 0.5rem;
    text-shadow: 0 0 10px rgba(100, 180, 255, 0.6);
    background-color: transparent;
    box-shadow: none;
    display: block;
    margin-bottom: 1rem;
}
.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background-color: #00bfff;
    border-radius: 2px;
    box-shadow: 0 0 12px 2px rgba(0, 191, 255, 0.7);
}

.page-header-block {
    background-color: rgba(28, 28, 48, 0.9) !important;
    border: 1px solid rgba(80, 80, 100, 0.4) !important;
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.page-header-block h1 {
    color: #ffffff;
    margin-bottom: 0;
    font-size: 1.75rem;
    font-weight: 600;
}
body .page-header-block a.btn.btn-outline-secondary {
    background-color: #4a4a6a;
    color: #ffffff;
    border-color: #5a5a7a;
}
body .page-header-block a.btn.btn-outline-secondary:hover {
    background-color: #5f5f8a;
    color: #ffffff;
    border-color: #6f6f9a;
}
body .page-header-block a.btn.btn-outline-secondary i {
    color: inherit;
}
body .page-header-block a.btn.btn-outline-secondary:focus,
body .page-header-block a.btn.btn-outline-secondary.focus {
  box-shadow: 0 0 0 0.25rem rgba(130, 138, 145, 0.5);
}

.agent-card {
    transition: box-shadow .2s ease-in-out, transform .2s ease-in-out;
    border: 1px solid #3a3a5a;
    display: flex;
    flex-direction: column;
}
.agent-card .card-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}
.agent-card .card-title {
    font-weight: 600;
}
.agent-card .agent-tags .badge {
    font-size: 0.75em;
}
.agent-card .agent-description {
    font-size: 0.88rem;
    color: #adb5bd;
    flex-grow: 1;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 50px;
}
.agent-card .card-img-top-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 100%;
    background-color: #2b2b4b;
    overflow: hidden;
    border-bottom: 1px solid #3a3a5a;
    display: block;
}
.agent-card .card-img-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.agent-card .card-img-top.is-default {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50%;
    height: 50%;
    object-fit: contain;
    opacity: 0.5;
}

@media (max-width: 576px) {
    .chat-input-area {
        flex-direction: column;
        align-items: stretch;
        gap: 0.3rem;
        padding: 0.4rem 0.6rem;
    }
    .input-row-top {
        order: 2;
    }
    .input-row-top textarea {
        margin-bottom: 0;
        min-height: 40px;
        max-height: 80px;
    }
    .input-row-bottom {
        order: 3;
        width: 100%;
        justify-content: space-between;
        min-height: 38px;
    }
    .recipient-selector-mobile-container {
        display: flex;
        flex-grow: 1;
        justify-content: center;
        overflow: hidden;
        order: 0;
        margin-bottom: 0.3rem;
    }
    .recipient-selector-mobile-container select {
        max-width: 100%;
        border: none;
        background-color: transparent;
        font-size: 0.8rem;
        font-weight: 500;
        color: #adb5bd;
        padding: 0.1rem 0.2rem;
        padding-right: 1rem;
        border-radius: 4px;
        text-overflow: ellipsis;
        white-space: nowrap;
        cursor: pointer;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23adb5bd' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 0.1rem center;
        background-size: 10px 10px;
    }
    .recipient-selector-mobile-container select:focus {
        box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
    }
    .input-row-bottom .btn {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }
    .input-row-top #sendButton {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }
    .recipient-selector-bar {
        display: none;
    }
    #file-selection-area {
        order: 1;
    }
    #selected-filename {
        max-width: 150px;
    }
    .share-toggle-container-infile {
        padding-left: 0.5rem;
    }
    .share-toggle-container-infile .form-check-label {
        font-size: 0.8rem;
    }
}

.auth-form-container {
    background-color: rgba(28, 28, 48, 0.92);
    border: 1px solid rgba(80, 80, 100, 0.5);
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}
.auth-form-container .form-label,
.auth-form-container .form-check-label {
    padding: 0.2rem 0.4rem;
    border-radius: 0.2rem;
    color: #e8e8e8;
    display: inline-block;
    margin-bottom: 0.25rem;
}
.auth-link-text a {
    color: #5dade2;
    text-decoration: none;
}
.auth-link-text a:hover {
    text-decoration: underline;
}
.language-selector {
    background-color: rgba(40, 40, 70, 0.8);
    display: inline-block;
}

.status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 5px;
    vertical-align: middle;
    flex-shrink: 0;
}
.status-indicator.status-online {
    background-color: #198754;
    box-shadow: 0 0 3px rgba(25, 135, 84, 0.7);
}
.status-indicator.status-offline {
    background-color: #adb5bd;
}

/* Offcanvas Dark Theme */
.offcanvas {
    background-color: #1c1c2c;
    color: #e0e0e0;
    border-left: 1px solid #3a3a5a;
}
.offcanvas-header {
    border-bottom: 1px solid #3a3a5a;
}
.offcanvas-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}
.offcanvas-body {
    --bs-offcanvas-padding-y: 1rem;
    --bs-offcanvas-padding-x: 1rem;
}
.offcanvas-body .list-group-flush .list-group-item {
    padding-left: 0;
    padding-right: 0;
    border-left: none;
    border-right: none;
    background-color: transparent;
    color: #e0e0e0;
    border-color: #3a3a5a;
}
.offcanvas-body .list-group-flush .list-group-item:last-child {
    border-bottom: none;
}
.offcanvas-body h6 {
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
    color: #8a8a9a; /* Lighter grey for section headers */
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background-color: #4a4a6a;
}
#flashAlertContainer .alert {
    background-color: rgba(40, 40, 70, 0.92);
    color: #f8f9fa;
    border-left-width: 5px;
    border-radius: 0.3rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}
#flashAlertContainer .alert-success {
    border-left-color: #198754;
}
#flashAlertContainer .alert-danger {
    border-left-color: #dc3545;
}
#flashAlertContainer .alert-warning {
    border-left-color: #ffc107;
}
#flashAlertContainer .alert-info {
    border-left-color: #0dcaf0;
}
#flashAlertContainer .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* === GENERIC DARK THEME FOR COMPONENTS === */
.card {
    background-color: rgba(28, 28, 48, 0.92) !important;
    border: 1px solid rgba(80, 80, 100, 0.5) !important;
    color: #e8e8e8 !important;
}
.card-header {
    border-bottom-color: rgba(80, 80, 100, 0.5) !important;
    color: #ffffff !important;
    background-color: rgba(40, 40, 70, 0.96) !important;
}
.card-footer {
    border-top-color: rgba(80, 80, 100, 0.5) !important;
    background-color: rgba(40, 40, 70, 0.96) !important;
}
.table {
    color: #e8e8e8 !important;
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(40, 40, 70, 0.96);
    --bs-table-hover-bg: rgba(55, 55, 85, 0.9);
}
.table > :not(caption) > * > * {
    background-color: var(--bs-table-bg);
    border-color: rgba(80, 80, 100, 0.6);
}
.table > thead.table-light th,
.table > thead.table-light > tr > th { /* Increased specificity */
    background-color: rgba(50, 50, 80, 1) !important;
    color: #ffffff !important;
}
.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: var(--bs-table-striped-bg);
    color: #e8e8e8;
}
.table-hover > tbody > tr:hover > * {
    background-color: var(--bs-table-hover-bg);
    color: #fff;
}
.form-control {
    background-color: #2b2b4b;
    color: #e8e8e8;
    border-color: #5a5a7a;
}
.form-control::placeholder {
    color: #8a8a9a;
}
.form-control:focus {
    background-color: #2b2b4b;
    color: #e8e8e8;
    border-color: #8d689c;
    box-shadow: 0 0 0 0.25rem rgba(141, 104, 156, 0.5);
}

/* --- Dark Theme Support for Native Inputs --- */
/* Forces browser-native pickers (date/time) to match the dark theme */
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
input[type="week"] {
    color-scheme: dark;
}

/* Specific fix for calendar icon in Webkit browsers if needed */
/* We target the class .form-control specifically to ensure specificity over Bootstrap */
.form-control::-webkit-calendar-picker-indicator {
    /* Since color-scheme: dark provides a white icon, we do NOT want to invert it. */
    filter: none; 
    opacity: 0.8;
    cursor: pointer;
    background-size: contain;
}
.form-control::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
.btn-primary, .btn-info, .btn-secondary, .btn-dark {
    color: #fff !important;
}
.btn-warning {
    color: #000 !important;
}
.list-group-item {
    background-color: rgba(40, 40, 70, 0.8);
    border-color: rgba(80, 80, 100, 0.5);
    color: #e8e8e8;
}
.list-group-item-action:hover, .list-group-item-action:focus {
    background-color: rgba(55, 55, 85, 0.9);
    color: #fff;
}

/* Modal Dark Theme */
.modal-content {
    background-color: #1c1c2c;
    color: #e0e0e0;
    border: 1px solid #3a3a5a;
}
.modal-header, .modal-footer {
    border-color: #3a3a5a;
}
.modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* --- Flatpickr Dark Theme Customization --- */
/* Target the confirmation bar using the correct .darkTheme class from the screenshot */
.flatpickr-confirm.darkTheme {
    background-color: #3a3a5a;
    border-top: 1px solid #5a5a7a;
    color: #e8e8e8; /* Set the text color for "OK" */
}
/* Style the SVG icon inside the confirmation bar */
.flatpickr-confirm.darkTheme svg {
    fill: #e8e8e8; /* Use 'fill' for SVG color */
}
/* Add a hover effect for better user feedback */
.flatpickr-confirm.darkTheme:hover {
    background-color: #5a5a7a;
    color: #ffffff;
}
.flatpickr-confirm.darkTheme:hover svg {
    fill: #ffffff;
}
/* General calendar styling for consistency */
.flatpickr-calendar.darkTheme {
    background: #2b2b4b;
    border: 1px solid #3a3a5a;
}
.flatpickr-calendar.darkTheme .flatpickr-day.selected {
    background: #8d689c;
    border-color: #8d689c;
}
.flatpickr-calendar.darkTheme .flatpickr-day:hover {
    background: #3a3a5a;
}
.flatpickr-calendar.darkTheme .flatpickr-time input:hover, 
.flatpickr-calendar.darkTheme .flatpickr-time .flatpickr-am-pm:hover, 
.flatpickr-calendar.darkTheme .flatpickr-time .flatpickr-time-separator:hover {
    background: #3a3a5a;
}
/* --- END Flatpickr Customization --- */

/* -------------------------------------------------- */
/* --- FULLCALENDAR DARK THEME OVERRIDES --- */
/* -------------------------------------------------- */
/* Force opaque background to hide page wallpaper */
.fc-view-harness, .fc-scrollgrid, .fc-scrollgrid td, .fc-scrollgrid th {
    background-color: #212529 !important; /* Bootstrap $dark */
}

/* Reset table borders inherited from Bootstrap */
.fc table, .fc th, .fc td {
    border-color: #495057 !important; 
}

/* Text Colors */
.fc {
    color: #e9ecef;
}

.fc-col-header-cell-cushion, .fc-timegrid-slot-label-cushion, .fc-list-day-cushion {
    color: #e9ecef !important;
    text-decoration: none !important;
}

/* Hover & Today Highlights */
.fc-timegrid-slot:hover, .fc-daygrid-day:hover {
    background-color: rgba(255,255,255,0.05) !important;
}
.fc-day-today {
    background-color: rgba(255,255,255,0.05) !important;
}

/* Toolbar Title */
.fc-toolbar-title {
    color: white !important;
    font-weight: 300;
}

/* Toolbar Buttons */
.fc-button-primary {
    background-color: #343a40 !important;
    border-color: #495057 !important;
    color: #fff !important;
}
.fc-button-primary:hover {
    background-color: #495057 !important;
}
.fc-button-primary:not(:disabled):active, 
.fc-button-primary:not(:disabled).fc-button-active {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
}

/* Event Styling */
.fc-event {
    border: none !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    border-radius: 3px;
}

/* --- MOBILE RESPONSIVENESS FOR CALENDAR --- */
@media (max-width: 768px) {
    #calendar {
        padding: 5px;
        height: 80vh !important; /* Use viewport height minus header/footer */
        overflow-x: auto !important; /* Allow horizontal scroll */
        overflow-y: auto !important; /* Allow vertical scroll */
    }
    
    /* Force width ONLY for Week/Month views to ensure readability */
    .fc-timeGridWeek-view .fc-view-harness, 
    .fc-dayGridMonth-view .fc-view-harness {
        min-width: 600px; 
    }
    
    /* Day view should fit screen width perfectly */
    .fc-timeGridDay-view .fc-view-harness {
        min-width: 100%;
    }

    /* Center Header Text */
    .fc-col-header-cell-cushion {
        width: 100%;
        text-align: center;
        display: block;
    }

    /* Toolbar Compact Mode */
    .fc-header-toolbar {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        margin-bottom: 10px !important;
    }
    
    .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
        align-items: center;
        flex-grow: 1; /* Distribute space */
    }

    .fc-toolbar-title {
        font-size: 1.1em !important;
        margin: 0 10px !important;
        white-space: nowrap;
    }
    
    .fc-button {
        padding: 0.25em 0.5em !important;
        font-size: 0.85em !important;
    }
}

/* --- M19: Custom Scrollbar for Cards --- */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}
