* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #e9af31;
    --secondary-color: #203650;
    --background-color: #f5f7fa;
    --text-color: #333;
    --text-secondary: #666;
    --border-color: #e0e0e0;
    --success-color: #27ae60;
    --error-color: #e74c3c;
    --sidebar-bg: #203650;
    --sidebar-text: #ecf0f1;
    --message-bg: #fff;
    --message-sent-bg: #e9af31;
    --message-sent-text: #1a2a3a;
    --auth-bg: #f0f0f0;
    --auth-box-bg: rgba(255, 255, 255, 0.98);
    --logo-opacity: 0.08;
    --logo-filter: brightness(0) invert(1);
    --input-bg: #ffffff;
    --input-text: #333;
    --input-container-bg: #ffffff;
}

/* Dark theme */
body.dark-theme {
    --background-color: #203650;
    --text-color: #e0e0e0;
    --text-secondary: #999;
    --border-color: rgba(255, 255, 255, 0.1);
    --sidebar-bg: #203650;
    --sidebar-text: #e0e0e0;
    --message-hover: rgba(255, 255, 255, 0.3);
    --message-bg: #2a2a2a;
    --message-sent-bg: #e9af31;
    --message-sent-text: #fff;
    --auth-bg: #0a0a0a;
    --auth-box-bg: rgba(26, 26, 26, 0.95);
    --logo-opacity: 0.03;
    --logo-filter: brightness(1) invert(0);
    --input-bg: #2a2a2a;
    --btn-color: #ffffff;
    --input-text: #e0e0e0;
    --input-container-bg: #203650;
}

/* Light theme */
body.light-theme {
    --background-color: #ffffff;
    --text-color: #333;
    --text-secondary: #666;
    --border-color: #e0e0e0;
    --sidebar-bg: #f8f9fa;
    --sidebar-text: #333;
    --message-hover: rgba(98, 98, 98, 0.3);
    --message-bg: #f5f7fa;
    --message-sent-bg: #e9af31;
    --message-sent-text: #203650;
    --auth-bg: #f0f0f0;
    --auth-box-bg: rgba(255, 255, 255, 0.95);
    --logo-opacity: 0.05;
    --logo-filter: none;
    --input-bg: #ffffff;
    --input-text: #333;
    --btn-color: #203650;
    --input-container-bg: #ffffff;
}

/* Font Awesome Icons */
.fas, .fa-solid {
    display: inline-block;
    font-style: normal;
    font-variant: normal;
    text-rendering: auto;
    line-height: 1;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--auth-bg);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* ==================== AUTH STYLES ==================== */

/* Animated Background */
.ub-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: -1;
    background: var(--auth-bg);
}

.ub-background-inner {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: var(--logo-opacity);
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
}

.ub-logo-row {
    display: flex;
    gap: 6rem;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    white-space: nowrap;
    flex-shrink: 0;
}

.ub-logo-row:nth-child(odd) {
    animation: slideRight 40s linear infinite;
}

.ub-logo-row:nth-child(even) {
    animation: slideLeft 40s linear infinite;
}

@keyframes slideRight {
    0% {
        transform: translateX(0%);
    }
    100% {
        transform: translateX(-50%);
    }
}

@keyframes slideLeft {
    0% {
        transform: translateX(-50%);
    }
    100% {
        transform: translateX(0%);
    }
}

.ub-logo {
    width: 2.5rem;
    height: auto;
    opacity: 1;
    flex-shrink: 0;
    filter: var(--logo-filter);
    padding: 0;
}

.auth-box {
    background: var(--auth-box-bg);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(10px);
}

.auth-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.auth-header h1 {
    text-align: center;
    flex: 1;
    color: var(--primary-color);
    font-size: 2rem;
    margin: 0;
}

.auth-box h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    font-size: 2rem;
}

.auth-subtitle {
    text-align: center;
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s;
    background: var(--input-bg);
    color: var(--input-text);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn {
    color: var(--btn-color);
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
}

.btn-primary {
    width: 100%;
    background: var(--primary-color);
    color: var(--secondary-color);
    font-weight: 600;
}

.btn-primary:hover {
    background: #f4c563;
}

.error-message {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #fee;
    color: var(--error-color);
    border-radius: 5px;
    display: none;
}

.error-message.show {
    display: block;
}

/* ==================== CHAT STYLES ==================== */

.chat-layout {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.5rem;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.username {
    font-weight: 600;
    color: var(--primary-color);
}

.user-role-badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
    background: var(--text-secondary);
    border-radius: 3px;
    display: inline-block;
    color: #f5f7fa
}

.user-agency-badge {
    font-size: 0.7rem;
    opacity: 0.7;
}

.btn-icon {
    color: var(--btn-color);
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
}

.sidebar-section {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-section h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    opacity: 0.7;
    margin-bottom: 0.75rem;
}

.chat-types-list, .users-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chat-section-separator {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0.6;
    padding: 1rem 0.75rem 0.5rem 0.75rem;
    margin-top: 0.5rem;
    letter-spacing: 0.5px;
}

.chat-type-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
    position: relative;
}

