/* css/assistant.css
 * Flytande lila Assistant-avatar (höger sida, draggable vertikalt).
 * Klick → expanderar chat-/feedback-panel. Steg 1 = bugg/feedback-rapport
 * med skärmdump, framtid = AI-assistent + steg-by-steg-guidning.
 */

#sgAssistantHost {
    position: fixed;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2147483647; /* Jim 2026-06-04: alltid över alla modaler */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    user-select: none;
}

#sgAssistantHost.is-dragging { transition: none !important; }

/* ---- Avatar (knappen) ---- */
#sgAssistantAvatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #b388ff 0%, #7c3aed 55%, #5b21b6 100%);
    box-shadow: 0 8px 24px rgba(124, 58, 237, .45), 0 2px 6px rgba(0, 0, 0, .25);
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    border: 2px solid rgba(255, 255, 255, .85);
    transition: transform .18s ease, box-shadow .18s ease;
    position: relative;
}
#sgAssistantAvatar:hover {
    transform: scale(1.06);
    box-shadow: 0 10px 28px rgba(124, 58, 237, .55), 0 3px 8px rgba(0, 0, 0, .3);
}
#sgAssistantAvatar:active { cursor: grabbing; }

#sgAssistantAvatar svg {
    width: 30px;
    height: 30px;
    pointer-events: none;
}

#sgAssistantAvatar .sg-avatar-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(124, 58, 237, .55);
    animation: sgPulse 2.4s ease-out infinite;
    pointer-events: none;
}
@keyframes sgPulse {
    0%   { transform: scale(.9); opacity: .8; }
    70%  { transform: scale(1.35); opacity: 0; }
    100% { transform: scale(1.35); opacity: 0; }
}

/* ---- Panel ---- */
#sgAssistantPanel {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%) scale(.96);
    width: 360px;
    max-width: calc(100vw - 96px);
    max-height: 78vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(31, 11, 61, .35), 0 4px 12px rgba(0, 0, 0, .15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e9deff;
    opacity: 0;
    transition: opacity .18s ease, transform .18s ease;
}
#sgAssistantHost.is-open #sgAssistantPanel {
    display: flex;
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

/* När avataren ligger högt upp, lägg panelen under istället */
#sgAssistantHost[data-vpos="top"] #sgAssistantPanel {
    top: 70px;
    transform: scale(.96);
}
#sgAssistantHost[data-vpos="top"].is-open #sgAssistantPanel {
    transform: scale(1);
}
#sgAssistantHost[data-vpos="bottom"] #sgAssistantPanel {
    top: auto;
    bottom: 70px;
    transform: scale(.96);
}
#sgAssistantHost[data-vpos="bottom"].is-open #sgAssistantPanel {
    transform: scale(1);
}

.sg-panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
    color: #fff;
}
.sg-panel-head .sg-panel-title {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
    flex: 1;
}
.sg-panel-head .sg-panel-sub {
    font-size: 11px;
    opacity: .8;
    font-weight: 400;
    margin-top: 2px;
}
.sg-panel-close {
    background: rgba(255,255,255,.2);
    border: 0;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sg-panel-close:hover { background: rgba(255,255,255,.32); }

.sg-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 12px 0 12px;
    background: #faf6ff;
    border-bottom: 1px solid #efe7ff;
}
.sg-tab {
    flex: 1;
    background: transparent;
    border: 0;
    padding: 8px 6px;
    font-size: 12px;
    font-weight: 600;
    color: #6b5b8a;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    border-bottom: 2px solid transparent;
}
.sg-tab.is-active {
    color: #5b21b6;
    border-bottom-color: #7c3aed;
    background: #fff;
}
.sg-tab[disabled] {
    opacity: .55;
    cursor: not-allowed;
}

.sg-panel-body {
    padding: 14px 16px;
    overflow-y: auto;
    flex: 1;
    background: #fff;
}

