/*
 * Shoutbox — komplettes Widget-Styling.
 *
 * Lag frueher als ~300-Zeilen-String-Verkettung in shoutbox_widget.js und wurde
 * zur Laufzeit als <style> in den <head> gehaengt. Jetzt ein echtes Stylesheet,
 * das der Renderer als <link> einbindet (rendering/shoutbox/shoutbox_renderer.py)
 * und der Browser 30 Tage cacht — genau wie minigames/static/lemmings.css.
 *
 * Alle Regeln sind auf #gwn-shoutbox / #sb-tab / .sb-* gescoped: das Widget
 * haengt auf JEDER Seite und darf nichts vom Seitenlayout anfassen.
 */

/* --- Rahmen: Box, minimierter Reiter, Kopfzeile ------------------------- */

#gwn-shoutbox {
    position: fixed; bottom: 20px; right: 20px; width: 340px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px; z-index: 99999; border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3); overflow: hidden;
    display: flex; flex-direction: column; background: #fff;
}
#sb-tab {
    display: none; position: fixed; bottom: 0; right: 20px;
    background: #1C4283; color: #fff; padding: 6px 16px;
    border-radius: 8px 8px 0 0; cursor: pointer; z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px; font-weight: 600; user-select: none;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
}
#sb-tab:hover { background: #15356a; }
#sb-header {
    background: #1C4283; color: #fff; padding: 8px 12px;
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; user-select: none;
}
#sb-header span { font-weight: 600; font-size: 14px; }
#sb-header button {
    background: none; border: none; color: #fff; cursor: pointer;
    font-size: 14px; font-weight: bold; padding: 0 4px; line-height: 1;
    opacity: 0.8;
}
#sb-header button:hover { opacity: 1; }

/* --- Wer-ist-online-Popover -------------------------------------------- */

#sb-online:hover { opacity: 1; }
#sb-online-pop {
    position: absolute; top: 38px; right: 8px; z-index: 100000;
    background: #fff; color: #163a74; border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    max-height: 220px; overflow-y: auto; min-width: 140px; max-width: 260px;
    padding: 4px 0; font-size: 13px;
}
#sb-online-pop .sb-online-title {
    padding: 4px 12px; font-weight: 600; color: #1C4283;
    border-bottom: 1px solid #e3e8f0; margin-bottom: 2px;
}
#sb-online-pop .sb-online-user { padding: 4px 12px; white-space: nowrap; }
#sb-online-pop .sb-online-empty { padding: 6px 12px; opacity: 0.7; }

/* --- Kanalreiter und Panels -------------------------------------------- */

#sb-tabs {
    display: flex; background: #163a74; border-bottom: 1px solid #1C4283;
}
.sb-tab-btn {
    flex: 1; padding: 6px 10px; border: none; cursor: pointer;
    font-size: 12px; font-weight: 600; font-family: inherit;
    background: #163a74; color: rgba(255,255,255,0.6);
    transition: background 0.15s, color 0.15s;
}
.sb-tab-btn:hover { background: #1a4080; color: rgba(255,255,255,0.85); }
.sb-tab-active { background: #1C4283; color: #fff; }
#sb-body {
    display: flex; flex-direction: column; height: 300px;
}
#sb-panels { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.sb-channel-panel { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.sb-messages {
    flex: 1; overflow-y: auto; padding: 8px; background: #f5f7fa;
}

/* --- Nachrichtenzeile --------------------------------------------------- */

/* line-height fix (nicht 1.4): der Inline-Avatar darf die Zeilenbox
   nicht aufziehen — sonst passen weniger Nachrichten in die 300px-Box. */
