/* ========================================
   AGENTHUB — DESIGN SYSTEM
   ======================================== */
:root {
    --bg: #eef1eb;
    --bg-sidebar: #fbfcf9;
    --bg-card: #ffffff;
    --bg-hover: #f2f5ed;
    --bg-input: #ffffff;
    --border: #d8dece;
    --border-light: #e4eadc;
    --text: #2e3728;
    --text-secondary: #4d5945;
    --text-muted: #7d8876;
    --accent: #b8ec3c;
    --accent-light: #5f7f1f;
    --accent-bg: rgba(184, 236, 60, 0.2);
    --green: #618f17;
    --green-bg: rgba(184, 236, 60, 0.24);
    --red: #d65158;
    --red-bg: rgba(225, 89, 100, 0.13);
    --yellow: #9b6f16;
    --sidebar-width: 240px;
    --radius: 10px;
    --radius-sm: 6px;
    --transition: 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    line-height: 1.5;
    font-size: 14px;
    color-scheme: light;
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    box-shadow: 0 0 0 1px rgba(216, 222, 206, 0.4);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-top {
    padding: 20px 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px;
    margin-bottom: 28px;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: var(--accent-bg);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-text {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text);
}

.nav-group {
    margin-bottom: 8px;
}

.nav-group-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-light);
    margin-bottom: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px 9px 18px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.nav-item.active {
    background: var(--accent-bg);
    color: var(--accent-light);
    font-weight: 500;
}

.nav-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-item.active svg {
    opacity: 1;
}

/* USER INFO */
.sidebar-bottom {
    padding: 14px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.user-info:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), #d3f46f);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #304017;
    flex-shrink: 0;
}

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

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

/* ========================================
   MAIN CONTENT
   ======================================== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 24px 32px 40px;
    min-width: 0;
    background: var(--bg);
}

.breadcrumb {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* PAGE HEADER */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    background: var(--accent);
    color: #2d3918;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background: #c9f55a;
    transform: translateY(-1px);
}

/* TABS */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.tab {
    padding: 10px 20px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}

.tab:hover {
    color: var(--text-secondary);
}

.tab.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

/* FILTERS */
.filters-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.time-filters {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.filter-btn {
    padding: 6px 14px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.filter-btn:hover {
    color: var(--text);
}

.filter-btn.active {
    background: var(--accent);
    color: #2d3918;
}

.search-filters {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    min-width: 200px;
}

.search-box svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    width: 100%;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.filter-dropdown {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.filter-dropdown:hover {
    border-color: var(--accent);
    color: var(--text);
}

/* TABLE */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: left;
    text-transform: none;
    letter-spacing: 0;
    background: #f1f4ee;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.th-sort-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    padding: 0;
}

.th-sort-btn:hover {
    color: var(--text-secondary);
}

.th-sort-btn.active {
    color: var(--text);
}

.th-sort-indicator {
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1;
}

.th-sort-btn.active .th-sort-indicator {
    color: var(--accent-light);
}

tbody td {
    padding: 14px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr {
    transition: var(--transition);
    cursor: pointer;
}

tbody tr:hover {
    background: var(--bg-hover);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Selected row highlight */
tbody tr.row-selected {
    background: rgba(184, 236, 60, 0.12);
}

tbody tr.row-selected:hover {
    background: rgba(184, 236, 60, 0.2);
}

.row-checkbox, #checkAll {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid #aebba1; /* Muted greenish border */
    border-radius: 4px;
    background-color: var(--bg-card);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    margin: 0;
    vertical-align: middle;
}

.row-checkbox:hover, #checkAll:hover {
    border-color: var(--accent-light);
    background-color: #f6f8f2;
}

.row-checkbox:checked, #checkAll:checked {
    background-color: var(--accent-light);
    border-color: var(--accent-light);
}

.row-checkbox:checked::after, #checkAll:checked::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

#checkAll:indeterminate {
    background-color: var(--accent-light);
    border-color: var(--accent-light);
}

#checkAll:indeterminate::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 6px;
    width: 7px;
    height: 1.5px;
    background-color: white;
}

/* Scenario name */
.scenario-name {
    font-weight: 500;
    color: var(--text);
}

.scenario-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}

.scenario-link:hover {
    text-decoration: underline;
}

