/* =========================================================
   RESET
========================================================= */

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

html,
body {
    width: 100%;
    min-height: 100%;
}

body {
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;

    background: #f4f7fb;
    color: #172033;
    line-height: 1.5;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

input,
textarea,
select {
    outline: none;
}

.hidden {
    display: none !important;
}


/* =========================================================
   LOGIN
========================================================= */

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;

    background:
        radial-gradient(
            circle at top left,
            #e7f3ff 0,
            transparent 35%
        ),
        #f4f7fb;
}

.login-card {
    width: 100%;
    max-width: 430px;

    background: #ffffff;
    border: 1px solid #e4eaf2;
    border-radius: 18px;

    padding: 40px;

    box-shadow:
        0 20px 60px rgba(25, 50, 80, 0.10);
}

.login-logo {
    width: 68px;
    height: 68px;

    display: flex;
    align-items: center;
    justify-content: center;

    margin: 0 auto 18px;

    border-radius: 18px;

    background: #eaf5ff;

    font-size: 32px;
}

.login-card h1 {
    text-align: center;
    font-size: 28px;
    font-weight: 750;
}

.login-subtitle {
    text-align: center;
    color: #738095;
    margin-top: 5px;
    margin-bottom: 30px;
}


/* =========================================================
   FORMS
========================================================= */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 18px;
}

.form-group label {
    color: #344054;
    font-size: 14px;
    font-weight: 650;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;

    border: 1px solid #d7dee9;
    border-radius: 10px;

    background: #ffffff;

    color: #172033;

    padding: 12px 14px;

    transition:
        border-color 0.2s,
        box-shadow 0.2s;
}

.form-group input {
    height: 46px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #2f80ed;

    box-shadow:
        0 0 0 3px rgba(47, 128, 237, 0.12);
}

.form-group input.input-invalid {
    border-color: #e5484d;

    box-shadow:
        0 0 0 3px rgba(229, 72, 77, 0.12);
}

.form-group input.input-valid {
    border-color: #2fb344;
}

.field-hint {
    font-size: 12.5px;
    color: #667085;
    line-height: 1.4;
}

.field-hint.field-error {
    color: #e5484d;
}

.password-field {
    position: relative;

    display: flex;
    align-items: center;
}

.password-field input {
    width: 100%;
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    right: 4px;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 36px;
    height: 36px;

    border: none;
    border-radius: 8px;
    background: transparent;

    font-size: 16px;
    line-height: 1;
    cursor: pointer;

    color: #d4a017;

    opacity: 0.75;

    transition:
        opacity 0.15s,
        background 0.15s;
}

.password-toggle:hover {
    opacity: 1;
    background: rgba(212, 160, 23, 0.12);
}

.password-toggle:focus-visible {
    outline: 2px solid #d4a017;
    outline-offset: 1px;
}

.password-toggle[aria-pressed="true"] {
    opacity: 1;
}


/* =========================================================
   BUTTONS
========================================================= */