e

.chat-type-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chat-type-item.active {
    background: var(--primary-color);
}

.chat-type-item.active{
    color: var(--secondary-color);
    font-weight: 600;
}

.chat-type-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.chat-type-name {
    font-weight: 500;
    font-size: 0.9rem;
    flex: 1;
}

.chat-typing-badge {
    font-size: 1rem;
    margin-left: auto;
    animation: pulse 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

.chat-unread-badge {
    background: var(--error-color);
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.users-agency-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: rgba(233, 175, 49, 0.1);
    border-left: 3px solid var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.users-agency-header:first-child {
    margin-top: 0;
}

.users-role-header {
    font-size: 0.75rem;
    text-transform: uppercase;
    opacity: 0.6;
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
    padding-left: 1rem;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 5px;
    font-size: 0.85rem;
}

.user-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
    flex-shrink: 0;
}

.user-agency-badge {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-left: auto;
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background-color);
    position: relative;
}

.chat-header {
    padding: 1rem 1.5rem;
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.menu-toggle-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    color: var(--text-color);
    margin-right: 1rem;
}

.chat-header h2 {
    font-size: 1.5rem;
    color: var(--text-color);
    flex: 1;
}

.status-indicator {
    font-size: 0.9rem;
}

.messages-container {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--background-color);
}

.message {
    display: flex;
    gap: 0.75rem;
    max-width: 70%;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.own-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.avatar-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.message-type-indicator {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    background: rgba(74, 144, 226, 0.2);
    border-radius: 10px;
    margin-bottom: 0.25rem;
    display: inline-block;
}

.message-header {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    flex-wrap: wrap;
}

.message-username {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-color);
}

.message-role {
    font-size: 0.75rem;
    opacity: 0.7;
    color: var(--text-secondary);
}

.message-agency {
    font-size: 0.75rem;
    padding: 0.1rem 0.3rem;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    color: var(--text-color);
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: auto;
}

.message-delete-btn,
.message-edit-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    font-size: 0.85rem;
    margin-left: 0.5rem;
}

.message:hover .message-delete-btn,
.message:hover .message-edit-btn {
    opacity: 1;
}

.message-delete-btn:hover {
    color: #e74c3c;
}

.message-edit-btn:hover {
    color: var(--primary-color);
}

.message-edited-tag {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 0.25rem;
    opacity: 0.8;
}

.message-edited-tag i {
    font-size: 0.65rem;
    margin-right: 0.2rem;
}

/* Date Separator */
.date-separator {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 2rem 0 1rem;
    position: relative;
}

.date-separator::before,
.date-separator::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
    opacity: 0.3;
}

.date-separator span {
    padding: 0 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 0.35rem 1rem;
    border: 1px solid var(--border-color);
    opacity: 0.8;
}

/* Broadcast Message Styles */
.message.broadcast-message {
    justify-content: center !important;
    align-items: center;
    margin: 1.5rem auto;
    flex-direction: column;
}

.message.broadcast-message .message-avatar {
    margin: 0 auto 0.75rem;
    background: linear-gradient(135deg, var(--primary-color), #f4c563);
    box-shadow: 0 2px 8px rgba(233, 175, 49, 0.3);
}

.message.broadcast-message .message-content {
    max-width: 70%;
    width: auto;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.message.broadcast-message .message-bubble {
    background: linear-gradient(135deg, rgba(233, 175, 49, 0.15), rgba(233, 175, 49, 0.08));
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(233, 175, 49, 0.2);
    position: relative;
    width: 100%;
}

.message.broadcast-message .message-bubble::before {
    content: '📢';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    background: var(--background-color);
    padding: 0 10px;
    border-radius: 50%;
    z-index: 1;
}

.message.broadcast-message .message-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(233, 175, 49, 0.3);
    margin-bottom: 0.5rem;
    width: 100%;
}

.message.broadcast-message .message-username {
    font-weight: 700;
    color: var(--primary-color);
}

.message.broadcast-message .message-role {
    background: var(--primary-color);
    color: var(--secondary-color);
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
}

.message.broadcast-message .message-time {
    margin-left: auto;
}

.message.broadcast-message .message-text {
    text-align: center;
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-color);
    padding: 0.5rem 0;
    width: 100%;
}

