/* ==========================================
   Chat Switchboard — Projects Surface CSS
   ==========================================
   v0.37.16: Card grid list + detail with inline chat.
   sw-projects__ prefixed, BEM convention.
   ========================================== */

/* ── Root ────────────────────────────────── */

.sw-projects {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg, #0e0e10);
}

/* ── List View ───────────────────────────── */

.sw-projects__list {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px 40px;
    max-width: 940px;
    margin: 0 auto;
    width: 100%;
}

.sw-projects__list-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.sw-projects__list-header .sw-projects__new-btn {
    margin-left: auto;
}

.sw-projects__list-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text, #e8e8ed);
    margin: 0;
}

.sw-projects__new-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-raised, #222227);
    border: 1px solid var(--border, #2e2e35);
    border-radius: 8px;
    color: var(--text, #e8e8ed);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.sw-projects__new-btn:hover {
    background: var(--bg-hover, #2a2a30);
    border-color: var(--border-light, #3a3a42);
}

.sw-projects__search {
    width: 100%;
    padding: 10px 14px 10px 36px;
    border: 1px solid var(--border, #2e2e35);
    border-radius: 10px;
    background: var(--bg-surface, #18181b);
    color: var(--text, #e8e8ed);
    font-size: 14px;
    margin-bottom: 8px;
    outline: none;
    transition: border-color 0.15s;
}

.sw-projects__search:focus {
    border-color: var(--accent, #6c9fff);
}

.sw-projects__search-wrap {
    position: relative;
}

.sw-projects__search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3, #6b6b7b);
    font-size: 14px;
    pointer-events: none;
}

.sw-projects__sort {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-3, #6b6b7b);
}

.sw-projects__sort select {
    background: var(--bg-raised, #222227);
    border: 1px solid var(--border, #2e2e35);
    border-radius: 6px;
    color: var(--text-2, #9898a8);
    font-size: 13px;
    padding: 4px 8px;
    cursor: pointer;
}

/* ── Card Grid ───────────────────────────── */

.sw-projects__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.sw-projects__card {
    background: var(--bg-surface, #18181b);
    border: 1px solid var(--border, #2e2e35);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
    min-height: 120px;
}

.sw-projects__card:hover {
    border-color: var(--border-light, #3a3a42);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.sw-projects__card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text, #e8e8ed);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sw-projects__card-desc {
    font-size: 13px;
    color: var(--text-2, #9898a8);
    flex: 1;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    line-height: 1.5;
}

.sw-projects__card-meta {
    font-size: 12px;
    color: var(--text-3, #6b6b7b);
    margin-top: 12px;
}

.sw-projects__card-badge {
    display: inline-flex;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 4px;
    background: var(--bg-raised, #222227);
    border: 1px solid var(--border, #2e2e35);
    color: var(--text-3, #6b6b7b);
}

.sw-projects__empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-3, #6b6b7b);
    font-size: 14px;
}


/* ── Detail View ─────────────────────────── */

.sw-projects__detail {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.sw-projects__detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border, #2e2e35);
    flex-shrink: 0;
    min-height: 48px;
}

.sw-projects__back {
    font-size: 13px;
    color: var(--text-3, #6b6b7b);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s;
}

.sw-projects__back:hover {
    color: var(--text, #e8e8ed);
}

.sw-projects__detail-name {
    font-size: 17px;
    font-weight: 600;
    color: var(--text, #e8e8ed);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
}

.sw-projects__detail-name-input {
    font-size: 17px;
    font-weight: 600;
    color: var(--text, #e8e8ed);
    background: var(--bg-surface, #18181b);
    border: 1px solid var(--accent, #6c9fff);
    border-radius: 6px;
    padding: 2px 8px;
    flex: 1;
    min-width: 0;
    outline: none;
}

.sw-projects__header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.sw-projects__icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-3, #6b6b7b);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-size: 16px;
}

.sw-projects__icon-btn:hover {
    background: var(--bg-hover, #2a2a30);
    color: var(--text, #e8e8ed);
}

.sw-projects__icon-btn--active {
    color: var(--warning, #eab308);
}

/* ── Detail Body (2-column) ──────────────── */

.sw-projects__detail-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sw-projects__conversations {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sw-projects__conv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    flex-shrink: 0;
}

.sw-projects__conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 20px;
}

.sw-projects__conv-item {
    display: flex;
    flex-direction: column;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s;
}

.sw-projects__conv-item:hover {
    background: var(--bg-hover, #2a2a30);
}

.sw-projects__conv-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text, #e8e8ed);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sw-projects__conv-meta {
    font-size: 12px;
    color: var(--text-3, #6b6b7b);
    margin-top: 4px;
}

.sw-projects__conv-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-3, #6b6b7b);
    font-size: 13px;
}

/* ── Chat Embed ──────────────────────────── */

.sw-projects__chat-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.sw-projects__chat-back {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 12px;
    color: var(--text-3, #6b6b7b);
    cursor: pointer;
    border-bottom: 1px solid var(--border, #2e2e35);
    flex-shrink: 0;
    transition: color 0.15s;
}

.sw-projects__chat-back:hover {
    color: var(--text, #e8e8ed);
}

/* ── Right Sidebar ───────────────────────── */

.sw-projects__sidebar {
    width: 320px;
    flex-shrink: 0;
    border-left: 1px solid var(--border, #2e2e35);
    overflow-y: auto;
    padding: 12px 16px;
    background: var(--bg-surface, #18181b);
}

/* ── Collapsible Sections ────────────────── */

.sw-projects__section {
    margin-bottom: 4px;
}

.sw-projects__section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    cursor: pointer;
    user-select: none;
}

.sw-projects__section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2, #9898a8);
}

.sw-projects__section-count {
    font-size: 11px;
    color: var(--text-3, #6b6b7b);
    margin-left: 6px;
}

.sw-projects__section-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.sw-projects__section-add {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-3, #6b6b7b);
    cursor: pointer;
    font-size: 16px;
    transition: background 0.15s, color 0.15s;
}

.sw-projects__section-add:hover {
    background: var(--bg-hover, #2a2a30);
    color: var(--text, #e8e8ed);
}

.sw-projects__section-chevron {
    font-size: 10px;
    color: var(--text-3, #6b6b7b);
    transition: transform 0.15s;
}

.sw-projects__section-chevron--open {
    transform: rotate(90deg);
}

.sw-projects__section-body {
    padding-bottom: 8px;
}

.sw-projects__section-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border, #2e2e35);
    border-radius: 8px;
    background: var(--bg-raised, #222227);
    color: var(--text, #e8e8ed);
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    min-height: 60px;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}

.sw-projects__section-textarea:focus {
    border-color: var(--accent, #6c9fff);
}

.sw-projects__section-hint {
    font-size: 12px;
    color: var(--text-3, #6b6b7b);
    padding: 8px 0;
}

/* ── Section Items (KBs, Notes, Files) ──── */

.sw-projects__section-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text, #e8e8ed);
    transition: background 0.12s;
}

.sw-projects__section-item:hover {
    background: var(--bg-hover, #2a2a30);
}

.sw-projects__section-item-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sw-projects__section-item-meta {
    font-size: 11px;
    color: var(--text-3, #6b6b7b);
    flex-shrink: 0;
}

.sw-projects__section-item-remove {
    display: none;
    font-size: 11px;
    color: var(--danger, #ef4444);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    background: transparent;
    border: none;
    transition: background 0.15s;
}

.sw-projects__section-item:hover .sw-projects__section-item-remove {
    display: inline-flex;
}

.sw-projects__section-item-remove:hover {
    background: var(--danger-dim, rgba(239, 68, 68, 0.2));
}

/* ── File Drop Zone ──────────────────────── */

.sw-projects__dropzone {
    border: 2px dashed var(--border, #2e2e35);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: var(--text-3, #6b6b7b);
    font-size: 13px;
    transition: border-color 0.15s, background 0.15s;
    cursor: pointer;
}

.sw-projects__dropzone:hover {
    border-color: var(--border-light, #3a3a42);
}

.sw-projects__dropzone--active {
    border-color: var(--accent, #6c9fff);
    background: var(--accent-dim, rgba(108, 159, 255, 0.12));
    color: var(--text, #e8e8ed);
}

/* ── Picker Dropdown ─────────────────────── */

.sw-projects__picker {
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 10;
    width: 280px;
    margin-top: 4px;
    padding: 6px;
    border: 1px solid var(--border, #2e2e35);
    border-radius: 8px;
    background: var(--bg-raised, #222227);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    max-height: 240px;
    overflow-y: auto;
}

.sw-projects__picker-item {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text, #e8e8ed);
    cursor: pointer;
    transition: background 0.12s;
}

.sw-projects__picker-item:hover {
    background: var(--bg-hover, #2a2a30);
}

.sw-projects__picker-hint {
    padding: 8px 10px;
    font-size: 12px;
    color: var(--text-3, #6b6b7b);
}

/* ── Context Menu (... menu) ─────────────── */

.sw-projects__ctx-menu {
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 20;
    min-width: 180px;
    padding: 6px;
    border: 1px solid var(--border, #2e2e35);
    border-radius: 8px;
    background: var(--bg-raised, #222227);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.sw-projects__ctx-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text, #e8e8ed);
    cursor: pointer;
    transition: background 0.12s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.sw-projects__ctx-item:hover {
    background: var(--bg-hover, #2a2a30);
}

.sw-projects__ctx-item--danger {
    color: var(--danger, #ef4444);
}

.sw-projects__ctx-divider {
    height: 1px;
    background: var(--border, #2e2e35);
    margin: 4px 0;
}

/* ── Color Swatches (in menu) ────────────── */

.sw-projects__color-row {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
}

.sw-projects__color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s;
}

.sw-projects__color-swatch--active {
    border-color: var(--text, #e8e8ed);
}

/* ── File Browser (v0.37.17) ──────────────── */

.sw-projects__file-browser {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.sw-projects__file-actions-bar {
    display: flex;
    gap: 6px;
    padding: 4px 0 8px;
    border-bottom: 1px solid var(--border, #2e2e35);
    margin-bottom: 4px;
}

.sw-projects__file-action-btn {
    background: none;
    border: 1px solid var(--border, #2e2e35);
    color: var(--text-3, #999);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.sw-projects__file-action-btn:hover {
    color: var(--text-1, #fff);
    border-color: var(--text-3, #999);
}

.sw-projects__file-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: default;
    transition: background 0.1s;
}
.sw-projects__file-row:hover {
    background: var(--bg-3, rgba(255,255,255,0.04));
}

.sw-projects__file-chevron {
    font-size: 8px;
    cursor: pointer;
    color: var(--text-3, #999);
    transition: transform 0.15s;
    display: inline-block;
    width: 12px;
    text-align: center;
    flex-shrink: 0;
}
.sw-projects__file-chevron--open {
    transform: rotate(90deg);
}

.sw-projects__file-icon {
    flex-shrink: 0;
    font-size: 13px;
}

.sw-projects__file-name {
    flex: 1;
    font-size: 12px;
    color: var(--text-2, #ccc);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}
.sw-projects__file-name:hover {
    color: var(--text-1, #fff);
    text-decoration: underline;
}

.sw-projects__file-meta {
    font-size: 11px;
    color: var(--text-3, #999);
    flex-shrink: 0;
}

.sw-projects__file-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--danger, #ef4444);
    cursor: pointer;
    font-size: 14px;
    padding: 0 2px;
    flex-shrink: 0;
    transition: opacity 0.1s;
}
.sw-projects__file-row:hover .sw-projects__file-delete {
    opacity: 0.7;
}
.sw-projects__file-delete:hover {
    opacity: 1 !important;
}

.sw-projects__dropzone {
    margin-top: 8px;
    padding: 16px;
    border: 2px dashed var(--border, #2e2e35);
    border-radius: 8px;
    text-align: center;
    font-size: 12px;
    color: var(--text-3, #999);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.sw-projects__dropzone:hover {
    border-color: var(--text-3, #999);
    color: var(--text-2, #ccc);
}
.sw-projects__dropzone--active {
    border-color: var(--accent, #4f8cff);
    color: var(--accent, #4f8cff);
    background: rgba(79, 140, 255, 0.05);
}

/* ── Responsive ──────────────────────────── */

@media (max-width: 768px) {
    .sw-projects__grid {
        grid-template-columns: 1fr;
    }

    .sw-projects__list {
        padding: 16px;
    }

    .sw-projects__detail-body {
        flex-direction: column;
    }

    .sw-projects__sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border, #2e2e35);
        max-height: 40vh;
    }
}
