﻿:root {
    --joshua-width: 420px;

    --joshua-bg: #0c1117;
    --joshua-panel-bg: #121821;
    --joshua-border: rgba(255,255,255,0.06);

    --joshua-text: #e6edf3;
    --joshua-muted: #8ea2b8;

    --joshua-accent: #1f6feb;
    --joshua-accent-hover: #2f81f7;

    --joshua-user-bubble: linear-gradient(135deg, #1f6feb, #2f81f7);
    --joshua-assistant-bubble: #1a222c;

    --joshua-radius: 16px;
}

/* =========================
   Toggle button
========================= */
.joshua-toggle {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1040;

    border: none;
    border-radius: 999px;
    padding: 12px 18px;

    background: linear-gradient(135deg, #1f6feb, #2f81f7);
    color: white;
    font-weight: 600;

    box-shadow: 0 8px 25px rgba(31,111,235,0.35);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.joshua-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(31,111,235,0.5);
}

/* =========================
   Backdrop
========================= */
.joshua-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.joshua-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

/* =========================
   Panel
========================= */
.joshua-panel {
    position: fixed;
    top: 16px;
    right: 16px;
    bottom: 16px;
    width: var(--joshua-width);
    max-width: calc(100vw - 32px);
    background: linear-gradient(180deg, #121821, #0f141a);
    border: 1px solid var(--joshua-border);
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.6);
    overflow: hidden;
    display: flex;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.25s ease;
    box-shadow: 
        0 30px 80px rgba(0,0,0,0.6),
        0 0 0 1px rgba(31,111,235,0.15),
        0 0 40px rgba(31,111,235,0.08);
}

.joshua-panel.open {
    transform: translateX(0);
    opacity: 1;
}

/* =========================
   Layout
========================= */
.joshua-shell {
    display: grid;
    grid-template-rows: 70px 1fr auto;
    width: 100%;
}

/* =========================
   Header
========================= */
.joshua-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 14px 18px;

    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid var(--joshua-border);
}

.joshua-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: var(--joshua-text);
}

.joshua-subtitle {
    font-size: 0.8rem;
    color: var(--joshua-muted);
    opacity: 0.7;
}

.joshua-icon-btn {
    border: none;
    background: rgba(255,255,255,0.04);
    color: var(--joshua-text);

    width: 36px;
    height: 36px;
    border-radius: 10px;

    cursor: pointer;
    transition: background 0.15s ease;
}

.joshua-icon-btn:hover {
    background: rgba(255,255,255,0.08);
}

/* =========================
   Messages
========================= */
.joshua-messages {
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* scrollbar (nice touch) */
.joshua-messages::-webkit-scrollbar {
    width: 6px;
}
.joshua-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 999px;
}

/* message layout */
.joshua-message {
    display: flex;
}

.joshua-message.user {
    justify-content: flex-end;
}

.joshua-message.assistant {
    justify-content: flex-start;
}

/* bubbles */
.joshua-bubble {
    max-width: 80%;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 0.95rem;
    line-height: 1.45;
}

/* assistant */
.joshua-message.assistant .joshua-bubble {
    background: var(--joshua-assistant-bubble);
    color: var(--joshua-text);
    border-top-left-radius: 4px;
}

/* user */
.joshua-message.user .joshua-bubble {
    background: var(--joshua-user-bubble);
    color: white;
    border-top-right-radius: 4px;
}

/* =========================
   Input area
========================= */
.joshua-input-area {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;

    padding: 14px;
    border-top: 1px solid var(--joshua-border);
    background: rgba(255,255,255,0.02);

    align-items: center; /* istället för end */
}

.joshua-input {
    resize: none;
    border-radius: 12px;
    border: 1px solid var(--joshua-border);

    padding: 12px;
    background: #0c1117;
    color: var(--joshua-text);

    font-size: 0.95rem;
    line-height: 1.4;

    overflow-y:auto;
}

/* snyggare scrollbar */
.joshua-input::-webkit-scrollbar {
    width: 6px;
}

.joshua-input::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 999px;
}

.joshua-input:focus {
    outline: none;
    border-color: var(--joshua-accent);
    box-shadow: 0 0 0 2px rgba(31,111,235,0.25);
}

.joshua-send-btn {
    border: none;
    border-radius: 10px;

    padding: 0 16px;
    height: 44px;

    background: var(--joshua-accent);
    color: white;
    font-weight: 600;

    cursor: pointer;
    transition: background 0.15s ease;
}

.joshua-send-btn:hover {
    background: var(--joshua-accent-hover);
}

.joshua-typing::after {
    content: "...";
    animation: blink 1.2s infinite;
}

@keyframes blink {
    0% {
        opacity: 0.2
    }

    50% {
        opacity: 1
    }

    100% {
        opacity: 0.2
    }
}

.joshua-confidence {
    height: 4px;
    background: linear-gradient(90deg, #ff4d4d, #f0c400, #00c853);
}

/* =========================
   Mobile
========================= */
@media (max-width: 768px) {
    .joshua-panel {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;

        width: 100%;
        height: 100dvh;

        border-radius: 20px 20px 0 0;

        transform: translateY(100%);
    }

    .joshua-panel.open {
        transform: translateY(0);
    }
    
    .joshua-input-area {
        padding-bottom: max(14px, env(safe-area-inset-bottom));
    }
}
@media (min-width: 768px) {
    .joshua-backdrop {
        display: none;
    }
}