.btn {
    border: 0;
    border-radius: 9px;

    min-height: 40px;

    padding: 9px 15px;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;

    font-size: 14px;
    font-weight: 700;

    transition:
        transform 0.15s,
        box-shadow 0.15s,
        background 0.15s;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-full {
    width: 100%;
    min-height: 48px;
}

.btn-primary {
    background: #2477d4;
    color: #ffffff;
}

.btn-primary:hover {
    background: #1d68bd;
    box-shadow:
        0 6px 16px rgba(36, 119, 212, 0.20);
}

.btn-secondary {
    background: #eef2f7;
    color: #344054;
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-danger {
    background: #dc3545;
    color: #ffffff;
}

.btn-danger:hover {
    background: #c82333;
    box-shadow:
        0 6px 16px rgba(220, 53, 69, 0.18);
}

.btn-success {
    background: #168a5b;
    color: #ffffff;
}

.btn-success:hover {
    background: #117349;
}


/* =========================================================
   APPLICATION LAYOUT
========================================================= */

.app {
    min-height: 100vh;
    display: flex;
}


/* =========================================================
   SIDEBAR
========================================================= */

.sidebar {
    width: 250px;
    min-width: 250px;

    min-height: 100vh;

    display: flex;
    flex-direction: column;

    background: #ffffff;

    border-right: 1px solid #e4e9f1;

    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    height: 78px;

    display: flex;
    align-items: center;

    gap: 12px;

    padding: 0 22px;

    border-bottom: 1px solid #edf0f5;
}

.brand-icon {
    width: 42px;
    height: 42px;

    border-radius: 12px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #eaf5ff;

    font-size: 22px;
}

.brand-title {
    font-size: 15px;
    font-weight: 800;
    color: #182230;
}

.brand-subtitle {
    margin-top: 1px;

    font-size: 11px;

    color: #8a96a8;
}


/* =========================================================
   SIDEBAR NAVIGATION
========================================================= */

.sidebar-nav {
    padding: 18px 12px;

    display: flex;
    flex-direction: column;

    gap: 5px;
}

.nav-link {
    width: 100%;

    border: 0;

    background: transparent;

    color: #667085;

    padding: 12px 13px;

    border-radius: 9px;

    display: flex;
    align-items: center;

    gap: 11px;

    text-align: left;

    font-size: 14px;
    font-weight: 600;

    transition:
        background 0.2s,
        color 0.2s;
}

.nav-link:hover {
    background: #f2f6fb;
    color: #2477d4;
}

.nav-link.active {
    background: #eaf4ff;
    color: #2477d4;
    font-weight: 750;
}

.nav-icon {
    width: 23px;
    text-align: center;
    font-size: 17px;
}


/* =========================================================
   SIDEBAR USER
========================================================= */

.sidebar-user {
    margin-top: auto;

    padding: 15px;

    display: flex;
    align-items: center;

    gap: 10px;

    border-top: 1px solid #edf0f5;
}

.avatar {
    width: 38px;
    height: 38px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: #2477d4;
    color: #ffffff;

    font-size: 13px;
    font-weight: 800;
}

.sidebar-user-info {
    min-width: 0;
    flex: 1;
}

.sidebar-user-name {
    overflow: hidden;

    white-space: nowrap;
    text-overflow: ellipsis;

    font-size: 13px;
    font-weight: 700;
}

.sidebar-user-email {
    overflow: hidden;

    white-space: nowrap;
    text-overflow: ellipsis;

    color: #8a96a8;

    font-size: 11px;
}

.logout-button {
    width: 34px;
    height: 34px;

    border: 0;
    border-radius: 8px;

    background: transparent;

    color: #7a8699;

    font-size: 20px;
}

.logout-button:hover {
    background: #fff0f1;
    color: #dc3545;
}


/* =========================================================
   MAIN
========================================================= */

.main-content {
    min-width: 0;
    flex: 1;

    padding-bottom: 40px;
}


/* =========================================================
   TOPBAR
========================================================= */

.topbar {
    height: 78px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 30px;

    background: #ffffff;

    border-bottom: 1px solid #e4e9f1;

    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-title {
    font-size: 22px;
    font-weight: 780;
    color: #182230;
}

.page-subtitle {
    margin-top: 2px;

    color: #7a8699;

    font-size: 12px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}


/* =========================================================
   CONNECTION STATUS
========================================================= */

.connection-status {
    min-height: 34px;

    display: inline-flex;
    align-items: center;
    gap: 7px;

    padding: 6px 11px;

    border-radius: 20px;

    background: #f4f6f8;

    color: #7a8699;

    font-size: 12px;
    font-weight: 650;
}

.connection-status.connected {
    background: #eaf8f1;
    color: #168a5b;
}

.connection-status.disconnected {
    background: #fff1f2;
    color: #c92d3d;
}

.connection-dot {
    width: 8px;
    height: 8px;

    border-radius: 50%;

    background: #98a2b3;
}

.connection-status.connected .connection-dot {
    background: #18a66b;
}

.connection-status.disconnected .connection-dot {
    background: #dc3545;
}


/* =========================================================
   ICON BUTTON
========================================================= */

.icon-button {
    width: 38px;
    height: 38px;

    border: 1px solid #dfe5ed;

    border-radius: 9px;

    background: #ffffff;

    color: #536174;

    font-size: 20px;

    transition:
        background 0.2s,
        border-color 0.2s;
}

.icon-button:hover {
    background: #f4f7fb;
    border-color: #cbd5e1;
}

.mobile-menu-button {
    display: none;

    width: 38px;
    height: 38px;

    border: 1px solid #dfe5ed;
    border-radius: 9px;

    background: #ffffff;

    font-size: 19px;
}


/* =========================================================
   PAGE
========================================================= */

.page {
    padding: 28px 30px;
}

.page.active {
    display: block;
}


/* =========================================================
   STATS
========================================================= */

.stats-grid {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 16px;

    margin-bottom: 22px;
}

.stat-card {
    min-height: 112px;

    padding: 20px;

    display: flex;
    align-items: center;

    gap: 15px;

    background: #ffffff;

    border: 1px solid #e4e9f1;

    border-radius: 13px;

    box-shadow:
        0 4px 18px rgba(22, 39, 64, 0.035);
}

.stat-icon {
    width: 48px;
    height: 48px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 12px;

    font-size: 21px;
}

.stat-icon.blue {
    background: #eaf4ff;
}

.stat-icon.orange {
    background: #fff5e7;
}

.stat-icon.green {
    background: #eaf8f1;
}

.stat-icon.purple {
    background: #f3edff;
}

.stat-content {
    min-width: 0;
}

.stat-label {
    color: #7a8699;

    font-size: 12px;
    font-weight: 600;
}

.stat-value {
    margin-top: 3px;

    color: #182230;

    font-size: 26px;
    line-height: 1.1;
    font-weight: 800;
}


/* =========================================================
   SECTION CARD
========================================================= */

.section-card {
    margin-bottom: 22px;

    background: #ffffff;

    border: 1px solid #e4e9f1;

    border-radius: 13px;

    overflow: hidden;

    box-shadow:
        0 4px 18px rgba(22, 39, 64, 0.035);
}

.section-header {
    min-height: 76px;

    padding: 17px 20px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 15px;

    border-bottom: 1px solid #edf0f5;
}

.section-header h2 {
    font-size: 17px;
    font-weight: 760;
}

.section-header p {
    margin-top: 3px;

    color: #8994a5;

    font-size: 12px;
}


/* =========================================================
   WAITING COUNTER
========================================================= */

.waiting-counter {
    display: flex;
    align-items: center;
    gap: 7px;

    padding: 6px 10px;

    border-radius: 20px;

    background: #fff5e7;

    color: #a55d00;

    font-size: 12px;
    font-weight: 700;
}

.waiting-count {
    min-width: 20px;
    height: 20px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: #f59e0b;
    color: #ffffff;

    font-size: 11px;
}


/* =========================================================
   LIVE REQUESTS
========================================================= */

.live-requests-container {
    padding: 18px;
}

.live-request-card {
    margin-bottom: 12px;

    padding: 18px;

    border: 1px solid #f1dfbc;

    border-left: 4px solid #f59e0b;

    border-radius: 11px;

    background: #fffdf8;

    transition:
        box-shadow 0.2s,
        transform 0.2s;
}

.live-request-card:last-child {
    margin-bottom: 0;
}

.live-request-card:hover {
    transform: translateY(-1px);

    box-shadow:
        0 8px 22px rgba(70, 50, 20, 0.07);
}

.live-request-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    gap: 15px;
}

.live-request-header strong {
    font-size: 15px;
}

.live-request-session {
    margin-top: 3px;

    color: #7b8797;

    font-size: 12px;
}

.live-request-body {
    margin-top: 14px;

    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 10px;

    color: #5f6c7d;

    font-size: 12px;
}

.live-request-body strong {
    color: #344054;
}

.live-request-last-message {
    grid-column: 1 / -1;

    padding-top: 11px;

    border-top: 1px solid #f0e8d9;
}

.live-request-last-message div {
    margin-top: 4px;

    color: #344054;

    line-height: 1.55;

    word-break: break-word;
}

.live-request-actions {
    margin-top: 16px;

    padding-top: 14px;

    border-top: 1px solid #f0e8d9;

    display: flex;
    justify-content: flex-end;

    gap: 8px;

    flex-wrap: wrap;
}


/* =========================================================
   STATUS BADGES
========================================================= */

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 25px;

    padding: 4px 9px;

    border-radius: 20px;

    font-size: 10px;
    line-height: 1;
    font-weight: 800;

    letter-spacing: 0.2px;
}

.status-waiting {
    background: #fff2d9;
    color: #a55d00;
}

.status-active {
    background: #eaf4ff;
    color: #2477d4;
}

.status-assigned {
    background: #eaf8f1;
    color: #168a5b;
}

.status-closed {
    background: #edf0f3;
    color: #667085;
}

.status-unknown {
    background: #f1f3f5;
    color: #667085;
}


/* =========================================================
   CONVERSATION LIST
========================================================= */

.conversations-list {
    width: 100%;
}

.conversation-row {
    min-height: 72px;

    padding: 12px 18px;

    display: grid;

    grid-template-columns:
        1.1fr
        100px
        70px
        1fr
        1fr
        2fr
        150px;

    align-items: center;

    gap: 12px;

    border-bottom: 1px solid #edf0f5;

    cursor: pointer;

    transition:
        background 0.15s;
}

.conversation-row:last-child {
    border-bottom: 0;
}

.conversation-row:hover {
    background: #f7faff;
}

.conversation-id {
    overflow: hidden;

    white-space: nowrap;
    text-overflow: ellipsis;

    color: #344054;

    font-size: 12px;
    font-weight: 700;
}

.conversation-message-count {
    color: #667085;
    font-size: 12px;
}

.conversation-agent,
.conversation-target {
    overflow: hidden;

    white-space: nowrap;
    text-overflow: ellipsis;

    color: #667085;

    font-size: 12px;
}

.conversation-last-message {
    overflow: hidden;

    white-space: nowrap;
    text-overflow: ellipsis;

    color: #667085;

    font-size: 12px;
}

.conversation-date {
    color: #8b95a5;
    font-size: 11px;
}


/* =========================================================
   CONVERSATION PAGE
========================================================= */

.conversation-layout {
    display: grid;

    grid-template-columns:
        minmax(330px, 390px)
        minmax(0, 1fr);

    height: calc(100vh - 134px);

    min-height: 620px;

    background: #ffffff;

    border: 1px solid #e4e9f1;

    border-radius: 13px;

    overflow-y: auto;
}


/* =========================================================
   CONVERSATION LIST PANEL
========================================================= */

.conversation-list-panel {
    min-width: 0;

    display: flex;
    flex-direction: column;

    border-right: 1px solid #e4e9f1;

    background: #ffffff;
}

.panel-header {
    padding: 18px 18px 14px;

    border-bottom: 1px solid #edf0f5;
}

.panel-header h2 {
    font-size: 17px;
    font-weight: 760;
}

.panel-header p {
    margin-top: 2px;

    color: #8a95a5;

    font-size: 12px;
}


/* =========================================================
   SEARCH
========================================================= */

.conversation-search {
    position: relative;

    margin: 13px 14px;

    height: 40px;
}

.conversation-search input {
    width: 100%;
    height: 100%;

    padding:
        0 12px 0 36px;

    border:
        1px solid #dce3ec;

    border-radius: 9px;

    background: #f9fafc;

    font-size: 12px;
}

.conversation-search input:focus {
    border-color: #2477d4;

    background: #ffffff;

    box-shadow:
        0 0 0 3px rgba(36, 119, 212, 0.08);
}

.search-icon {
    position: absolute;

    left: 12px;
    top: 50%;

    transform: translateY(-50%);

    color: #8a95a5;

    font-size: 13px;

    pointer-events: none;
}


/* =========================================================
   FILTERS
========================================================= */

.conversation-filters {
    display: flex;

    gap: 5px;

    padding: 0 14px 13px;

    overflow-x: auto;
}

.filter-button {
    flex-shrink: 0;

    border: 1px solid #e1e6ed;

    background: #ffffff;

    color: #667085;

    padding: 6px 10px;

    border-radius: 7px;

    font-size: 11px;
    font-weight: 650;
}

.filter-button:hover {
    background: #f5f7fa;
}

.filter-button.active {
    border-color: #2477d4;

    background: #eaf4ff;

    color: #2477d4;
}


/* =========================================================
   CHAT PANEL
========================================================= */

.chat-panel {
    min-width: 0;

    display: flex;
    flex-direction: column;

    background: #f8fafc;
    overflow-y: auto;
}


/* =========================================================
   CHAT HEADER
========================================================= */

.chat-header {
    min-height: 75px;

    padding: 13px 18px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 15px;

    background: #ffffff;

    border-bottom: 1px solid #e4e9f1;
}

.chat-header-info {
    min-width: 0;

    display: flex;
    align-items: center;

    gap: 11px;
}

.chat-avatar {
    width: 42px;
    height: 42px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: #eaf4ff;

    font-size: 19px;
}

.chat-header h2 {
    overflow: hidden;

    white-space: nowrap;
    text-overflow: ellipsis;

    font-size: 15px;
    font-weight: 760;
}

.chat-status {
    margin-top: 4px;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 7px;
}


/* =========================================================
   CONVERSATION META
========================================================= */

.conversation-meta {
    padding: 10px 18px;

    display: flex;
    flex-wrap: wrap;

    gap: 8px 18px;

    background: #ffffff;

    border-bottom: 1px solid #edf0f5;

    color: #687487;

    font-size: 11px;
}

.conversation-meta strong {
    color: #344054;
}


/* =========================================================
   CONVERSATION ACTIONS
========================================================= */

.conversation-actions {
    min-height: 55px;

    padding: 9px 18px;

    display: flex;
    align-items: center;
    justify-content: flex-end;

    gap: 8px;

    flex-wrap: wrap;

    background: #ffffff;

    border-bottom: 1px solid #e4e9f1;
}

.conversation-actions:empty {
    display: none;
}


/* =========================================================
   MESSAGES
========================================================= */

.messages-container {
    flex: 1;

    min-height: 0;

    overflow-y: auto;

    padding: 20px;
}

.chat-message {
    max-width: 75%;

    margin-bottom: 13px;

    padding: 11px 13px;

    border-radius: 11px;

    background: #ffffff;

    border: 1px solid #e4e9f1;

    box-shadow:
        0 2px 8px rgba(20, 40, 70, 0.025);
}

.chat-message:last-child {
    margin-bottom: 0;
}

.chat-message-role {
    margin-bottom: 4px;

    color: #2477d4;

    font-size: 10px;
    font-weight: 800;

    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.chat-message-content {
    color: #344054;

    font-size: 13px;

    line-height: 1.55;

    white-space: pre-wrap;

    word-break: break-word;
}

.chat-message-time {
    margin-top: 6px;

    color: #98a2b3;

    font-size: 9px;
}


/* USER MESSAGE */

.chat-message.message-user {
    margin-left: auto;

    background: #eaf4ff;

    border-color: #d5e8ff;
}

.chat-message.message-user .chat-message-role {
    color: #2477d4;
}


/* BOT MESSAGE */

.chat-message.message-bot {
    margin-right: auto;

    background: #ffffff;
}


/* AGENT MESSAGE */

.chat-message.message-agent {
    margin-right: auto;

    background: #eaf8f1;

    border-color: #d7f0e5;
}

.chat-message.message-agent .chat-message-role {
    color: #168a5b;
}


/* SYSTEM / HANDOFF-EVENT MESSAGE
   Rendered inline in the single message feed for
   agent_requested / agent_joined / session_closed etc, so the
   full session history reads as one chronological timeline
   instead of a second duplicate scrolling panel. */

.chat-message.message-system {
    max-width: 100%;

    margin: 4px auto 13px;

    padding: 6px 12px;

    background: #f5f7fa;
    border: 1px dashed #d6dce5;

    text-align: center;
}

.chat-message.message-system .chat-message-content {
    color: #667085;

    font-size: 11px;
    font-style: italic;
}

.chat-message.message-system .chat-message-time {
    margin-top: 2px;
}


/* =========================================================
   CHAT FOOTER
========================================================= */

.chat-footer {
    min-height: 44px;

    padding: 8px 18px;

    display: flex;
    align-items: center;

    background: #ffffff;

    border-top: 1px solid #e4e9f1;
}

.chat-footer-status {
    display: flex;
    align-items: center;
    gap: 7px;

    color: #7a8699;

    font-size: 10px;
}

.chat-footer-status .connection-dot {
    width: 7px;
    height: 7px;

    background: #18a66b;
}


/* =========================================================
   EMPTY STATES
========================================================= */

.empty-state {
    padding: 45px 20px;

    text-align: center;

    color: #8a95a5;
}

.empty-state h3 {
    margin-top: 10px;

    color: #536174;

    font-size: 14px;
}

.empty-state p {
    max-width: 430px;

    margin: 5px auto 0;

    font-size: 12px;

    line-height: 1.5;
}

.empty-icon {
    font-size: 30px;
}

.empty-chat {
    height: 100%;

    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    text-align: center;

    color: #8a95a5;
}

.empty-chat-icon {
    width: 65px;
    height: 65px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: #edf3f9;

    font-size: 27px;

    margin-bottom: 14px;
}

.empty-chat h3 {
    color: #536174;

    font-size: 15px;
}

.empty-chat p {
    margin-top: 4px;

    font-size: 12px;
}


/* =========================================================
   AGENTS
========================================================= */

.agents-list {
    width: 100%;
}

.agent-row {
    min-height: 70px;

    padding: 12px 20px;

    display: grid;

    grid-template-columns:
        42px
        1.5fr
        100px
        130px
        100px
        150px;

    align-items: center;

    gap: 14px;

    border-bottom: 1px solid #edf0f5;
}

.agent-row:last-child {
    border-bottom: 0;
}

.agent-avatar {
    width: 38px;
    height: 38px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: #eaf4ff;

    color: #2477d4;

    font-size: 12px;
    font-weight: 800;
}

.agent-info {
    min-width: 0;

    display: flex;
    flex-direction: column;
}

.agent-info strong {
    overflow: hidden;

    white-space: nowrap;
    text-overflow: ellipsis;

    font-size: 13px;
}

.agent-info span {
    overflow: hidden;

    white-space: nowrap;
    text-overflow: ellipsis;

    color: #8a95a5;

    font-size: 11px;
}

.online,
.offline {
    display: inline-flex;

    align-items: center;

    gap: 6px;

    font-size: 11px;
    font-weight: 700;
}

.online {
    color: #168a5b;
}

.offline {
    color: #98a2b3;
}

.online::before,
.offline::before {
    content: "";

    width: 7px;
    height: 7px;

    border-radius: 50%;
}

.online::before {
    background: #18a66b;
}

.offline::before {
    background: #98a2b3;
}


/* =========================================================
   CREATE AGENT
========================================================= */

.create-agent-form {
    padding: 20px;
}

.form-row {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 15px;
}


/* =========================================================
   TOAST
========================================================= */

.toast-container {
    position: fixed;

    right: 20px;
    bottom: 20px;

    width: min(360px, calc(100vw - 40px));

    z-index: 99999;
}

.toast {
    padding: 12px 15px;

    margin-top: 9px;

    border-radius: 9px;

    color: #ffffff;

    background: #273142;

    font-size: 12px;
    font-weight: 600;

    box-shadow:
        0 8px 25px rgba(0, 0, 0, 0.16);

    animation:
        toastIn 0.2s ease-out;
}

.toast-success {
    background: #168a5b;
}

.toast-error {
    background: #c92d3d;
}

.toast-info {
    background: #2477d4;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* =========================================================
   LOADING
========================================================= */

.loading-overlay {
    position: fixed;

    inset: 0;

    z-index: 100000;

    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    gap: 12px;

    background: rgba(255, 255, 255, 0.78);

    backdrop-filter: blur(3px);

    color: #536174;

    font-size: 13px;
    font-weight: 650;
}

.loading-spinner {
    width: 32px;
    height: 32px;

    border:
        3px solid #e3e9f0;

    border-top-color: #2477d4;

    border-radius: 50%;

    animation:
        spin 0.75s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


/* =========================================================
   SCROLLBARS
========================================================= */

* {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 20px;
}

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


/* =========================================================
   TABLET
========================================================= */

@media (max-width: 1200px) {

    .stats-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .conversation-row {
        grid-template-columns:
            1fr
            90px
            60px
            1fr
            1fr;

        row-gap: 5px;
    }

    .conversation-last-message {
        grid-column: 1 / 4;
    }

    .conversation-date {
        grid-column: 4 / 6;
    }

    .agent-row {
        grid-template-columns:
            42px
            1.5fr
            100px
            120px;
    }

    .agent-row > div:nth-child(5),
    .agent-row > div:nth-child(6) {
        display: none;
    }
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 900px) {

    .sidebar {
        position: fixed;

        left: -270px;

        top: 0;
        bottom: 0;

        z-index: 100;

        transition: left 0.25s ease;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .mobile-menu-button {
        display: block;
    }

    .topbar {
        padding: 0 18px;
    }

    .page {
        padding: 20px 18px;
    }

    .stats-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .conversation-layout {
        grid-template-columns: 1fr;

        height: auto;

        min-height: 0;
    }

    .conversation-list-panel {
        min-height: 430px;

        border-right: 0;

        border-bottom: 1px solid #e4e9f1;
        overflow-y: auto;
    }

    .chat-panel {
        min-height: 650px;
    }

    .live-request-body {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}


/* =========================================================
   SMALL MOBILE
========================================================= */

@media (max-width: 600px) {

    .login-card {
        padding: 28px 22px;
    }

    .topbar {
        height: 70px;
    }

    .page-title {
        font-size: 18px;
    }

    .page-subtitle {
        display: none;
    }

    .connection-status {
        width: 9px;
        height: 9px;

        min-height: 9px;

        padding: 0;

        border-radius: 50%;
    }

    .connection-status span:last-child {
        display: none;
    }

    .connection-status .connection-dot {
        width: 9px;
        height: 9px;
    }

    .stats-grid {
        grid-template-columns: 1fr;

        gap: 10px;
    }

    .stat-card {
        min-height: 90px;

        padding: 15px;
    }

    .section-header {
        padding: 15px;
    }

    .live-requests-container {
        padding: 12px;
    }

    .live-request-card {
        padding: 14px;
    }

    .live-request-body {
        grid-template-columns: 1fr;
    }

    .live-request-actions {
        justify-content: stretch;
    }

    .live-request-actions .btn {
        flex: 1;
    }

    .conversation-row {
        grid-template-columns:
            1fr
            auto;

        padding: 13px;
    }

    .conversation-status {
        grid-column: 2;
        grid-row: 1;
    }

    .conversation-message-count,
    .conversation-agent,
    .conversation-target,
    .conversation-last-message,
    .conversation-date {
        grid-column: 1 / -1;
    }

    .conversation-last-message {
        white-space: normal;
    }

    .conversation-date {
        grid-column: 1 / -1;
    }

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

    .conversation-actions {
        justify-content: stretch;
    }

    .conversation-actions .btn {
        flex: 1;
    }

    .chat-header {
        padding: 12px;
    }

    .messages-container {
        padding: 13px;
    }

    .conversation-meta {
        padding: 10px 13px;
    }

    .agent-row {
        grid-template-columns:
            42px
            1fr;
    }

    .agent-row > div:nth-child(n + 3) {
        display: none;
    }

    .create-agent-form {
        padding: 15px;
    }

    .topbar-right .icon-button {
        width: 34px;
        height: 34px;
    }
}
/* =========================================================
   CHAT COMPOSER
   (append to style.css — these classes didn't exist before,
   which is why the composer was present in the DOM but
   effectively invisible / unstyled)
========================================================= */

.chat-composer {
    flex-shrink: 0;

    background: #ffffff;

    border-top: 1px solid #e4e9f1;
}

.chat-composer-form {
    display: flex;
    align-items: center;

    gap: 10px;

    padding: 14px 18px;
}

.chat-composer-form input[type="text"] {
    flex: 1;
    min-width: 0;

    height: 44px;

    border: 1px solid #d7dee9;
    border-radius: 10px;

    background: #ffffff;
    color: #172033;

    padding: 0 14px;

    transition:
        border-color 0.2s,
        box-shadow 0.2s;
}

.chat-composer-form input[type="text"]:focus {
    border-color: #2f80ed;

    box-shadow:
        0 0 0 3px rgba(47, 128, 237, 0.12);
}

.chat-composer-form .btn {
    flex-shrink: 0;
}

.chat-composer-hint {
    padding: 14px 18px;

    color: #8a95a5;

    font-size: 12px;

    background: #ffffff;

    border-top: 1px solid #e4e9f1;
}

.chat-composer-hint.locked {
    color: #a55d00;
    background: #fffaf0;
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 600px) {

    .chat-composer-form {
        padding: 10px 13px;
    }
}
/* =========================================================
   Production handoff presence indicators
========================================================= */
.presence-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    background: #94a3b8;
}
.presence-dot.online { background: #22c55e; }
.presence-dot.offline { background: #f59e0b; }
.conversation-presence { white-space: nowrap; font-size: 12px; }


/* =========================================================
   GOLD + BLACK AGENT DASHBOARD THEME
   Conversation page is a fixed two-pane workspace:
   - session lists scroll independently
   - chat messages scroll independently
   - the page itself does not scroll while Conversations is open
========================================================= */

:root {
    --dbf-black: #080808;
    --dbf-black-2: #101010;
    --dbf-black-3: #171717;
    --dbf-panel: #111111;
    --dbf-panel-2: #151515;
    --dbf-border: rgba(212, 175, 55, 0.20);
    --dbf-border-strong: rgba(212, 175, 55, 0.38);
    --dbf-gold: #d4af37;
    --dbf-gold-bright: #f0c95c;
    --dbf-gold-soft: rgba(212, 175, 55, 0.12);
    --dbf-text: #f5f1e6;
    --dbf-muted: #a9a292;
}

/* Base */
html,
body {
    background: var(--dbf-black);
    color: var(--dbf-text);
}

body {
    overflow-x: hidden;
}

.app {
    min-height: 100vh;
    background: var(--dbf-black);
}

/* Login */
.login-screen {
    background:
        radial-gradient(circle at 20% 10%, rgba(212,175,55,.16), transparent 32%),
        radial-gradient(circle at 85% 90%, rgba(212,175,55,.08), transparent 35%),
        var(--dbf-black);
}

.login-card {
    background: linear-gradient(145deg, #141414, #0b0b0b);
    border-color: var(--dbf-border-strong);
    box-shadow: 0 24px 80px rgba(0,0,0,.55);
}

.login-logo,
.brand-icon {
    background: var(--dbf-gold-soft);
    border: 1px solid var(--dbf-border);
}

.login-card h1,
.sidebar-user-name,
.page-title,
.section-header h2,
.panel-header h2,
.chat-header h2,
.stat-value {
    color: var(--dbf-text);
}

.login-subtitle,
.page-subtitle,
.panel-header p,
.section-header p,
.stat-label,
.sidebar-user-email {
    color: var(--dbf-muted);
}

.form-group label {
    color: #ddd4bd;
}

.form-group input,
.form-group select,
.form-group textarea {
    background: #0e0e0e;
    color: var(--dbf-text);
    border-color: var(--dbf-border);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.conversation-search input:focus {
    border-color: var(--dbf-gold);
    box-shadow: 0 0 0 3px rgba(212,175,55,.13);
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, #b99221, var(--dbf-gold));
    color: #090909;
    font-weight: 800;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--dbf-gold), var(--dbf-gold-bright));
    box-shadow: 0 8px 22px rgba(212,175,55,.20);
}

.btn-secondary {
    background: #1b1b1b;
    color: #ded5bf;
    border: 1px solid var(--dbf-border);
}

.btn-secondary:hover {
    background: #232323;
    color: var(--dbf-gold-bright);
    border-color: var(--dbf-border-strong);
}

/* Sidebar */
.sidebar {
    background: #070707;
    border-right-color: var(--dbf-border);
}

.sidebar-brand {
    border-bottom-color: var(--dbf-border);
}

.brand-title {
    color: var(--dbf-text);
}

.brand-subtitle {
    color: #8f8879;
}

.nav-link {
    color: #a49d8d;
}

.nav-link:hover {
    background: var(--dbf-gold-soft);
    color: var(--dbf-gold-bright);
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(212,175,55,.20), rgba(212,175,55,.06));
    color: var(--dbf-gold-bright);
    box-shadow: inset 3px 0 0 var(--dbf-gold);
}

.sidebar-user {
    border-top-color: var(--dbf-border);
}

.avatar {
    background: var(--dbf-gold);
    color: #090909;
}

/* Main/topbar */
.main-content {
    background: var(--dbf-black);
}

.topbar {
    background: #0b0b0b;
    border-bottom-color: var(--dbf-border);
}

.icon-button,
.mobile-menu-button {
    background: #141414;
    color: var(--dbf-gold-bright);
    border-color: var(--dbf-border);
}

.icon-button:hover {
    background: #1c1c1c;
    border-color: var(--dbf-border-strong);
}

.connection-status {
    background: #181818;
    color: #b7af9d;
}

.connection-status.connected {
    background: rgba(47, 170, 111, .13);
    color: #73d7a4;
}

/* Dashboard cards */
.stat-card,
.section-card {
    background: linear-gradient(145deg, #141414, #0e0e0e);
    border-color: var(--dbf-border);
    box-shadow: 0 10px 30px rgba(0,0,0,.22);
}

.stat-icon.blue,
.stat-icon.orange,
.stat-icon.green,
.stat-icon.purple {
    background: var(--dbf-gold-soft);
}

.waiting-counter {
    background: rgba(212,175,55,.13);
    color: var(--dbf-gold-bright);
}

.waiting-count {
    background: var(--dbf-gold);
    color: #090909;
}

/* Live requests */
.live-request-card {
    background: rgba(212,175,55,.045);
    border-color: var(--dbf-border);
    border-left-color: var(--dbf-gold);
}

.live-request-header strong,
.live-request-body strong,
.live-request-last-message div {
    color: #e8dfca;
}

.live-request-session,
.live-request-body {
    color: var(--dbf-muted);
}

.live-request-last-message,
.live-request-actions {
    border-color: var(--dbf-border);
}

/* =========================================================
   CONVERSATIONS WORKSPACE
========================================================= */

#conversationsPage {
    height: calc(100vh - 78px);
    min-height: 0;
    overflow: hidden;
}

#conversationsPage .conversation-layout {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    background: #0b0b0b;
    border-color: var(--dbf-border);
    box-shadow: 0 12px 40px rgba(0,0,0,.35);
}

.conversation-list-panel {
    min-height: 0;
    height: 100%;
    overflow: hidden;
    background: #0d0d0d;
    border-right-color: var(--dbf-border);
}

.conversation-search {
    flex: 0 0 auto;
}

.conversation-search input {
    background: #151515;
    color: var(--dbf-text);
    border-color: var(--dbf-border);
}

.conversation-search input::placeholder {
    color: #777064;
}

.search-icon {
    color: var(--dbf-gold);
}

.conversation-filters {
    flex: 0 0 auto;
    padding-bottom: 12px;
}

.filter-button {
    background: #141414;
    color: #a9a18e;
    border-color: var(--dbf-border);
}

.filter-button:hover {
    background: #1e1e1e;
    color: var(--dbf-gold-bright);
}

.filter-button.active {
    background: var(--dbf-gold);
    border-color: var(--dbf-gold);
    color: #080808;
}

.filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    margin-left: 4px;
    padding: 0 5px;
    border-radius: 10px;
    background: rgba(255,255,255,.10);
    font-size: 9px;
}

.filter-button.active .filter-count {
    background: rgba(0,0,0,.16);
}

.conversation-status-lists {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    overflow: hidden;
}

.conversation-status-list {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    background: #0d0d0d;
    scrollbar-width: thin;
    scrollbar-color: rgba(212,175,55,.55) transparent;
}

.conversation-status-list::-webkit-scrollbar,
.messages-container::-webkit-scrollbar {
    width: 8px;
}

.conversation-status-list::-webkit-scrollbar-track,
.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.conversation-status-list::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb {
    background: rgba(212,175,55,.45);
    border-radius: 8px;
}

.conversation-status-list::-webkit-scrollbar-thumb:hover,
.messages-container::-webkit-scrollbar-thumb:hover {
    background: rgba(240,201,92,.72);
}

/* Clickable session boxes */
.conversation-row {
    min-height: 82px;
    background: #0f0f0f;
    border-bottom-color: rgba(212,175,55,.11);
    transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.conversation-row:hover {
    background: rgba(212,175,55,.08);
    box-shadow: inset 3px 0 0 var(--dbf-gold);
}

.conversation-row:active {
    background: rgba(212,175,55,.13);
}

.conversation-id {
    color: var(--dbf-gold-bright);
}

.conversation-last-message,
.conversation-agent,
.conversation-target,
.conversation-date,
.conversation-message-count,
.conversation-presence {
    color: #a9a292;
}

.presence-dot.online {
    background: #58c98b;
}

.presence-dot.offline {
    background: #6d675c;
}

/* Status badges */
.status-waiting {
    background: rgba(212,175,55,.16);
    color: var(--dbf-gold-bright);
}

.status-active,
.status-assigned {
    background: rgba(66, 155, 106, .15);
    color: #79d39e;
}

.status-closed {
    background: rgba(255,255,255,.08);
    color: #aaa294;
}

/* Chat panel: fixed workspace, no panel-level scrolling */
.chat-panel {
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    background: #0b0b0b;
}

.chat-header {
    flex: 0 0 auto;
    background: #101010;
    border-bottom-color: var(--dbf-border);
}

.chat-avatar {
    background: var(--dbf-gold-soft);
    border-color: var(--dbf-border);
    color: var(--dbf-gold-bright);
}

.chat-status {
    color: var(--dbf-muted);
}

.conversation-meta {
    flex: 0 0 auto;
    background: #0e0e0e;
    border-bottom-color: var(--dbf-border);
    color: #b4ab99;
}

.conversation-actions {
    flex: 0 0 auto;
    background: #101010;
    border-bottom-color: var(--dbf-border);
}

/* ONLY THIS AREA scrolls for the full conversation */
.messages-container {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    overflow-y: auto;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 15% 10%, rgba(212,175,55,.035), transparent 30%),
        #090909;
    scrollbar-width: thin;
    scrollbar-color: rgba(212,175,55,.55) transparent;
}

.chat-message {
    background: #151515;
    border-color: rgba(212,175,55,.16);
    color: #eee7d8;
    box-shadow: 0 4px 14px rgba(0,0,0,.20);
}

.chat-message-role {
    color: var(--dbf-gold-bright);
}

.chat-message-time {
    color: #827b6e;
}

.chat-message.user,
.chat-message[data-role="user"] {
    background: rgba(212,175,55,.12);
    border-color: rgba(212,175,55,.28);
}

.chat-message.agent,
.chat-message[data-role="agent"] {
    background: #181818;
    border-color: rgba(212,175,55,.18);
}

.chat-message.system,
.chat-message[data-role="system"] {
    background: rgba(255,255,255,.045);
    border-color: rgba(255,255,255,.08);
}

.empty-chat {
    color: #9e9687;
}

.empty-chat h3 {
    color: #ded5c2;
}

.chat-footer {
    flex: 0 0 auto;
    background: #0e0e0e;
    border-top-color: var(--dbf-border);
    color: #a79f8f;
}

.chat-composer {
    flex: 0 0 auto;
    background: #101010;
    border-top-color: var(--dbf-border);
}

.chat-composer input {
    background: #171717;
    color: var(--dbf-text);
    border-color: var(--dbf-border);
}

.chat-composer input:focus {
    border-color: var(--dbf-gold);
    box-shadow: 0 0 0 3px rgba(212,175,55,.12);
}

.chat-composer-hint {
    color: #b6ad9a;
}

/* Agents page */
.agent-row {
    background: #111111;
    border-color: var(--dbf-border);
}

.agent-row:hover {
    background: #171717;
}

.create-agent-form {
    background: #0f0f0f;
}

/* Toast/loading */
.toast {
    background: #161616;
    color: #eee7d8;
    border-color: var(--dbf-border);
}

.loading-overlay {
    background: rgba(0,0,0,.78);
}

/* Prevent the page itself from becoming the chat scroller */
body:has(#conversationsPage.active) {
    overflow: hidden;
}

.main-content:has(#conversationsPage.active) {
    height: 100vh;
    overflow: hidden;
}

/* Responsive: keep separate scroll areas on mobile too */
@media (max-width: 900px) {
    #conversationsPage {
        height: auto;
        min-height: calc(100vh - 70px);
        overflow: hidden;
    }

    #conversationsPage .conversation-layout {
        height: calc(100vh - 100px);
        min-height: 620px;
        overflow: hidden;
    }

    .conversation-list-panel {
        height: 42%;
        min-height: 300px;
        overflow: hidden;
        border-right: 0;
        border-bottom: 1px solid var(--dbf-border);
    }

    .conversation-status-lists {
        min-height: 0;
    }

    .chat-panel {
        height: 58%;
        min-height: 320px;
    }

    .messages-container {
        min-height: 0;
    }
}

@media (max-width: 600px) {
    #conversationsPage .conversation-layout {
        height: calc(100vh - 88px);
        min-height: 0;
    }

    .conversation-list-panel {
        min-height: 260px;
    }

    .chat-panel {
        min-height: 0;
    }
}