/* ===== GunnerUp Chat Room — modern UI v2 ===== */
.gu-chat {
    display: flex;
    align-items: stretch;
    gap: 0;
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 16px;
    color: #111827 !important;
    --gu-chat-bg: #fff;
    --gu-chat-border: #e5e7eb;
    --gu-chat-muted: #6b7280;
    --gu-chat-accent: #111827;
    --gu-sidebar-w: 280px;
}

/* Default text color inside the chat scope so themes can't repaint everything */
.gu-chat,
.gu-chat * {
    box-sizing: border-box;
}
.gu-chat p,
.gu-chat span,
.gu-chat strong,
.gu-chat time,
.gu-chat h2,
.gu-chat h3,
.gu-chat label {
    color: inherit;
}

.gu-chat__main {
    display: flex;
    flex-direction: column;
    /* Pin a viewport-aware ceiling so the room doesn't grow with the
       conversation. The messages area below absorbs the remaining space and
       scrolls internally. */
    height: min(720px, calc(100vh - 120px));
    min-height: 480px;
    background: var(--gu-chat-bg);
    border: 1px solid var(--gu-chat-border);
    border-radius: 16px;
    padding: 20px 20px 16px;
    flex: 1 1 auto;
    min-width: 320px;
    overflow: hidden;
}

/* ===== Resizable splitter ===== */
.gu-chat__resizer {
    flex: 0 0 8px;
    margin: 0 6px;
    background: transparent;
    cursor: col-resize;
    position: relative;
    border-radius: 4px;
    align-self: stretch;
    transition: background 0.15s;
}
.gu-chat__resizer::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 36px;
    background: #d1d5db;
    border-radius: 2px;
    transition: background 0.15s, height 0.15s;
}
.gu-chat__resizer:hover { background: rgba(17, 24, 39, 0.04); }
.gu-chat__resizer:hover::before,
.gu-chat__resizer.is-dragging::before {
    background: #111827;
    height: 60px;
}
.gu-chat.is-resizing,
.gu-chat.is-resizing * {
    cursor: col-resize !important;
    user-select: none !important;
}

/* ===== Header ===== */
.gu-chat__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid #f3f4f6;
}
.gu-chat__header-left { display: flex; gap: 12px; align-items: flex-start; flex: 1; min-width: 0; }
.gu-chat__category {
    color: #fff !important;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 2px;
}
.gu-chat__title-block { min-width: 0; }
.gu-chat__title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
    color: #111827 !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.gu-chat__description {
    margin: 4px 0 0;
    color: var(--gu-chat-muted) !important;
    font-size: 13px;
    line-height: 1.4;
}