.sb-msg {
    margin-bottom: 6px; line-height: 18px; word-wrap: break-word;
}
.sb-avatar {
    display: inline-block; width: 14px; height: 14px; border-radius: 50%;
    vertical-align: middle; margin-right: 4px;
}
img.sb-avatar { object-fit: cover; }
.sb-avatar--default {
    font-size: 9px; line-height: 14px; text-align: center;
    font-weight: 700; overflow: hidden;
}
.sb-msg .sb-user {
    font-weight: 600; color: #1C4283; margin-right: 4px;
}
a.sb-user { text-decoration: none; }
a.sb-user:hover { text-decoration: underline; }
.sb-msg .sb-user-clickable { cursor: pointer; }
.sb-msg .sb-user-clickable:hover { text-decoration: underline; }
.sb-msg .sb-time {
    font-size: 11px; color: #999; margin-right: 4px;
}
.sb-msg .sb-text { color: #333; }
.sb-msg .sb-text a { color: #1C4283; text-decoration: underline; word-break: break-all; }
.sb-msg .sb-text a:hover { color: #0d2a5c; }
.sb-intro {
    padding: 10px; background: #e8edf4; border-bottom: 1px solid #ddd;
    font-size: 12px; color: #444; line-height: 1.5; flex-shrink: 0;
}
.sb-intro b { color: #1C4283; }
.sb-error { color: #c00; font-style: italic; padding: 4px 8px; font-size: 12px; }

/* --- Antwortleiste und Eingabe ----------------------------------------- */

#sb-reply-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 10px; background: #e8edf4; border-top: 1px solid #ddd;
    font-size: 12px; color: #1C4283;
}
#sb-reply-bar button {
    background: none; border: none; cursor: pointer; font-size: 16px;
    color: #999; padding: 0 2px; line-height: 1;
}
#sb-reply-bar button:hover { color: #333; }
#sb-input-area {
    display: flex; border-top: 1px solid #ddd; background: #fff;
}
#sb-input {
    flex: 1; border: none; padding: 8px 10px; font-size: 13px;
    outline: none; font-family: inherit;
}
#sb-send {
    background: #1C4283; color: #fff; border: none; padding: 8px 14px;
    cursor: pointer; font-size: 14px;
}
#sb-send:hover { background: #15356a; }
#sb-arrow {
    display: inline-block; width: 0; height: 0;
    border-top: 6px solid transparent; border-bottom: 6px solid transparent;
    border-left: 8px solid #fff;
}

/* --- Minimiert, Badges, Loeschknopf ------------------------------------ */

#gwn-shoutbox.sb-closed { display: none; }
#gwn-shoutbox.sb-closed + #sb-tab { display: block; }
.sb-badge {
    display: inline-block; min-width: 16px; height: 16px;
    background: #e53e3e; color: #fff; font-size: 10px; font-weight: 700;
    line-height: 16px; text-align: center; border-radius: 8px;
    padding: 0 4px; margin-left: 4px; vertical-align: middle;
}
#sb-tab .sb-badge {
    position: absolute; top: -8px; right: -8px;
}
.sb-del {
    background: none; border: none; color: #ccc; cursor: pointer;
    font-size: 14px; padding: 0 0 0 6px; line-height: 1;
    float: right; opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}
