/**
 * Tower of Destiny — In-Game Chat Styles (v1.13.75)
 *
 * Matches the existing sidebar visual language:
 *   --tod-gold: #FFD700
 *   --tod-border: #2a2a2a
 *   --tod-text / --tod-text-bright
 *   background: #1a1a1a panels, #0a0a0a page
 */

/* ── Top-level Controls / Chat tab row ─────────────────────────────────────── */

.tod-top-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 0;
    flex-shrink: 0;
}

.tod-top-tab {
    flex: 1;
    position: relative;
    background: #1a1a1a;
    border: 1px solid var(--tod-border, #2a2a2a);
    border-bottom: none;
    border-radius: var(--tod-radius, 3px) var(--tod-radius, 3px) 0 0;
    color: var(--tod-text, #ccc);
    font-size: 12px;
    font-family: var(--tod-font-ui, inherit);
    font-weight: bold;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 5px 4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.tod-top-tab:hover {
    background: #2a2a2a;
    color: var(--tod-text-bright, #fff);
}

.tod-top-tab--active {
    background: var(--tod-gold, #FFD700);
    color: #000;
    border-color: var(--tod-gold, #FFD700);
}

/* Unread badge on the Chat tab */
.tod-chat-badge-count {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #00cc44;
    border-radius: 50%;
    margin-left: 5px;
    vertical-align: middle;
    box-shadow: 0 0 4px #00cc44;
    /* hide the number text — we only use the dot */
    font-size: 0;
    line-height: 0;
    padding: 0;
}

/* When the Chat tab itself is active, hide the dot (badge is cleared anyway) */
.tod-top-tab--active .tod-chat-badge-count {
    display: none;
}

/* ── Top-level panel wrappers ───────────────────────────────────────────────── */

.tod-top-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    border: 1px solid var(--tod-border, #2a2a2a);
    border-top: none;
    overflow: hidden;
}

/* Push the Controls inner panel's sub-tab bar down one line from the top-level tabs */
#tod-top-panel-controls {
    padding-top: 8px;
}

.tod-top-panel--hidden {
    display: none;
}

/* ── Chat panel ─────────────────────────────────────────────────────────────── */

.tod-chat-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #0f0f0f;
}

/* Birthday gate notice */
.tod-chat-gate {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 12px;
    text-align: center;
    color: var(--tod-text, #ccc);
    font-size: 12px;
    line-height: 1.6;
    gap: 10px;
}

.tod-chat-gate a {
    color: var(--tod-gold, #FFD700);
    text-decoration: none;
}

.tod-chat-gate a:hover {
    text-decoration: underline;
}

/* Message feed */
.tod-chat-feed {
    flex: 1;
    overflow-y: auto;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 0;
    scroll-behavior: smooth;
}

/* Scrollbar */
.tod-chat-feed::-webkit-scrollbar {
    width: 4px;
}
.tod-chat-feed::-webkit-scrollbar-track {
    background: transparent;
}
.tod-chat-feed::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 2px;
}

/* Individual message row */
/*
 * Each message row is a block. The username (.tod-chat-header) and the body
 * (.tod-chat-body) are inline-block siblings so they flow on the same line.
 * The row uses padding-left equal to the indent depth, and text-indent set to
 * a negative value of the same amount — this creates a hanging indent so that
 * wrapped lines start at the left edge (under the username), not at the
 * message-text start position.
 *
 * Layout result:
 *   Lord Quatscho  This is a very long message that wraps
 *   Lord Quatscho  around to the next line here
 */
.tod-chat-msg {
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--tod-text, #ccc);
    word-break: break-word;
    display: block;
    padding: 2px 4px;
    border-radius: 2px;
    cursor: default;
}

.tod-chat-msg:hover {
    background: rgba(255,255,255,0.04);
}

.tod-chat-msg--system {
    color: #666;
    font-style: italic;
    font-size: 11px;
    cursor: default;
}

/* Username prefix — inline so message text flows right after it */
.tod-chat-header {
    display: inline;
}

/* Username badge */
.tod-chat-badge {
    font-weight: bold;
    font-size: 11px;
}

/* Admin crown glyph sits inline before the badge */
.tod-chat-admin-crown {
    display: inline;
}

/* Body — inline so it continues on the same line as the username */
.tod-chat-body {
    display: inline;
}

/* Message text — inline */
.tod-chat-text {
    display: inline;
    word-break: break-word;
}

/* Timestamp — inline, sits after the message text */
.tod-chat-time {
    display: inline;
    font-size: 10px;
    color: #555;
    white-space: nowrap;
    margin-left: 4px;
}

/* "↓ New messages" pill */
.tod-chat-new-pill {
    display: none;
    position: absolute;
    bottom: 52px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--tod-gold, #FFD700);
    color: #000;
    font-size: 11px;
    font-weight: bold;
    padding: 3px 10px;
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0,0,0,0.6);
}

/* Input row */
.tod-chat-input-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 6px 6px;
    border-top: 1px solid var(--tod-border, #2a2a2a);
    background: #141414;
    flex-shrink: 0;
    position: relative;
}

.tod-chat-input {
    flex: 1;
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: var(--tod-radius, 3px);
    color: var(--tod-text-bright, #fff);
    font-family: var(--tod-font-ui, inherit);
    font-size: 12px;
    padding: 5px 8px;
    outline: none;
    transition: border-color 0.15s;
    min-width: 0;
}

.tod-chat-input:focus {
    border-color: var(--tod-gold, #FFD700);
}

.tod-chat-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tod-chat-send {
    background: var(--tod-gold, #FFD700);
    color: #000;
    border: none;
    border-radius: var(--tod-radius, 3px);
    font-family: var(--tod-font-ui, inherit);
    font-size: 11px;
    font-weight: bold;
    padding: 5px 8px;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.15s;
    white-space: nowrap;
}

.tod-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tod-chat-send:hover:not(:disabled) {
    opacity: 0.85;
}

/* Character counter */
.tod-chat-counter {
    position: absolute;
    bottom: 100%;
    right: 8px;
    font-size: 10px;
    color: #888;
    pointer-events: none;
    padding-bottom: 2px;
}

.tod-chat-counter--warn {
    color: #e05555;
}

/* ── Context menu (v1.14.9) — styled to match the game's visual language ──────
 */
.tod-chat-ctx-menu {
    position: fixed;
    z-index: 9999;
    background: var(--tod-bg-panel, #141414);
    border: 1px solid var(--tod-border-gold, #8B6914);
    border-radius: var(--tod-radius, 4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.85), 0 0 0 1px rgba(255,215,0,0.06);
    min-width: 190px;
    max-width: 260px;
    overflow: hidden;
    padding: 0;
    font-family: var(--tod-font-mono, "Courier New", monospace);
}
/* Menu header bar */
.tod-chat-ctx-header {
    background: var(--tod-bg, #0d0d0d);
    border-bottom: 1px solid var(--tod-border-gold, #8B6914);
    padding: 6px 12px;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--tod-gold, #FFD700);
    user-select: none;
}
/* Section separator line */
.tod-chat-ctx-sep {
    height: 1px;
    background: var(--tod-border, #2a2a2a);
    margin: 3px 0;
}
/* Section label (non-interactive) */
.tod-chat-ctx-section-label {
    font-size: 9px;
    font-weight: bold;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--tod-text-dim, #666);
    padding: 6px 12px 2px;
    pointer-events: none;
    user-select: none;
}
/* Base item */
.tod-chat-ctx-item {
    display: block;
    width: 100%;
    background: none;
    border: none;
    border-left: 2px solid transparent;
    color: var(--tod-text, #c8c8c8);
    font-family: var(--tod-font-mono, "Courier New", monospace);
    font-size: 12px;
    padding: 7px 12px;
    text-align: left;
    cursor: pointer;
    transition: background var(--tod-transition, 0.15s ease),
                color var(--tod-transition, 0.15s ease),
                border-color var(--tod-transition, 0.15s ease);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tod-chat-ctx-item:hover {
    background: rgba(255,215,0,0.07);
    border-left-color: var(--tod-gold, #FFD700);
    color: var(--tod-gold, #FFD700);
}
/* Danger item (Delete) */
.tod-chat-ctx-item--danger {
    color: var(--tod-red, #F44336);
}
.tod-chat-ctx-item--danger:hover {
    background: rgba(244,67,54,0.10);
    border-left-color: var(--tod-red, #F44336);
    color: var(--tod-red, #F44336);
}
/* Admin-only items (mute durations) */
.tod-chat-ctx-item--admin {
    color: var(--tod-purple, #9C27B0);
    padding-left: 20px;
}
.tod-chat-ctx-item--admin:hover {
    background: rgba(156,39,176,0.10);
    border-left-color: var(--tod-purple, #9C27B0);
    color: #ce93d8;
}
/* Cancel item */
.tod-chat-ctx-item--cancel {
    color: var(--tod-text-dim, #666);
    font-size: 11px;
    border-top: 1px solid var(--tod-border, #2a2a2a);
    margin-top: 3px;
}
.tod-chat-ctx-item--cancel:hover {
    background: rgba(255,255,255,0.04);
    border-left-color: var(--tod-text-dim, #666);
    color: var(--tod-text, #c8c8c8);
}

/* ── Silenced Players strip ────────────────────────────────────────────────────
 */
/* Outer container — sits between the feed and the input row */
.tod-chat-silenced-strip {
    background: var(--tod-bg, #0d0d0d);
    border-top: 1px solid var(--tod-border-gold, #8B6914);
    border-bottom: 1px solid var(--tod-border, #2a2a2a);
    padding: 5px 8px;
    flex-shrink: 0;
    font-family: var(--tod-font-mono, "Courier New", monospace);
}
/* Section label */
.tod-chat-silenced-label {
    font-size: 9px;
    font-weight: bold;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--tod-text-dim, #666);
    margin-bottom: 4px;
    user-select: none;
}
/* One row per silenced player */
.tod-chat-silenced-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 2px 0;
}
/* Player name */
.tod-chat-silenced-name {
    font-size: 11px;
    color: var(--tod-text, #c8c8c8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
/* Unsilence button */
.tod-chat-silenced-unsilence {
    flex-shrink: 0;
    background: none;
    border: 1px solid var(--tod-border-gold, #8B6914);
    border-radius: var(--tod-radius, 4px);
    color: var(--tod-gold, #FFD700);
    font-family: var(--tod-font-mono, "Courier New", monospace);
    font-size: 10px;
    padding: 2px 7px;
    cursor: pointer;
    transition: background var(--tod-transition, 0.15s ease),
                color var(--tod-transition, 0.15s ease);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.tod-chat-silenced-unsilence:hover {
    background: var(--tod-gold, #FFD700);
    color: #000;
}

/* ── Admin crown badge on messages ────────────────────────────────────────────
 */

.tod-chat-admin-crown {
    color: var(--tod-gold, #FFD700);
    font-size: 11px;
    margin-right: 2px;
    vertical-align: middle;
    cursor: default;
}

/* Admin message row: subtle gold left border */
.tod-chat-msg--admin {
    border-left: 2px solid rgba(255,215,0,0.35);
    padding-left: 6px;
}