/* Mobile adjustments for broadcast */
@media (max-width: 768px) {
    .message.broadcast-message .message-content {
        max-width: 90%;
    }
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 15px;
    background: var(--message-bg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
    color: var(--text-color);
}

.message .message-bubble:hover {
    background: var(--message-hover);
}

.message.own-message .message-bubble:hover {
    background: var(--message-sent-bg);
    filter: brightness(1.1);
}

.message.own-message .message-bubble {
    background: var(--message-sent-bg);
    color: var(--message-sent-text);
}

.typing-indicator {
    padding: 0.5rem 1.5rem;
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

.message-input-container {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    position: relative;
}

/* Drag and Drop Overlay */
.drag-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(233, 175, 49, 0.1);
    border: 3px dashed var(--primary-color);
    border-radius: 12px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: none;
    backdrop-filter: blur(2px);
}

.drag-overlay.active {
    display: flex;
}

.drag-overlay-content {
    text-align: center;
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 600;
    padding: 2rem;
    background: var(--background-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.drag-overlay-content i {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

#message-form {
    display: flex;
    gap: 0.75rem;
}

#message-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 25px;
    font-size: 1rem;
    transition: border-color 0.3s;
    background: var(--input-bg);
    color: var(--input-text);
    resize: none;
    overflow-y: hidden;
    min-height: 44px;
    max-height: 200px;
    font-family: inherit;
    line-height: 1.5;
}

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

.btn-send {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    background: transparent;
    transition: background 0.3s;
}

.btn-send:hover {
    background: rgba(74, 144, 226, 0.1);
}



/* System Messages */
.system-message {
    text-align: center;
    padding: 0.5rem;
    color: #666;
    font-size: 0.9rem;
    font-style: italic;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-color);
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px;
        transition: left 0.3s ease;
        z-index: 1000;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
    }

    .sidebar.open {
        left: 0;
    }

    .menu-toggle-btn {
        display: block;
    }

    .chat-header h2 {
        font-size: 1.1rem;
    }

    .message {
        max-width: 85%;
    }

    .message-input-container {
        padding: 0.75rem;
    }

    .chat-header {
        padding: 0.75rem 1rem;
    }

    .messages-container {
        padding: 1rem;
    }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* ==================== WHATSAPP-LIKE IMPROVEMENTS ==================== */

.message-input-container form {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 12px;
    border-radius: 25px;
}

#message-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    padding: 8px 12px;
}

#attach-btn {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

#attach-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.btn-send {
    border: none;
    padding: 10px 16px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}


