﻿body {
    margin: 0;
    font-family: "Segoe UI", sans-serif;
    background: #f4f6f9;
}

.admin-layout {
    display: flex;
    height: 90vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: #1e293b;
    color: white;
    padding: 15px;
    overflow-y: auto;
}

.sidebar-title {
    margin-bottom: 15px;
}

.client-list {
    list-style: none;
    padding: 0;
}

.client-item {
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

    .client-item:hover {
        background: #334155;
    }

    .client-item.active {
        background: #2563eb;
    }

    /* NEW: escalated client highlight in sidebar */
    .client-item.escalated {
        border-left: 3px solid red;
    }

.online-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    margin-right: 6px;
}

.badge {
    background: red;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 10px;
}

/* Main */
.main-content {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: row;
    gap: 20px;
    flex-wrap: nowrap;
    align-items: stretch;
    align-content: space-between;
}

.card-section {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    padding: 15px;
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow-y: Auto;
}

.section-header {
    font-weight: bold;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Chat */
.chat-box {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 6px;
    background: #f9fafb;
}

.message {
    margin-bottom: 8px;
}

    .message.admin {
        text-align: right;
        color: #2563eb;
    }

    .message.client {
        text-align: left;
        color: #111;
    }

    .message.bot {
        text-align: left;
        color: #7c3aed;
    }

    .message.system {
        text-align: left;
        color: #6b7280;
        font-style: italic;
        padding: 2px 0;
        cursor: pointer;
    }

        .message.system:hover {
            color: #2563eb;
            text-decoration: none;
        }

        .message.system .view-history-link {
            color: #2563eb;
            font-size: 11px;
            margin-left: 6px;
            text-decoration: underline;
            cursor: pointer;
        }

.timestamp {
    font-size: 10px;
    color: gray;
}

/* NEW: Bot history popup */
.history-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    padding: 20px;
    width: 420px;
    max-height: 500px;
    z-index: 1000;
    flex-direction: column;
}

    .history-popup.open {
        display: flex;
    }

.history-popup-header {
    font-weight: bold;
    font-size: 15px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-popup-close {
    cursor: pointer;
    color: gray;
    font-size: 18px;
    border: none;
    background: none;
    padding: 0 4px;
}

.history-popup-body {
    overflow-y: auto;
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 10px;
    background: #f9fafb;
}

.history-msg {
    margin: 5px 0;
    font-size: 13px;
}

    .history-msg.user {
        color: #111;
    }

    .history-msg.bot {
        color: #7c3aed;
    }

    .history-msg.system {
        color: #6b7280;
        font-style: italic;
    }

.history-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 999;
}

    .history-overlay.open {
        display: block;
    }

/* Command Output */
.output-box {
    flex: 1;
    overflow-y: auto;
    background: black;
    color: #00ff00;
    padding: 10px;
    font-family: Consolas, monospace;
    border-radius: 6px;
}

/* Input Row */
.input-row {
    display: flex;
    margin-top: 10px;
}

    .input-row input {
        flex: 1;
        padding: 8px;
    }

    .input-row button {
        padding: 8px 12px;
        background: #2563eb;
        color: white;
        border: none;
        cursor: pointer;
    }

        .input-row button.warning {
            background: #f59e0b;
        }

/* Knowledge Base Panel */
.kb-section {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    padding: 15px;
}

.kb-upload-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

    .kb-upload-row input[type="file"] {
        flex: 1;
        font-size: 13px;
        border: 1px solid #ddd;
        border-radius: 4px;
        padding: 4px;
    }

.kb-upload-btn {
    padding: 6px 14px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}

    .kb-upload-btn:disabled {
        background: #94a3b8;
        cursor: not-allowed;
    }

.kb-progress {
    display: none;
    font-size: 12px;
    color: #2563eb;
    margin-bottom: 8px;
}

.kb-status {
    font-size: 11px;
    font-weight: normal;
    margin-left: 8px;
}

.kb-doc-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    margin: 4px 0;
    background: #f8fafc;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    font-size: 13px;
}

.kb-doc-delete {
    background: none;
    border: none;
    color: #dc2626;
    cursor: pointer;
    font-size: 12px;
}

.kb-empty {
    color: gray;
    font-size: 13px;
}

.kb-section {
    display: none;
}
/* Remote toggle */

.remote-toggle {
    position: absolute;
    top: 20px;
    right: 30px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

    .switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 34px;
    transition: .3s;
}

    .slider:before {
        position: absolute;
        content: "";
        height: 18px;
        width: 18px;
        left: 3px;
        bottom: 3px;
        background: white;
        border-radius: 50%;
        transition: .3s;
    }

input:checked + .slider {
    background: #22c55e;
}

    input:checked + .slider:before {
        transform: translateX(26px);
    }

.toggle-label {
    font-size: 13px;
    font-weight: 600;
}

#remoteSection {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

#remoteScreen {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0; 
    left: 0; 
}
#remoteScreen {
    max-width: 200%;
    max-height: 200%;
}


#chatSection{
    max-width:35%
}