.sb-msg:hover .sb-del { opacity: 1; }
.sb-del:hover { color: #c00; }

@media (max-width: 480px) {
    #gwn-shoutbox { width: calc(100% - 20px); right: 10px; bottom: 10px; }
    #sb-tab { right: 10px; }
}

/* --- Staff-Sessionliste und Unterhaltungsansicht (Hilfe-Chat) ---------- */

.sb-session-list {
    flex: 1; overflow-y: auto; background: #f5f7fa;
}
.sb-session-row {
    display: flex; flex-direction: column; padding: 10px 12px;
    border-bottom: 1px solid #e2e6ea; cursor: pointer;
    position: relative; transition: background 0.15s;
}
.sb-session-row:hover { background: #e8edf4; }
.sb-session-unread { background: #eef3ff; }
.sb-session-unread .sb-session-name { font-weight: 700; }
.sb-session-info {
    display: flex; justify-content: space-between; align-items: center;
}
.sb-session-name { font-weight: 600; color: #1C4283; font-size: 13px; }
.sb-session-time { font-size: 11px; color: #999; }
.sb-session-preview {
    font-size: 12px; color: #666; margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 280px;
}
.sb-session-close {
    position: absolute; top: 8px; right: 8px;
    background: none; border: none; cursor: pointer;
    font-size: 16px; color: #ccc; opacity: 0; transition: opacity 0.15s, color 0.15s;
    line-height: 1; padding: 0;
}
.sb-session-row:hover .sb-session-close { opacity: 1; }
.sb-session-close:hover { color: #c00; }
.sb-session-empty {
    padding: 20px; text-align: center; color: #999; font-size: 13px;
}
.sb-conversation { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.sb-conv-header {
    display: flex; align-items: center; padding: 6px 10px;
    background: #e8edf4; border-bottom: 1px solid #ddd; flex-shrink: 0;
}
.sb-back-btn {
    background: none; border: none; cursor: pointer;
    font-size: 18px; color: #1C4283; padding: 0 8px 0 0; line-height: 1;
}
.sb-back-btn:hover { color: #15356a; }
.sb-conv-title { flex: 1; font-weight: 600; color: #1C4283; font-size: 13px; }
.sb-dismiss-conv {
    background: none; border: none; cursor: pointer;
    font-size: 16px; color: #999; padding: 0 2px; line-height: 1;
}
.sb-dismiss-conv:hover { color: #c00; }
.sb-invite-btn {
    background: #9CC42F; color: #fff; border: none; cursor: pointer;
    font-size: 11px; font-weight: 700; border-radius: 5px;
    padding: 3px 8px; margin-right: 6px; font-family: inherit;
}
.sb-invite-btn:hover { background: #89ae28; }

/* --- Systemzeilen ------------------------------------------------------- */

#sb-closed-notice {
    padding: 8px 10px; text-align: center; color: #888;
    font-size: 12px; border-top: 1px solid #ddd; background: #f5f7fa;
}
.sb-server-msg {
    text-align: center; color: #888; font-size: 12px;
    font-style: italic; padding: 4px 8px; margin: 4px 0;
}
/* Ignorierter Absender (Issue #109): nur eine unscheinbare Notiz,
   den Text schickt der Server erst gar nicht mit. */
.sb-ignored-msg {
    color: #aaa; font-size: 11px; font-style: italic;
    padding: 2px 8px;
}

/* --- Oeffnungs-Animation (18 Uhr) -------------------------------------- */

@keyframes sb-overlay-in {
    0% { opacity: 0; }
    20% { opacity: 1; }
    75% { opacity: 1; }
    100% { opacity: 0; }
}
@keyframes sb-text-in {
    0% { opacity: 0; transform: translateY(10px); }
    20% { opacity: 1; transform: translateY(0); }
    75% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-5px); }
}
@keyframes sb-line-reveal {
    0% { width: 0; opacity: 0; }
    25% { opacity: 1; }
    50% { width: 220px; }
    75% { width: 220px; opacity: 1; }
    100% { width: 0; opacity: 0; }
}
.sb-open-overlay {
    position: fixed; inset: 0; z-index: 999999;
    display: flex; align-items: center; justify-content: center; flex-direction: column;
    background: rgba(28,66,131,0.85);
    pointer-events: none;
    animation: sb-overlay-in 3s ease-out forwards;
}
.sb-open-title {
    font-family: inherit;
    color: #fff;
    font-size: 32px; font-weight: 700; letter-spacing: 1px;
    text-align: center; line-height: 1.4;
    text-shadow: 0 1px 4px rgba(0,0,0,0.3);
    animation: sb-text-in 3s ease-out forwards;
}
.sb-open-line {
    height: 2px; margin-top: 14px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7), transparent);
    animation: sb-line-reveal 3s ease-out forwards;
}

/* --- Paysafecard-Adminpanel -------------------------------------------- */

.sb-psc-list {
    flex: 1; overflow-y: auto; background: #f5f7fa; padding: 6px;
}
.sb-psc-empty { padding: 20px; text-align: center; color: #999; font-size: 13px; }
.sb-psc-row {
    padding: 10px; background: #fff; border: 1px solid #e2e6ea;
    border-radius: 6px; margin-bottom: 8px; font-size: 12px;
}
.sb-psc-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 6px; font-weight: 600; color: #1C4283;
}
.sb-psc-anon { color: #e67e22; font-size: 11px; font-weight: 700; }
.sb-psc-kind {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .5px; padding: 2px 6px; border-radius: 3px;
    background: #1C4283; color: #fff; margin-left: 6px;
}
.sb-psc-kind-amazon { background: #ff9900; color: #232f3e; }
.sb-psc-pin-row {
    display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.sb-psc-pin-code {
    flex: 1; font-family: 'Consolas','Menlo',monospace; font-size: 13px;
    font-weight: 700; letter-spacing: 1px; padding: 6px 8px;
    background: #eef3ff; border-radius: 4px; word-break: break-all;
    cursor: pointer; user-select: all;
}
.sb-psc-pin-code:hover { background: #dee7f7; }
.sb-psc-copy {
    background: #1C4283; color: #fff; border: none; padding: 4px 10px;
    border-radius: 4px; font-size: 11px; cursor: pointer; font-weight: 600;
}
.sb-psc-copy:hover { background: #15356a; }
.sb-psc-amount-row {
    display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
    font-size: 12px;
}
.sb-psc-actual {
    width: 70px; padding: 4px 6px; border: 1px solid #ccc;
    border-radius: 4px; font-size: 12px; font-family: inherit;
}
.sb-psc-actions { display: flex; gap: 6px; }
.sb-psc-btn {
    flex: 1; padding: 6px 10px; border: none; border-radius: 4px;
    font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.sb-psc-confirm { background: #2e7d32; color: #fff; }
.sb-psc-confirm:hover { background: #1b5e20; }
.sb-psc-reject { background: #c62828; color: #fff; }
.sb-psc-reject:hover { background: #8e0000; }
.sb-psc-btn:disabled { opacity: .5; cursor: not-allowed; }