/* ===== Header action buttons (Leave / Close) ===== */
.gu-chat__header-actions { display: flex; gap: 8px; flex-shrink: 0; }
.gu-chat__action-btn {
    background: #fff !important;
    border: 1px solid var(--gu-chat-border) !important;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #374151 !important;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    text-shadow: none;
    line-height: 1.4;
}
.gu-chat__action-btn:hover { background: #f9fafb !important; border-color: #d1d5db !important; color: #111827 !important; }
.gu-chat__action-btn--danger { color: #dc2626 !important; border-color: #fecaca !important; }
.gu-chat__action-btn--danger:hover { background: #fef2f2 !important; border-color: #fca5a5 !important; color: #b91c1c !important; }

/* ===== Messages ===== */
.gu-chat__messages {
    flex: 1 1 0;
    /* min-height: 0 is required so the flex child can shrink and let
       overflow-y kick in instead of forcing the parent to grow. */
    min-height: 0;
    overflow-y: auto;
    padding: 8px 4px;
    scroll-behavior: smooth;
}
.gu-msg { padding: 6px 4px; margin-bottom: 10px; display: flex; flex-direction: column; }
.gu-msg__author { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 4px; }
.gu-msg__avatar { width: 26px; height: 26px; border-radius: 50%; }
.gu-msg__name { font-weight: 600; font-size: 12px; color: #111827 !important; cursor: pointer; }
.gu-msg__name:hover { text-decoration: underline; }
.gu-msg__time { color: #9ca3af !important; font-size: 11px; }
.gu-msg__body {
    font-size: 14px;
    line-height: 1.5;
    color: #1f2937 !important;
    word-wrap: break-word;
    padding: 9px 14px;
    border-radius: 16px;
    max-width: 70%;
    display: inline-block;
}

/* Bubble — mine (right) */
.gu-msg--mine { align-items: flex-end; }
.gu-msg--mine .gu-msg__author { flex-direction: row-reverse; }
.gu-msg--mine .gu-msg__body {
    background: #111827 !important;
    color: #fff !important;
    border-radius: 16px 16px 4px 16px;
}

/* Bubble — theirs (left) */
.gu-msg--theirs { align-items: flex-start; }
.gu-msg--theirs .gu-msg__body {
    background: #f3f4f6 !important;
    color: #1f2937 !important;
    border-radius: 16px 16px 16px 4px;
}

/* Attachment bubble keeps image-only on a clean background */
.gu-msg__body img { display: block; }
.gu-msg--mine .gu-msg__body img,
.gu-msg--theirs .gu-msg__body img { max-width: 100%; }

.gu-msg--system { padding: 4px 0; }
.gu-msg__system {
    text-align: center;
    color: #9ca3af !important;
    font-size: 12px;
    padding: 4px 8px;
    font-style: italic;
}

.gu-msg--command_result {
    background: #f9fafb;
    border-left: 3px solid #6366f1;
    padding-left: 10px;
    border-radius: 6px;
}
.gu-msg__cmd {
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    color: #6366f1 !important;
    font-size: 12px;
    font-weight: 600;
}
.gu-msg__command-title { font-weight: 600; margin-bottom: 6px; font-size: 14px; color: #111827 !important; }
.gu-msg__command-body {
    background: #fff;
    border: 1px solid #f3f4f6;
    padding: 10px 12px;
    border-radius: 8px;
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 12.5px;
    line-height: 1.5;
    white-space: pre-wrap;
    margin: 4px 0 0;
    color: #1f2937 !important;
    overflow-x: auto;
}
.gu-msg__choices { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* Fixtures / Results grid inside command result */
.gu-msg__fixtures {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}
.gu-msg__fixture {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 12px;
}
.gu-msg__fixture-main { min-width: 0; flex: 1; }
.gu-msg__fixture-teams {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #111827 !important;
    flex-wrap: wrap;
}
.gu-msg__fixture-meta {
    font-size: 11px;
    color: #6b7280 !important;
    margin-top: 2px;
}
.gu-msg__fixture-side { text-align: right; flex-shrink: 0; }
.gu-msg__fixture-score {
    font-size: 15px;
    font-weight: 700;
    color: #111827 !important;
}

/* News cards inside command result */
.gu-msg__news {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}
.gu-msg__news-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px;
    text-decoration: none;
    color: inherit !important;
    transition: background 0.1s, border-color 0.1s, transform 0.1s;
}
.gu-msg__news-item:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    transform: translateY(-1px);
}
.gu-msg__news-thumb {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    background-color: #f3f4f6;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    border: 1px solid #e5e7eb;
}
.gu-msg__news-thumb--empty {
    background-image: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
}
.gu-msg__news-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}
.gu-msg__news-title {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.35;
    color: #111827 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.gu-msg__news-date {
    font-size: 11px;
    color: #6b7280 !important;
}

/* ===== Tone warning ===== */
.gu-chat__tone-warning[hidden] { display: none !important; }
.gu-chat__tone-warning {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 10px;
    padding: 12px 14px;
    margin: 12px 0;
}
.gu-chat__tone-warning p { margin: 0 0 8px; color: #92400e !important; font-size: 13px; }
.gu-chat__tone-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ===== Composer wrapper + private command preview ===== */
.gu-chat__composer-wrap { position: relative; margin-top: 12px; }

/* Slash autocomplete panel (typing) */
.gu-chat__cmd-panel {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--gu-chat-border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    max-height: 280px;
    overflow-y: auto;
    z-index: 20;
}
.gu-chat__cmd-panel[hidden] { display: none !important; }
.gu-chat__cmd-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f9fafb;
    transition: background 0.1s;
}
.gu-chat__cmd-item:last-child { border-bottom: 0; }
.gu-chat__cmd-item:hover,
.gu-chat__cmd-item.is-active { background: #f3f4f6; }
.gu-chat__cmd-item-name {
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 13px;
    font-weight: 600;
    color: #111827 !important;
}
.gu-chat__cmd-item-desc { font-size: 12px; color: var(--gu-chat-muted) !important; }

/* Private preview panel (interactive command picker) — only the invoker sees this */
.gu-chat__preview-panel {
    position: relative;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 16px 12px;
    margin-bottom: 8px;
}
.gu-chat__preview-panel[hidden] { display: none !important; }
.gu-chat__preview-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #64748b !important;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 600;
    margin-bottom: 8px;
}
.gu-chat__preview-hint::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6366f1;
}
.gu-chat__preview-title {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 600;
    color: #0f172a !important;
}
.gu-chat__preview-body {
    font-size: 13px;
    color: #475569 !important;
    margin: 0 0 10px;
    line-height: 1.5;
}
.gu-chat__preview-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.gu-chat__preview-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: 0;
    color: #94a3b8 !important;
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    font-size: 16px;
    line-height: 1;
    padding: 0;
}
.gu-chat__preview-close:hover { background: #e2e8f0; color: #334155 !important; }

/* Attachment preview — hidden by default, displayed during upload */
.gu-chat__attachment-preview[hidden] { display: none !important; }
.gu-chat__attachment-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f9fafb;
    border: 1px solid var(--gu-chat-border);
    border-radius: 10px;
    margin-bottom: 8px;
    font-size: 13px;
    color: #374151 !important;
}
.gu-chat__attachment-preview img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
}

/* ===== Composer (input row) ===== */
.gu-chat__composer {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--gu-chat-border);
    border-radius: 14px;
    padding: 6px 6px 6px 10px;
    transition: border-color 0.15s, box-shadow 0.15s;
    min-width: 0;
}
.gu-chat__composer:focus-within {
    border-color: #9ca3af;
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.04);
}