.sg-context {
    font-size: 11px;
    color: #7a6c95;
    background: #faf6ff;
    border: 1px solid #efe7ff;
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 12px;
    line-height: 1.4;
    word-break: break-all;
}
.sg-context strong { color: #5b21b6; font-weight: 600; }

.sg-field { margin-bottom: 10px; }
.sg-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #4a3768;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.sg-field input[type=text],
.sg-field textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ddd0f5;
    border-radius: 8px;
    padding: 9px 10px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    color: #2b1d4a;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.sg-field input[type=text]:focus,
.sg-field textarea:focus {
    outline: none;
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, .15);
}
.sg-field textarea { min-height: 90px; resize: vertical; }

.sg-screenshot-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}
.sg-screenshot-btn {
    flex: 1;
    background: #f3eaff;
    color: #5b21b6;
    border: 1px dashed #c4b0f5;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.sg-screenshot-btn:hover { background: #e9daff; }
.sg-screenshot-btn[disabled] { opacity: .6; cursor: progress; }

.sg-screenshot-preview {
    margin-bottom: 10px;
    border: 1px solid #efe7ff;
    border-radius: 8px;
    padding: 6px;
    background: #faf6ff;
    display: none;
    position: relative;
}
.sg-screenshot-preview.is-shown { display: block; }
.sg-screenshot-preview img {
    width: 100%;
    border-radius: 6px;
    display: block;
    cursor: zoom-in;
}
.sg-screenshot-clear {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,.6);
    color: #fff;
    border: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

.sg-submit {
    width: 100%;
    background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
    color: #fff;
    border: 0;
    padding: 11px 14px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(124,58,237,.35);
}
.sg-submit:hover { filter: brightness(1.05); }
.sg-submit[disabled] { opacity: .6; cursor: progress; }

.sg-status {
    margin-top: 10px;
    font-size: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    display: none;
}
.sg-status.is-shown { display: block; }
.sg-status.is-ok    { background: #e6fff2; color: #0f6f3d; border: 1px solid #b9ecd0; }
.sg-status.is-err   { background: #ffefef; color: #8a1f1f; border: 1px solid #f4c5c5; }

.sg-soon {
    text-align: center;
    padding: 28px 14px;
    color: #7a6c95;
}
.sg-soon-emoji { font-size: 32px; margin-bottom: 8px; }
.sg-soon-title { font-weight: 600; color: #4a3768; margin-bottom: 4px; }
.sg-soon-sub { font-size: 12px; line-height: 1.45; }

/* Mobil */
@media (max-width: 640px) {
    #sgAssistantHost { right: 12px; }
    #sgAssistantPanel {
        right: 0;
        width: calc(100vw - 24px);
    }
}


/* ==== [LAC-143] Mina ärenden ============================================== */
/* Mapp-knappen under avataren, med röd räknare för ärenden som fått nytt. */
#sgAssistantFolder {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; margin: 10px auto 0; border-radius: 50%;
    background: #fff; color: #5b21b6; border: 2px solid #d9c8ff;
    box-shadow: 0 4px 14px rgba(124, 58, 237, .25); cursor: pointer; position: relative;
    transition: transform .18s ease;
}
#sgAssistantFolder:hover { transform: scale(1.08); }
#sgAssistantFolder svg { width: 22px; height: 22px; pointer-events: none; }
.sg-folder-badge {
    position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
    line-height: 18px; text-align: center; border: 2px solid #fff; box-sizing: content-box;
}
.sg-folder-badge[hidden] { display: none; }
.sg-tab-badge {
    display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 4px; border-radius: 8px;
    background: #ef4444; color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.sg-tab-badge[hidden] { display: none; }

.sg-tickets-bar { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; }
.sg-tickets-bar select {
    flex: 1; padding: 7px 10px; border: 1px solid #e2d6ff; border-radius: 8px; background: #faf6ff;
    color: #3b2a63; font-size: 12px; font-family: inherit;
}
.sg-tickets-bar button {
    width: 32px; height: 32px; border-radius: 8px; border: 1px solid #e2d6ff; background: #fff;
    color: #5b21b6; cursor: pointer; font-size: 16px;
}
.sg-tickets-rows { display: flex; flex-direction: column; gap: 6px; }
.sg-ticket-row {
    display: flex; gap: 8px; align-items: flex-start; padding: 9px 10px; border-radius: 10px;
    border: 1px solid #efe7ff; background: #fff; cursor: pointer; text-align: left; width: 100%; font-family: inherit;
}
.sg-ticket-row:hover { background: #faf6ff; border-color: #d9c8ff; }
.sg-ticket-row.is-unread { border-color: #c4b0f5; background: #fbf8ff; }
.sg-ticket-row-main { flex: 1; min-width: 0; }
.sg-ticket-row-title { font-size: 13px; font-weight: 600; color: #1f1638; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-ticket-row.is-unread .sg-ticket-row-title { color: #4c1d95; }
.sg-ticket-row-sub { font-size: 11px; color: #8a7ea6; margin-top: 3px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sg-ticket-row-dot { width: 9px; height: 9px; border-radius: 50%; background: #ef4444; flex: none; margin-top: 5px; }
.sg-tickets-empty { font-size: 12px; color: #8a7ea6; text-align: center; padding: 22px 8px; }

.sg-status-pill {
    display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 700;
    letter-spacing: .02em; white-space: nowrap; background: #ede9fe; color: #5b21b6;
}
.sg-status-pill[data-status="inskickad"]  { background: #e5e7eb; color: #374151; }
.sg-status-pill[data-status="planerad"]   { background: #dbeafe; color: #1d4ed8; }
.sg-status-pill[data-status="arbetar"]    { background: #ffedd5; color: #c2410c; }
.sg-status-pill[data-status="pausad"]     { background: #fef3c7; color: #92400e; }
.sg-status-pill[data-status="granskas"]   { background: #ede9fe; color: #6d28d9; }
.sg-status-pill[data-status="klar"]       { background: #ccfbf1; color: #0f766e; }
.sg-status-pill[data-status="publicerad"] { background: #dcfce7; color: #15803d; }
.sg-status-pill[data-status="stangd"]     { background: #f3f4f6; color: #6b7280; }

.sg-ticket-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sg-ticket-back { border: 0; background: none; color: #5b21b6; font-size: 12px; font-weight: 600; cursor: pointer; padding: 4px 0; font-family: inherit; }
.sg-ticket-title { font-size: 14px; font-weight: 700; color: #1f1638; line-height: 1.3; }
.sg-ticket-meta { font-size: 11px; color: #8a7ea6; margin: 4px 0 10px; line-height: 1.5; word-break: break-word; }
.sg-ticket-meta a { color: #5b21b6; }
.sg-ticket-thread { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.sg-msg { max-width: 92%; padding: 8px 10px; border-radius: 12px; font-size: 12px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.sg-msg-who { font-size: 10px; font-weight: 700; margin-bottom: 2px; opacity: .8; }
.sg-msg-time { font-size: 10px; opacity: .6; margin-top: 3px; }
.sg-msg.is-user { align-self: flex-end; background: #7c3aed; color: #fff; border-bottom-right-radius: 4px; }
.sg-msg.is-trello { align-self: flex-start; background: #f3f0fa; color: #1f1638; border-bottom-left-radius: 4px; }
.sg-msg.is-system { align-self: center; background: none; color: #8a7ea6; font-size: 11px; text-align: center; padding: 2px 0; }
.sg-msg-imgs { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.sg-msg-imgs img { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid rgba(0,0,0,.1); cursor: zoom-in; background: #fff; }
.sg-ticket-reply textarea {
    width: 100%; box-sizing: border-box; min-height: 60px; resize: vertical; padding: 8px 10px;
    border: 1px solid #e2d6ff; border-radius: 8px; font-size: 12px; font-family: inherit;
}
.sg-ticket-reply textarea:focus { outline: none; border-color: #7c3aed; box-shadow: 0 0 0 3px rgba(124,58,237,.15); }
.sg-ticket-reply-row { display: flex; gap: 6px; margin-top: 6px; align-items: stretch; }
.sg-ticket-reply-row .sg-screenshot-btn { flex: none; width: auto; padding: 8px 10px; }
.sg-ticket-reply-shots { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.sg-ticket-reply-shots .sg-rs { position: relative; }
.sg-ticket-reply-shots img { width: 56px; height: 42px; object-fit: cover; border-radius: 6px; border: 1px solid #e2d6ff; }
.sg-ticket-reply-shots button { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: #ef4444; color: #fff; font-size: 11px; line-height: 18px; cursor: pointer; padding: 0; }