/* File Preview */
.file-preview {
    background: var(--message-sent-bg);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.file-preview-icon {
    color: #ffffff;
    font-size: 40px;
}

.file-preview-info {
    flex: 1;
}

.file-preview-name {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.file-preview-size {
    font-size: 12px;
    color: #000;
}

.file-preview-remove {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Message Attachments */
.message-attachment {
    margin-top: 8px;
    max-width: 300px;
}

.message-attachment img {
    max-width: 100%;
    border-radius: 8px;
    cursor: pointer;
}

.image-download-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    opacity: 0;
    z-index: 10;
}

.message-attachment > div:hover .image-download-btn {
    opacity: 1;
}

.image-download-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.image-download-btn:active {
    transform: scale(0.95);
}

.message-attachment-file {
    background: var(--message-bg);
    padding: 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.message-attachment-file:hover {
    background: var(--message-hover);
}

.message-attachment-icon {
    font-size: 32px;
}

.message-attachment-info {
    flex: 1;
}

.message-attachment-name {
    font-weight: 600;
    font-size: 14px;
}

.message-attachment-size {
    font-size: 12px;
    opacity: 0.8;
}

/* Excel Table Styles */
.excel-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    margin: 8px 0;
    font-size: 13px;
    background: var(--input-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
}

.excel-table th,
.excel-table td {
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    text-align: left;
    white-space: nowrap;
}

.excel-table th {
    background: linear-gradient(135deg, var(--primary-color), #f4c563);
    color: var(--secondary-color);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.8px;
    border-bottom: 2px solid var(--secondary-color);
}

.excel-table tbody tr {
    background: var(--input-bg);
    transition: background 0.2s ease;
}

.excel-table tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.03);
}

.excel-table tbody tr:hover {
    background: rgba(233, 175, 49, 0.15);
}

.excel-table td {
    color: var(--text-color);
    font-weight: 500;
}

.message-text.contains-table {
    max-width: 100%;
    overflow-x: auto;
    padding: 0;
}

.message-bubble .contains-table {
    background: transparent;
}

/* Dark theme adjustments for tables */
body.dark-theme .excel-table {
    background: #1e1e1e;
    border-color: #3a3a3a;
}

body.dark-theme .excel-table th,
body.dark-theme .excel-table td {
    border-color: #3a3a3a;
}

body.dark-theme .excel-table tbody tr {
    background: #1e1e1e;
}

body.dark-theme .excel-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-theme .excel-table tbody tr:hover {
    background: rgba(233, 175, 49, 0.2);
}

/* Improved message bubbles */
.message-bubble {
    padding: 10px 14px;
    border-radius: 8px;
    max-width: 600px;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    background: var(--message-bg);
}



.own-message .message-bubble {
    background: var(--message-sent-bg);
    color: var(--message-sent-text);
}

.message:not(.own-message) .message-bubble {
    background: var(--message-bg);
}

/* Message time styling */
.message-time {
    font-size: 11px;
    color: var(--text-color);
    margin-left: auto;
}

.own-message .message-time {
    color: var(--text-color);
}

/* Typing indicator improvements */
.typing-indicator {
    padding: 12px 20px;
    background: white;
    border-radius: 8px;
    margin: 8px;
    font-size: 14px;
    color: #666;
    font-style: italic;
}

/* Input container improvements */
.message-input-container {
    padding: 12px;
    background: var(--input-container-bg);
}

/* Reply Preview */
.reply-preview {
    background: var(--message-bg);
    border-left: 4px solid var(--primary-color);
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.reply-preview-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.reply-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reply-preview-label {
    font-size: 13px;
    color: var(--primary-color);
}

.cancel-reply-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
}

.cancel-reply-btn:hover {
    color: #e74c3c;
}

.reply-preview-text {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Message Reply Preview (inside message bubble) */
.message-reply-preview {
    background: rgba(0, 0, 0, 0.05);
    border-left: 3px solid var(--primary-color);
    padding: 6px 10px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.own-message .message-reply-preview {
    background: rgba(32, 54, 80, 0.2);
    border-left-color: var(--secondary-color);
}

.message-reply-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 2px;
}

.own-message .message-reply-header {
    color: var(--secondary-color);
}

.message-reply-text {
    font-size: 12px;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.own-message .message-reply-text {
    color: rgba(0, 0, 0, 0.6);
}


/* ==================== AGENCY SELECTOR ==================== */
.agency-selector {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 1rem;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.agency-selector.hidden {
    display: none;
}

.agency-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.agency-selector-header i {
    color: var(--primary-color);
    margin-right: 0.5rem;
}

.close-selector-btn {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.2rem;
    transition: color 0.3s;
}

.close-selector-btn:hover {
    color: #e74c3c;
}

.agency-checkboxes {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
}

.agency-checkbox-label {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.agency-checkbox-label:hover {
    background: rgba(233, 175, 49, 0.1);
}

.agency-checkbox-label input[type="checkbox"] {
    margin-right: 0.75rem;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.agency-checkbox-label span {
    flex: 1;
    color: var(--text-primary);
}

.agency-selector-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.btn-selector {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.btn-selector:hover {
    background: var(--primary-color);
    color: var(--secondary-color);
    border-color: var(--primary-color);
}

#select-agencies-btn {
    margin-left: 0.5rem;
}

/* Dark theme adjustments */
.dark-theme .agency-selector {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.dark-theme .agency-checkbox-label:hover {
    background: rgba(233, 175, 49, 0.15);
}

/* Selective message styling (similar to broadcast) */
.selective-message {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.05) 0%, rgba(41, 128, 185, 0.05) 100%);
    border-left: 3px solid #3498db;
    padding-left: 0.75rem;
    margin: 0.75rem 0;
}

.selective-message .message-bubble {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.15) 0%, rgba(41, 128, 185, 0.1) 100%);
    border: 1px solid rgba(52, 152, 219, 0.3);
}

.dark-theme .selective-message {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.08) 0%, rgba(41, 128, 185, 0.08) 100%);
}

.dark-theme .selective-message .message-bubble {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.2) 0%, rgba(41, 128, 185, 0.15) 100%);
    border: 1px solid rgba(52, 152, 219, 0.4);
}

/* Message style selector */
.message-style-selector {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.message-style-selector.hidden {
    display: none;
}

.message-style-option {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.3s;
    border: 2px solid transparent;
    flex: 1;
    justify-content: center;
}

.message-style-option:hover {
    background: rgba(233, 175, 49, 0.1);
}

.message-style-option input[type="radio"] {
    display: none;
}

.message-style-option input[type="radio"]:checked + span {
    font-weight: 600;
    color: var(--primary-color);
}

.message-style-option input[type="radio"]:checked ~ span {
    font-weight: 600;
}

.message-style-option:has(input[type="radio"]:checked) {
    background: rgba(233, 175, 49, 0.15);
    border-color: var(--primary-color);
}

.message-style-option span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    transition: all 0.3s;
}

.message-style-option i {
    font-size: 1.1rem;
}

.dark-theme .message-style-option:hover {
    background: rgba(233, 175, 49, 0.2);
}

.dark-theme .message-style-option:has(input[type="radio"]:checked) {
    background: rgba(233, 175, 49, 0.25);
}