.gu-chat__icon-btn {
    background: transparent !important;
    border: 0 !important;
    color: #4b5563 !important;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    padding: 0;
}
.gu-chat__icon-btn:hover { background: #e5e7eb !important; color: #111827 !important; }
.gu-chat__icon-btn svg {
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    flex: 0 0 auto !important;
    stroke: #4b5563 !important;
    fill: none !important;
    display: block !important;
    pointer-events: none;
}
.gu-chat__icon-btn:hover svg { stroke: #111827 !important; }

/* Textarea — explicit single-row height; JS auto-grows when content exceeds */
.gu-chat__input {
    flex: 1 1 0;
    min-width: 0;
    border: 0 !important;
    outline: none !important;
    background: transparent !important;
    font-family: inherit !important;
    font-size: 15px;
    line-height: 1.4 !important;
    color: #111827 !important;
    resize: none !important;
    height: 36px;
    max-height: 200px;
    padding: 8px 4px;
    overflow-y: hidden;
    box-sizing: border-box;
    box-shadow: none !important;
    white-space: pre-wrap;
}
.gu-chat__input::placeholder { color: #9ca3af !important; opacity: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Send button — black square */
.gu-chat__send-btn {
    background: #111827 !important;
    border: 0 !important;
    color: #fff !important;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
    padding: 0;
}
.gu-chat__send-btn:hover { background: #1f2937 !important; }
.gu-chat__send-btn:active { transform: scale(0.95); }
.gu-chat__send-btn:disabled { background: #e5e7eb !important; color: #9ca3af !important; cursor: not-allowed; }
.gu-chat__send-btn svg {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    flex: 0 0 auto !important;
    stroke: #fff !important;
    fill: none !important;
    display: block !important;
    pointer-events: none;
}
.gu-chat__send-btn:disabled svg { stroke: #9ca3af !important; }

/* ===== Buttons ===== */
.gu-btn {
    padding: 7px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}
.gu-btn--primary { background: #111827 !important; color: #fff !important; border-color: #111827 !important; }
.gu-btn--primary:hover { background: #1f2937 !important; }
.gu-btn--ghost { background: #fff !important; border-color: var(--gu-chat-border) !important; color: #374151 !important; }
.gu-btn--ghost:hover { background: #f9fafb !important; }
.gu-btn--choice {
    background: #fff !important;
    border: 1px solid #d1d5db !important;
    color: #374151 !important;
    font-size: 13px;
    padding: 6px 12px;
}
.gu-btn--choice:hover { background: #f3f4f6 !important; color: #111827 !important; }
.gu-btn--choice:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Sidebar ===== */
.gu-chat__sidebar {
    background: #fff;
    border: 1px solid var(--gu-chat-border);
    border-radius: 16px;
    padding: 16px;
    flex: 0 0 var(--gu-sidebar-w);
    min-width: 200px;
    max-width: 480px;
    /* Match the main panel height — the sidebar grows with chat__main and
       scrolls internally if Tips + participants overflow. */
    height: min(720px, calc(100vh - 120px));
    min-height: 480px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.gu-chat__sidebar-title {
    font-size: 12px;
    margin: 0 0 12px;
    color: #6b7280 !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 700;
}
.gu-chat__count {
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    color: #374151 !important;
}
.gu-chat__participants { list-style: none; padding: 0; margin: 0; }
.gu-chat__participant {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    color: #374151 !important;
}
.gu-chat__participant[data-status="left"] { display: none; }
.gu-chat__status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.gu-chat__status-dot--active { background: #10b981; }
.gu-chat__status-dot--away   { background: #f59e0b; }
.gu-chat__status-dot--left   { background: #d1d5db; }
.gu-chat__role {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 6px;
    background: #fef3c7;
    color: #92400e !important;
    font-weight: 600;
    margin-left: auto;
}

/* ===== Sidebar — Tips block (collapsible slash command reference) ===== */
.gu-chat__sidebar-block { display: block; }

.gu-chat__tips {
    background: #f9fafb;
    border: 1px solid var(--gu-chat-border);
    border-radius: 12px;
    padding: 10px 12px;
    flex-shrink: 0;
}
.gu-chat__tips[open] { background: #fff; }

.gu-chat__tips summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #374151 !important;
    user-select: none;
    padding: 2px 0;
}
.gu-chat__tips summary::-webkit-details-marker { display: none; }
.gu-chat__tips summary::after {
    content: '+';
    margin-left: auto;
    font-size: 16px;
    font-weight: 400;
    color: #6b7280 !important;
    transition: transform 0.15s;
    line-height: 1;
}
.gu-chat__tips[open] summary::after {
    content: '−';
}
.gu-chat__tips-icon { font-size: 14px; }
.gu-chat__tips-label { font-size: 12px; }

.gu-chat__tips-body {
    padding-top: 10px;
    margin-top: 10px;
    border-top: 1px solid #f3f4f6;
}
.gu-chat__tips-hint {
    margin: 0 0 8px;
    font-size: 11px;
    color: #6b7280 !important;
    line-height: 1.5;
}
.gu-chat__tips-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.gu-chat__tips-list li {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.gu-chat__tips-cmd {
    background: #f3f4f6 !important;
    border: 0 !important;
    color: #6366f1 !important;
    font-family: 'SF Mono', 'Menlo', monospace !important;
    font-size: 12px !important;
    font-weight: 600;
    padding: 4px 8px !important;
    border-radius: 6px;
    align-self: flex-start;
    cursor: pointer;
    transition: background 0.1s;
}
.gu-chat__tips-cmd:hover {
    background: #e0e7ff !important;
    color: #4338ca !important;
}
.gu-chat__tips-desc {
    font-size: 11px;
    color: #6b7280 !important;
    padding-left: 2px;
    line-height: 1.4;
}

.gu-chat__login-cta { text-align: center; padding: 12px; margin-top: 12px; }
.gunnerup-error {
    color: #b91c1c !important;
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
}

@media (max-width: 900px) {
    .gu-chat { flex-direction: column; }
    .gu-chat__resizer { display: none; }
    .gu-chat__main { height: 560px; min-height: 0; }
    .gu-chat__sidebar {
        flex: 0 0 auto;
        max-width: none;
        position: static;
        margin-top: 12px;
        height: auto;
        max-height: 320px;
        min-height: 0;
    }
}

@media (max-width: 540px) {
    .gu-chat { padding: 0 8px; margin: 12px auto; }
    .gu-chat__main { padding: 14px 14px 12px; height: 480px; }
    .gu-chat__title { font-size: 16px; }
    .gu-chat__action-btn { padding: 5px 10px; font-size: 12px; }
}