/* Agent tags */
.agent-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.agent-tag {
    display: inline-block;
    padding: 3px 8px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Date */
.date-cell {
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Duration */
.duration-cell {
    color: var(--text-secondary);
}

/* Score */
.score-cell {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.score-high { color: var(--green); }
.score-mid { color: var(--yellow); }
.score-low { color: var(--red); }

/* Status badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.badge-pass {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.badge-fail {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge-ready {
    background: rgba(137, 150, 132, 0.12);
    color: #5d6659;
    border: 1px solid rgba(137, 150, 132, 0.3);
}

/* PAGINATION */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.page-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.page-btn:hover:not(:disabled):not(.active) {
    border-color: var(--accent);
    color: var(--text);
}

.page-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #2d3918;
    font-weight: 600;
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-dots {
    color: var(--text-muted);
    padding: 0 4px;
    font-size: 14px;
}

.kb-file-cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.kb-file-meta {
    min-width: 0;
}

.kb-file-name {
    color: var(--primary, #3498db);
}

.kb-file-count {
    font-size: 12px;
    color: var(--text-muted);
}

.btn-danger-link {
    border: 0;
    background: transparent;
    color: var(--red);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
}

.btn-danger-link:hover:not(:disabled) {
    text-decoration: underline;
}

.btn-danger-link:disabled {
    opacity: 0.55;
    cursor: wait;
}

/* ========================================
   SCROLLBAR
   ======================================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 900px) {
    .sidebar { display: none; }
    .main-wrapper { margin-left: 0; }
}

@media (max-width: 700px) {
    .filters-row { flex-direction: column; align-items: stretch; }
    .search-filters { flex-wrap: wrap; }
    .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .kb-file-cell { align-items: flex-start; flex-direction: column; }
}

/* ========================================
   CREATE SCENARIO MODAL
   ======================================== */
.hidden {
    display: none !important;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(7, 9, 12, 0.78);
    backdrop-filter: blur(3px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.scenario-modal {
    width: min(820px, 95vw);
    max-height: 92vh;
    overflow-y: auto;
    background: #f6f8f2;
    border: 1px solid #dbe1d2;
    border-radius: 16px;
    padding: 16px;
    color: #2d3729;
}

.scenario-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.scenario-modal-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.scenario-modal-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: #edf6db;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.scenario-modal-title-wrap h2 {
    font-size: 28px;
    line-height: 1.1;
    letter-spacing: -0.2px;
    color: #2d3729;
}

.scenario-modal-close {
    border: 0;
    background: transparent;
    font-size: 30px;
    line-height: 1;
    color: #818b78;
    cursor: pointer;
}

.scenario-modal-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: #4d5945;
}

.form-input {
    width: 100%;
    border: 1px solid #d8dece;
    border-radius: 10px;
    background: #ffffff;
    padding: 9px 12px;
    font-family: inherit;
    font-size: 14px;
    color: #2e3728;
    outline: none;
}

.form-input:focus {
    border-color: #b8ec3c;
    box-shadow: 0 0 0 3px rgba(184, 236, 60, 0.2);
}

.form-input::placeholder {
    color: #9aa594;
}

.form-textarea-sm {
    min-height: 74px;
    resize: vertical;
}

.form-textarea-md {
    min-height: 132px;
    resize: vertical;
}

.dialogues-head {
    margin-top: 6px;
}

.dialogues-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dialogue-row {
    display: grid;
    grid-template-columns: 26px 1fr;
    gap: 8px;
}

.dialogue-label {
    align-self: center;
    font-size: 12px;
    color: #677460;
    font-weight: 600;
}

.btn-add-dialogue {
    border: 1px solid #c8dca6;
    border-radius: 12px;
    background: #edf6db;
    color: #5f7f1f;
    font-size: 30px;
    line-height: 1;
    min-height: 44px;
    cursor: pointer;
}

.form-error {
    min-height: 18px;
    color: #cc4455;
    font-size: 12px;
}

.scenario-modal-footer {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.scenario-modal-footer .filter-dropdown {
    background: #ffffff;
    border: 1px solid #d8dece;
    color: #4d5945;
}

.scenario-modal-footer .btn-primary {
    background: #b8ec3c;
    color: #2d3918;
}

.scenario-modal-footer .btn-primary:hover {
    background: #c9f55a;
}

/* ========================================
   SINGLE-CHAT TOGGLE SWITCH
   ======================================== */
.single-chat-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 5px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    margin: 2px 4px;
    transition: border-color var(--transition), background var(--transition);
}

.single-chat-toggle:hover {
    border-color: var(--accent-light);
    background: var(--bg-hover);
}

.single-chat-toggle input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--border);
    border-radius: 12px;
    transition: background 0.25s ease;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.25s ease;
}

.single-chat-toggle input:checked ~ .toggle-slider {
    background: var(--accent-light);
}

.single-chat-toggle input:checked ~ .toggle-slider::after {
    transform: translateX(16px);
}

/* When active, highlight label text */
#singleChatToggle:checked ~ .toggle-slider {
    background: var(--accent-light);
}

.single-chat-toggle:has(input:checked) {
    border-color: var(--accent-light);
    color: var(--accent-light);
    background: var(--accent-bg);
}
