/*
 * Mail.Ru Agent — MRIM Web Client
 * Telegram-inspired UX with Mail.Ru Agent classic brand identity
 * Flat, compact, borderless style (0px border-radius)
 */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border-radius: 0 !important; /* Strictly remove all rounded corners per user request */
}

body {
    font-family: Tahoma, Verdana, Arial, sans-serif;
    font-size: 12px;
    background-color: #dce1e6;
    color: #1c252e;
    margin: 0;
    padding: 8px;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Main Container Window */
.agent-window {
    max-width: 1080px;
    width: 100%;
    height: 100%;
    max-height: 860px;
    margin: 0 auto;
    background-color: #ffffff;
    border: 1px solid #3b5998;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Top Title Bar */
.title-bar {
    background-color: #3b5998;
    color: #ffffff;
    padding: 6px 12px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #294273;
    flex-shrink: 0;
}

.title-text {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ws-status-square {
    display: inline-block;
    width: 9px;
    height: 9px;
    border: 1px solid #ffffff;
    background-color: #ffaa00;
    box-shadow: 0 0 2px rgba(0,0,0,0.3);
    flex-shrink: 0;
}

/* Panels */
.panel {
    border: none;
    background-color: transparent;
    margin: 0;
    padding: 0;
}

.panel-header {
    background-color: #e8ecef;
    padding: 6px 10px;
    border-bottom: 1px solid #d0d8e0;
    margin: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Login Header Bar (Compact & Expandable inside left sidebar) */
.login-panel {
    background-color: #f0f3f6;
    border-bottom: 1px solid #d0d8e0;
    padding: 8px 10px;
    flex-shrink: 0;
    transition: background-color 0.2s ease;
}

.login-header-bar {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.login-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: bold;
    color: #2b3a4a;
    min-width: 0;
    flex: 1;
}

.user-avatar-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #dce4eb;
    border: 1px solid #8a9aa8;
    flex-shrink: 0;
    overflow: visible;
}

.user-avatar-img-wrap {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.user-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.user-avatar-img.hidden,
.user-avatar-svg.hidden {
    display: none !important;
}

.user-avatar-svg {
    width: 100%;
    height: 100%;
}

.user-status-indicator {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 7px;
    height: 7px;
    border: 1px solid #ffffff;
}

.user-status-indicator.status-online { background-color: #00cc00; }
.user-status-indicator.status-away { background-color: #ffaa00; }
.user-status-indicator.status-offline { background-color: #aaaaaa; }

.user-email-preview {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
    color: #2b3a4a;
    font-size: 11px;
}

.user-email-preview.authenticated {
    color: #1b5e20;
    font-weight: 500;
}

.user-email-preview.error {
    color: #cc0000;
    font-weight: bold;
}

.user-email-accent {
    color: #006600;
    font-weight: bold;
}

.login-header-actions {
    display: flex;
    align-items: center;
    width: 100%;
}

.panel-buttons-group {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.panel-buttons-group .btn {
    flex: 1;
    text-align: center;
    padding: 3px 4px;
    font-size: 11px;
}

/* Common Buttons */
.btn {
    padding: 3px 8px;
    background-color: #d0d8e0;
    border: 1px solid #7a8a9a;
    cursor: pointer;
    font-family: Tahoma, Verdana, sans-serif;
    font-size: 11px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.btn:hover {
    background-color: #c0c8d0;
}

.btn:disabled {
    background-color: #e0e0e0;
    color: #888888;
    border-color: #cccccc;
    cursor: default;
}

.btn-small {
    padding: 2px 6px;
    font-size: 11px;
}

.btn-login {
    font-weight: bold;
    background-color: #3b5998;
    color: #ffffff;
    border-color: #294273;
}

.btn-login:hover {
    background-color: #2e4678;
}

.btn-toggle {
    padding: 2px 6px;
    background-color: #d0d8e0;
    border: 1px solid #7a8a9a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
}

.btn-toggle:hover {
    background-color: #bcd0e0;
}

.toggle-chevron {
    display: inline-block;
    font-size: 9px;
    transition: transform 0.25s ease;
    color: #334455;
}

/* Expandable Login Content */
.login-expandable-content {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease, margin-top 0.2s ease;
}

.login-panel.expanded .login-expandable-content {
    max-height: 280px;
    opacity: 1;
    margin-top: 6px;
}

.login-panel.expanded .toggle-chevron {
    transform: rotate(180deg);
}

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    background-color: #ffffff;
    border: 1px solid #c0c8d0;
    margin-top: 4px;
}

.form-field {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    width: 100%;
}

.form-field label {
    font-size: 10px;
    font-weight: bold;
    color: #334455;
    white-space: nowrap;
}

.form-field input[type="text"],
.form-field input[type="password"],
.form-field select {
    flex: 1;
    width: 100%;
    padding: 3px 6px;
    border: 1px solid #7a8a9a;
    background-color: #ffffff;
    font-family: Tahoma, Verdana, sans-serif;
    font-size: 11px;
    outline: none;
}

.form-field input[type="text"]:focus,
.form-field input[type="password"]:focus,
.form-field select:focus {
    border-color: #3b5998;
}

.auth-status-bar {
    margin-top: 4px;
    padding: 3px 6px;
    background-color: #fcfcfc;
    border: 1px solid #c0c8d0;
    font-size: 11px;
}

/* Workspace Layout */
.workspace {
    display: flex;
    flex: 1;
    min-height: 0;
    background-color: #ffffff;
    width: 100%;
    overflow: hidden;
}

/* Left Sidebar: Contacts Panel */
.contacts-panel {
    width: 280px;
    min-width: 230px;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #d0d8e0;
    background-color: #f8fafc;
    margin: 0;
    padding: 0;
}

.contacts-panel .panel-header {
    background-color: #e8ecef;
    padding: 6px 10px;
    border-bottom: 1px solid #d0d8e0;
    margin: 0;
    font-weight: bold;
    color: #2b3a4a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    font-size: 12px;
}

/* Contacts List (Scrollable Middle Area) */
.contacts-list {
    flex: 1;
    overflow-y: auto;
    border: none;
    background-color: #ffffff;
    padding: 0;
    margin: 0;
}

.contact-item {
    padding: 6px 10px;
    border-bottom: 1px solid #f0f3f6;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.15s ease;
}

.contact-item:hover {
    background-color: #f0f5fa;
}

.contact-item.active {
    background-color: #e1ebf5;
    border-left: 3px solid #3b5998;
    font-weight: bold;
}

.contact-left {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.contact-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 4px;
}

.contact-avatar-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    background-color: #dce4eb;
    object-fit: cover;
    border: 1px solid #c0c8d0;
    flex-shrink: 0;
}

.active-chat-avatar {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border: 1px solid #7a8a9a;
}

.msg-avatar {
    width: 18px;
    height: 18px;
    min-width: 18px;
    object-fit: cover;
    border: 1px solid #8a9aa8;
    vertical-align: middle;
    margin-right: 4px;
    display: inline-block;
}

.contact-status-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 7px;
    height: 7px;
    display: inline-block;
    border: 1px solid #ffffff;
    box-shadow: 0 0 2px rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.status-online { background-color: #00cc00; }
.status-away { background-color: #ffaa00; }
.status-offline { background-color: #aaaaaa; }

.contact-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    color: #2b3a4a;
}

.unread-badge {
    background-color: #3b5998;
    color: #ffffff;
    font-size: 10px;
    padding: 1px 5px;
    font-weight: bold;
}

.empty-list {
    color: #778899;
    text-align: center;
    padding: 24px 12px;
    font-size: 11px;
}

/* Quick Add Contact at Bottom of Left Sidebar */
.direct-msg-box {
    padding: 8px 10px 14px 10px;
    background-color: #f0f4f8;
    border-top: 1px solid #d0d8e0;
    margin: 0;
    flex-shrink: 0;
}

.direct-msg-box label {
    font-size: 10px;
    font-weight: bold;
    color: #4a5a6a;
    margin-bottom: 6px;
    display: block;
}

.direct-input-row {
    display: flex;
    gap: 4px;
    align-items: center;
}

.direct-input-row input {
    flex: 1;
    min-width: 0;
    padding: 4px 6px;
    border: 1px solid #7a8a9a;
    font-size: 11px;
    background-color: #ffffff;
    outline: none;
}

.direct-input-row input:focus {
    border-color: #3b5998;
}

.direct-input-row .btn {
    padding: 3px 8px;
    height: 23px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.btn-chat {
    background-color: #3b5998;
    color: #ffffff;
    border: 1px solid #294273;
    font-weight: bold;
}

.btn-chat:hover {
    background-color: #2e4678;
}

/* Right Column: Chat Panel */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #f4f6f9;
    margin: 0;
    padding: 0;
    border: none;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.chat-panel .panel-header.chat-header-row {
    background-color: #ffffff;
    padding: 6px 12px;
    border-bottom: 1px solid #d0d8e0;
    margin: 0;
    min-height: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-title-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    min-width: 0;
    font-size: 12px;
}

.chat-history {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    border: none;
    background-color: #f2f5f8;
    padding: 12px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-welcome {
    color: #445566;
    line-height: 1.5;
    background-color: #ffffff;
    border: 1px solid #d8e0e8;
    padding: 12px;
    max-width: 480px;
    margin: 16px auto;
    font-size: 12px;
}

/* Messages */
.message-item {
    max-width: 82%;
    padding: 6px 10px;
    background-color: #ffffff;
    border: 1px solid #d8e0e8;
    margin-bottom: 2px;
    align-self: flex-start;
    word-break: break-word;
}

.message-item:has(.msg-author.me),
.message-item.msg-outgoing {
    align-self: flex-end;
    background-color: #e3effd;
    border-color: #b8d4f8;
}

.msg-header {
    font-size: 10px;
    color: #667788;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.msg-author {
    font-weight: bold;
    color: #003366;
}

.msg-author.me {
    color: #0055aa;
}

.msg-text {
    line-height: 1.4;
    color: #1c252e;
    font-size: 12px;
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* Bottom Message Send Form */
.send-box {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px;
    background-color: #ffffff;
    border-top: 1px solid #d0d8e0;
    flex-shrink: 0;
}

/* Smile Picker Popup */
.smile-picker-popup {
    position: absolute;
    bottom: 100%;
    left: 12px;
    margin-bottom: 6px;
    width: 310px;
    max-width: calc(100% - 24px);
    background-color: #ffffff;
    border: 1px solid #3b5998;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    border-radius: 0 !important;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.smile-picker-popup.hidden {
    display: none !important;
}

.smile-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background-color: #e8ecef;
    border-bottom: 1px solid #d0d8e0;
    font-weight: bold;
    font-size: 11px;
    color: #2b3a4a;
    user-select: none;
}

.smile-picker-close {
    background: transparent;
    border: none;
    font-size: 16px;
    line-height: 1;
    color: #7a8a9a;
    cursor: pointer;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.smile-picker-close:hover {
    color: #cc0000;
}

.smile-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 34px);
    gap: 5px;
    padding: 8px;
    max-height: 200px;
    overflow-y: auto;
    background-color: #f8fafc;
    justify-content: start;
}

.smile-picker-grid.hidden {
    display: none !important;
}

.smile-picker-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background-color: #ffffff;
    border: 1px solid #d0d8e0;
    border-radius: 0 !important;
    cursor: pointer;
    padding: 2px;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.smile-picker-item:hover {
    background-color: #e1ebf5;
    border-color: #3b5998;
    box-shadow: 0 1px 4px rgba(59, 89, 152, 0.25);
    z-index: 2;
}

.smile-picker-item img {
    max-width: 26px;
    max-height: 26px;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}

/* Kaomoji Picker Grid */
.kaomoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 5px;
    padding: 8px;
    max-height: 200px;
    overflow-y: auto;
    background-color: #f8fafc;
}

.kaomoji-picker-grid.hidden {
    display: none !important;
}

.kaomoji-picker-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px 6px;
    background-color: #ffffff;
    border: 1px solid #d0d8e0;
    border-radius: 0 !important;
    cursor: pointer;
    font-size: 11px;
    font-family: inherit;
    color: #1c252e;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.kaomoji-picker-item:hover {
    background-color: #e1ebf5;
    border-color: #3b5998;
    color: #003366;
}

/* Smile Picker Footer & Tabs */
.smile-picker-footer {
    background-color: #e8ecef;
    border-top: 1px solid #d0d8e0;
    padding: 4px;
}

.smile-picker-tabs {
    display: flex;
    gap: 4px;
}

.smile-picker-tab {
    flex: 1;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: bold;
    color: #4a5a6a;
    background-color: #d0d8e0;
    border: 1px solid #7a8a9a;
    border-radius: 0 !important;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.smile-picker-tab:hover {
    background-color: #c0c8d0;
    color: #1c252e;
}

.smile-picker-tab.active {
    background-color: #3b5998;
    color: #ffffff;
    border-color: #294273;
}

.send-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    width: 100%;
}

.send-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
}

#btn-sound-toggle {
    margin-left: auto;
}

.btn-toolbar-stub {
    font-size: 11px;
    padding: 2px 8px;
    background-color: #f0f3f6;
    border: 1px solid #c0c8d0;
    color: #4a5a6a;
    cursor: pointer;
    border-radius: 2px;
}

.btn-toolbar-stub:hover {
    background-color: #e1ebf5;
    border-color: #7a8a9a;
    color: #1c252e;
}

.send-box textarea,
.send-box .message-input {
    flex: 1;
    min-height: 32px;
    height: 32px;
    max-height: 96px;
    padding: 6px 10px;
    border: 1px solid #b0bec5;
    font-family: inherit;
    font-size: 12px;
    line-height: 18px;
    resize: none;
    outline: none;
    background-color: #f8fafc;
    box-sizing: border-box;
    transition: border-color 0.15s, background-color 0.15s;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.send-box textarea:focus,
.send-box .message-input:focus {
    border-color: #3b5998;
    background-color: #ffffff;
}

.send-box .message-input[contenteditable="false"] {
    background-color: #f0f0f0;
    color: #888888;
    cursor: not-allowed;
}

.send-box .message-input:empty::before {
    content: attr(placeholder);
    color: #8f9bb3;
    pointer-events: none;
    display: block;
}

.mrim-smile-input {
    width: 18px;
    height: 18px;
    vertical-align: -3px;
    display: inline-block;
    margin: 0 1px;
    user-select: none;
    pointer-events: none;
}

.send-buttons {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.btn-send {
    height: 32px;
    padding: 0 16px;
    font-weight: bold;
    background-color: #3b5998;
    color: #ffffff;
    border: 1px solid #294273;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    white-space: nowrap;
    transition: background-color 0.15s;
}

.btn-send:hover {
    background-color: #2e4678;
}

.btn-send:disabled {
    background-color: #c0c8d0;
    color: #ffffff;
    border-color: #a0a8b0;
    cursor: not-allowed;
}

/* Bottom Collapsible Logs Panel */
.logs-panel {
    background-color: #ffffff;
    border-top: 1px solid #d0d8e0;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
}

.logs-panel .panel-header {
    background-color: #e8ecef;
    padding: 4px 10px;
    border-bottom: 1px solid #d0d8e0;
    margin: 0;
    font-size: 11px;
    cursor: pointer;
    user-select: none;
}

.logs-header-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.logs-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.logs-expandable-content {
    max-height: 120px;
    opacity: 1;
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}

.logs-panel.collapsed .logs-expandable-content {
    max-height: 0;
    opacity: 0;
}

.logs-panel.collapsed #logs-toggle-chevron {
    transform: rotate(180deg);
}

.logs-panel.collapsed .panel-header {
    border-bottom: none;
}

.logs-console {
    height: 110px;
    overflow-y: auto;
    background-color: #0d1117;
    color: #c9d1d9;
    font-family: monospace;
    font-size: 11px;
    padding: 4px 8px;
    line-height: 1.35;
    border: none;
}

.log-line {
    margin-bottom: 2px;
}

.log-info { color: #58a6ff; }
.log-error { color: #f85149; font-weight: bold; }
.log-warning { color: #d29922; }
.log-debug { color: #8b949e; }

.btn-auth {
    background-color: #f0f3f6;
    color: #4a5a6a;
    border: 1px solid #c0c8d0;
    font-weight: normal;
}

.btn-auth:hover {
    background-color: #e1ebf5;
    border-color: #7a8a9a;
    color: #1c252e;
}

.msg-auth-card {
    background-color: #e6f4ea;
    border: 1px solid #34a853;
    padding: 6px 10px;
    margin-top: 4px;
    margin-bottom: 4px;
}

.auth-card-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 3px;
}

.auth-card-title {
    color: #137333;
    font-size: 11px;
}

.btn-approve-card {
    padding: 3px 8px;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
}

.typing-status {
    font-size: 11px;
    color: #0078d4;
    font-style: italic;
    margin-left: 6px;
}

.hidden {
    display: none !important;
}

/* Modal Overlay & Base Window Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 16px;
    box-sizing: border-box;
}

.modal-window {
    background-color: #ffffff;
    border: 1px solid #3b5998;
    border-radius: 6px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    width: 100%;
    max-width: 520px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10001;
    font-family: inherit;
}

.modal-header {
    background: linear-gradient(to bottom, #3b5998 0%, #2d4373 100%);
    color: #ffffff;
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 13px;
    border-bottom: 1px solid #1f3054;
    flex-shrink: 0;
}

.modal-title {
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0.2px;
}

.modal-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease;
}

.modal-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

.modal-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    font-size: 11px;
    line-height: 1.5;
    color: #1e293b;
}

.modal-footer {
    padding: 10px 16px;
    background-color: #f1f5f9;
    border-top: 1px solid #cbd5e1;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.settings-section {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section-title {
    font-weight: bold;
    color: #0f172a;
    font-size: 12px;
    margin-bottom: 10px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e2e8f0;
}

.settings-divider {
    display: none;
}

.settings-help-text {
    font-size: 10px;
    color: #64748b;
    margin-top: 6px;
    line-height: 1.4;
}

.settings-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 11px;
    color: #334155;
    user-select: none;
}

.settings-checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 14px;
    height: 14px;
    accent-color: #3b5998;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-field label {
    font-weight: 600;
    color: #334155;
    font-size: 11px;
}

.form-field select,
.form-field input[type="file"],
.form-field input[type="text"] {
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 11px;
    font-family: inherit;
    background-color: #ffffff;
    color: #1e293b;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-field select:focus,
.form-field input[type="text"]:focus {
    border-color: #3b5998;
    box-shadow: 0 0 0 2px rgba(59, 89, 152, 0.15);
}

.pwa-guide-section {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 10px 12px;
    margin-top: 8px;
}

.pwa-platform-header {
    color: #1e3a8a;
    font-weight: bold;
    font-size: 11px;
    margin-bottom: 6px;
}

.pwa-steps {
    margin: 0;
    padding-left: 18px;
    color: #334155;
}

.pwa-steps li {
    margin-bottom: 4px;
    line-height: 1.4;
}

.pwa-steps li:last-child {
    margin-bottom: 0;
}

.pwa-status-box {
    margin-top: 10px;
    padding: 8px 12px;
    background-color: #f1f5f9;
    border-left: 3px solid #3b82f6;
    border-radius: 2px;
    font-size: 10px;
    color: #475569;
}

.mrim-smile {
    max-width: 22px;
    max-height: 22px;
    width: auto;
    height: auto;
    display: inline-block;
    vertical-align: middle;
    margin: 0 2px;
}

.mobile-workspace-tabs {
    display: none;
}

.btn-back-contacts {
    display: none;
}

/* Mobile & Tablet Styles */
@media (max-width: 768px) {
    html, body {
        padding: 0;
        margin: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .agent-window {
        border: none;
        box-shadow: none;
        max-width: 100%;
        width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        height: 100vh;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .title-bar {
        padding: 8px 12px;
        font-size: 13px;
        flex-shrink: 0;
    }

    .mobile-workspace-tabs {
        display: none !important;
    }

    .mobile-tab-btn {
        flex: 1;
        padding: 12px 8px;
        border: none;
        border-top: 3px solid transparent;
        border-bottom: none;
        background: transparent;
        font-family: inherit;
        font-size: 13px;
        font-weight: bold;
        color: #556677;
        cursor: pointer;
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }

    .mobile-tab-btn.active {
        color: #3b5998;
        border-top-color: #3b5998;
        background-color: #ffffff;
    }

    .workspace {
        flex: 1;
        flex-direction: column;
        min-height: 0;
        height: 100%;
        overflow: hidden;
    }

    .workspace.mobile-view-contacts .contacts-panel {
        display: flex;
        flex-direction: column;
        width: 100%;
        max-width: 100%;
        height: 100%;
        min-height: 0;
        overflow: hidden;
        border-right: none;
    }

    .workspace.mobile-view-contacts .chat-panel {
        display: none !important;
    }

    .workspace.mobile-view-chat .contacts-panel {
        display: none !important;
    }

    .workspace.mobile-view-chat .chat-panel {
        display: flex;
        flex-direction: column;
        width: 100%;
        height: 100%;
        min-height: 0;
        overflow: hidden;
        position: relative;
    }

    /* Mobile Chat Header: Show avatar and contact name, plus back button */
    .chat-panel .panel-header.chat-header-row {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 42px;
        padding: 6px 10px;
        flex-shrink: 0;
    }

    .chat-title-group {
        width: auto;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        margin: 0 auto;
        max-width: calc(100% - 140px);
    }

    .chat-title-group .chat-title-prefix,
    .chat-title-group #current-chat-title,
    .chat-title-group .typing-status {
        display: none !important;
    }

    .chat-title-group .active-chat-avatar {
        width: 28px;
        height: 28px;
        min-width: 28px;
    }

    #chat-header-actions {
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 2;
    }

    .btn-back-contacts {
        display: inline-flex;
        align-items: center;
        position: absolute;
        left: 8px;
        top: 50%;
        transform: translateY(-50%);
        padding: 4px 8px;
        font-size: 11px;
        background-color: #bcd4e6;
        border: 1px solid #5a7b9c;
        cursor: pointer;
        font-weight: bold;
        z-index: 2;
    }

    .contacts-panel {
        width: 100%;
        max-width: 100%;
        flex: 1;
        min-height: 0;
    }

    .contacts-list {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .contact-item {
        padding: 10px 12px;
        min-height: 48px;
    }

    html body .contact-item.active {
        background: transparent !important;
        background-color: transparent !important;
        border-left: none !important;
        border-top: none !important;
        outline: none !important;
        box-shadow: none !important;
        font-weight: normal !important;
    }

    html body .contact-item.active .contact-name {
        color: inherit !important;
        text-shadow: none !important;
    }

    .contact-name {
        font-size: 13px;
    }

    .logs-panel {
        display: none !important;
    }

    .chat-history {
        flex: 1 1 0%;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
        padding: 10px;
    }

    .message-item {
        max-width: 90%;
    }

    .send-box {
        padding: 8px 10px;
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        z-index: 15;
        background-color: #ffffff;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
    }

    .send-box textarea,
    .send-box .message-input {
        min-height: 38px;
        font-size: 16px;
        padding: 8px 10px;
    }

    .btn-send {
        height: 38px;
        padding: 0 16px;
        font-size: 13px;
    }

    .send-toolbar {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
    }

    .btn-toolbar-stub {
        padding: 6px 12px;
        font-size: 12px;
    }

    .smile-picker-popup {
        left: 8px;
        right: 8px;
        width: auto;
        max-width: calc(100vw - 16px);
        bottom: 100%;
        max-height: 45vh;
    }

    /* Remove custom theme scrollbars on mobile devices */
    ::-webkit-scrollbar,
    *::-webkit-scrollbar,
    *::-webkit-scrollbar-track,
    *::-webkit-scrollbar-thumb,
    *::-webkit-scrollbar-button,
    *::-webkit-scrollbar-corner {
        width: 0 !important;
        height: 0 !important;
        display: none !important;
        background: transparent !important;
        border: none !important;
    }

    * {
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
    }
}

/* WakeUp Message Shake Animation */
@keyframes wakeup-shake {
    0% { transform: translate(0, 0) rotate(0deg); }
    15% { transform: translate(-5px, 4px) rotate(-1.5deg); }
    30% { transform: translate(5px, -4px) rotate(1.5deg); }
    45% { transform: translate(-4px, -3px) rotate(-1deg); }
    60% { transform: translate(4px, 3px) rotate(1deg); }
    75% { transform: translate(-2px, 2px) rotate(-0.5deg); }
    90% { transform: translate(2px, -1px) rotate(0.5deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

.shake-effect {
    animation: wakeup-shake 0.25s ease-in-out 3;
}

.message-item.wakeup-message {
    /* Retains standard message appearance */
}
