/* =====================================================
   HENRIK SIDEKICK — Expandable Right Sidebar
   Ask Henrik (consumer) + Config-Henrik (admin chat + board)
   Uses Verktygsguiden theme variables from catalog.css
   ===================================================== */

/* Hidden in consumer until Henrik's role and answer quality are decided. */
.henrik-toggle-btn,
.toolbar-henrik-btn,
.henrik-sidebar {
    display: none !important;
}

/* ── Header toggle button ─────────────────────────── */

.henrik-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid var(--accent, #5b9bd5);
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.henrik-toggle-btn:hover {
    background: var(--accent, #5b9bd5);
}
.henrik-toggle-btn:hover .henrik-toggle-avatar {
    color: #fff;
}
.henrik-toggle-avatar {
    font-weight: 700;
    font-size: 16px;
    color: var(--accent, #5b9bd5);
    line-height: 1;
    transition: color 0.2s;
}
/* Active state when sidebar is open */
.henrik-toggle-btn.active {
    background: var(--accent, #5b9bd5);
}
.henrik-toggle-btn.active .henrik-toggle-avatar {
    color: #fff;
}

/* ── Sidebar Panel ────────────────────────────────── */

.henrik-sidebar {
    position: fixed;
    top: 85px;
    right: 0;
    bottom: 0;
    z-index: 180;
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg, #1a1a1a);
    border-left: 1px solid var(--border-color, #333);
    width: min(380px, calc(100vw - 16px));
    min-width: 0;
    overflow: hidden;
    box-shadow: -18px 0 42px rgba(15, 23, 42, 0.18);
    transform: translateX(100%);
    transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}
.henrik-sidebar.open {
    transform: translateX(0);
}

/* ── Sidebar Header + Tabs ────────────────────────── */

.henrik-sidebar-header {
    display: flex;
    align-items: center;
    padding: 0;
    border-bottom: 1px solid var(--border-color, #333);
    background: var(--cat-group-bg, #161616);
    flex-shrink: 0;
}

.henrik-sidebar-tabs {
    display: flex;
    flex: 1;
}

.henrik-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    border: none;
    background: transparent;
    color: var(--text-muted, #888);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    gap: 4px;
}
.henrik-tab:hover {
    color: var(--text-primary, #e0e0e0);
    background: rgba(255,255,255,0.03);
}
.henrik-tab.active {
    color: var(--accent, #5b9bd5);
    border-bottom-color: var(--accent, #5b9bd5);
}

.henrik-tab-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent, #5b9bd5);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    margin-right: 4px;
}

.henrik-close {
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted, #888);
    cursor: pointer;
    transition: color 0.15s;
    flex-shrink: 0;
}
.henrik-close:hover {
    color: var(--text-strong, #fff);
}

/* ── Tab Content ──────────────────────────────────── */

.henrik-tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.henrik-tab-content.active {
    display: flex;
}

/* ── Chat (shared between Ask + Config) ───────────── */

.henrik-chat {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

.henrik-message {
    display: flex;
    gap: 8px;
    animation: henrikFadeIn 0.2s ease-out;
}
.henrik-message-user {
    flex-direction: row-reverse;
}

.henrik-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent, #5b9bd5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 2px;
}
.henrik-avatar-admin {
    background: var(--orange, #ffcc00);
}

.henrik-message-content {
    padding: 8px 12px;
    border-radius: 10px;
    line-height: 1.45;
    font-size: 13px;
    max-width: 280px;
    word-break: break-word;
}
.henrik-message-content p { margin: 0 0 6px; }
.henrik-message-content p:last-child { margin: 0; }
.henrik-message-content h3 { margin: 0 0 4px; font-size: 14px; color: var(--text-strong, #fff); }
.henrik-message-content ul { margin: 4px 0; padding-left: 16px; }
.henrik-message-content li { margin: 2px 0; }
.henrik-message-content strong { color: var(--text-strong, #fff); }
.henrik-message-content a { color: var(--accent, #5b9bd5); }

.henrik-message-bot .henrik-message-content {
    background: var(--bg-body, #111);
    border: 1px solid var(--border-light, #2a2a2a);
    border-top-left-radius: 4px;
    color: var(--text-primary, #e0e0e0);
}
.henrik-message-user .henrik-message-content {
    background: var(--accent, #5b9bd5);
    color: #fff;
    border-top-right-radius: 4px;
}
.henrik-message-user .henrik-message-content strong { color: #fff; }
.henrik-message-user .henrik-message-content a { color: #fff; text-decoration: underline; }

/* Typing indicator */
.henrik-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px !important;
}
.henrik-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted, #888);
    animation: henrikBounce 1.2s infinite;
}
.henrik-typing span:nth-child(2) { animation-delay: 0.2s; }
.henrik-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes henrikBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}
@keyframes henrikFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Suggestions */
.henrik-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.henrik-suggestions button {
    padding: 4px 10px;
    border-radius: 14px;
    border: 1px solid var(--accent, #5b9bd5);
    background: transparent;
    color: var(--accent, #5b9bd5);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.henrik-suggestions button:hover {
    background: var(--accent, #5b9bd5);
    color: #fff;
}

/* Input bar */
.henrik-input-bar {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: var(--cat-group-bg, #161616);
    border-top: 1px solid var(--border-color, #333);
    flex-shrink: 0;
}
.henrik-input-bar input {
    flex: 1;
    padding: 8px 12px;
    border-radius: 18px;
    border: 1px solid var(--border-color, #333);
    background: var(--bg-body, #111);
    color: var(--text-primary, #e0e0e0);
    font-size: 13px;
    outline: none;
    min-width: 0;
}
.henrik-input-bar input:focus {
    border-color: var(--accent, #5b9bd5);
}
.henrik-input-bar button {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--accent, #5b9bd5);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.henrik-input-bar button:hover {
    background: var(--accent-hover, #4a8bc4);
}

/* ── Mini Pipeline Board (Config tab) ─────────────── */

.henrik-mini-board {
    flex-shrink: 0;
    border-top: 1px solid var(--border-color, #333);
    background: var(--cat-group-bg, #161616);
}

.henrik-mini-board-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    cursor: pointer;
}
.henrik-mini-board-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #888);
}
.henrik-mini-board-toggle {
    border: none;
    background: transparent;
    color: var(--text-muted, #888);
    cursor: pointer;
    padding: 2px;
    transition: transform 0.2s;
}
.henrik-mini-board-toggle.collapsed {
    transform: rotate(-90deg);
}

.henrik-mini-board-lanes {
    display: flex;
    gap: 6px;
    padding: 0 10px 10px;
    overflow: hidden;
    transition: max-height 0.25s ease, padding 0.25s ease;
    max-height: 200px;
}
.henrik-mini-board-lanes.collapsed {
    max-height: 0;
    padding-bottom: 0;
}

.henrik-mini-lane {
    flex: 1;
    min-width: 0;
}

.henrik-mini-lane-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-dim, #666);
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 4px;
}
.henrik-mini-lane-label span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    background: var(--cat-count-bg, #333);
    color: var(--cat-count-text, #999);
    font-size: 9px;
}

.henrik-mini-lane-cards {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 150px;
    overflow-y: auto;
    min-height: 30px;
    padding: 4px;
    border-radius: 6px;
    border: 1px dashed var(--border-light, #2a2a2a);
    transition: background 0.15s;
}
.henrik-mini-lane-cards.henrik-lane-dragover {
    background: rgba(91, 155, 213, 0.1);
    border-color: var(--accent, #5b9bd5);
}

.henrik-mini-card {
    padding: 4px 6px;
    border-radius: 4px;
    background: var(--bg-body, #111);
    border: 1px solid var(--border-light, #2a2a2a);
    font-size: 10px;
    color: var(--text-primary, #e0e0e0);
    cursor: grab;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
    transition: border-color 0.15s;
}
.henrik-mini-card:hover {
    border-color: var(--accent, #5b9bd5);
}
.henrik-mini-card.henrik-card-dragging {
    opacity: 0.3;
}

/* ── Scrollbar in sidebar ─────────────────────────── */

.henrik-chat::-webkit-scrollbar,
.henrik-mini-lane-cards::-webkit-scrollbar {
    width: 5px;
}
.henrik-chat::-webkit-scrollbar-track,
.henrik-mini-lane-cards::-webkit-scrollbar-track {
    background: transparent;
}
.henrik-chat::-webkit-scrollbar-thumb,
.henrik-mini-lane-cards::-webkit-scrollbar-thumb {
    background: var(--sidebar-scrollbar-thumb, #444);
    border-radius: 3px;
}

/* ── Toast ────────────────────────────────────────── */

.henrik-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 10px 20px;
    border-radius: 8px;
    background: var(--check-green, #33A952);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    z-index: 9999;
    transition: opacity 0.3s;
}
.henrik-toast-error { background: #d44; }
.henrik-toast.hidden { opacity: 0; pointer-events: none; }

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

@media (max-width: 900px) {
    .henrik-sidebar {
        top: 0;
        width: 100vw;
        max-width: 100vw;
    }

    .henrik-sidebar.open {
        z-index: 200;
    }
}
@media (min-width: 901px) and (max-width: 1200px) {
    .henrik-sidebar {
        width: 320px;
    }
}
