/* === Message Rendering === */

.message {
    padding: 1px 0;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
}

.message:hover {
    background: #f0f0f0;
}

.message.deleted {
    opacity: 0.5;
    font-style: italic;
}

.message-timestamp {
    color: #808080;
    margin-right: 4px;
    white-space: nowrap;
    font-size: 11px;
}

.message-author {
    font-weight: bold;
    margin-right: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.message-content {
    word-break: break-word;
    flex: 1;
    min-width: 0;
}

.message-edited {
    color: #808080;
    font-size: 9px;
    font-style: italic;
    margin-left: 4px;
}

.message-actions {
    display: none;
    margin-left: auto;
    gap: 2px;
    font-size: 10px;
}

.message:hover .message-actions {
    display: flex;
}

.msg-action-btn {
    background: var(--bg-window);
    border: 1px solid var(--border-dark);
    cursor: pointer;
    padding: 0 4px;
    font-size: 10px;
    font-family: var(--font-main);
}

.msg-action-btn:hover {
    background: var(--border-light);
}

/* === Reply Quote === */

.reply-quote {
    border-left: 2px solid #808080;
    padding: 1px 6px;
    margin-bottom: 1px;
    font-size: 10px;
    color: #606060;
    cursor: pointer;
    background: #f4f4f4;
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reply-quote:hover {
    background: #e8e8e8;
}

/* === Mentions === */

.mention {
    background: var(--color-mention-bg);
    border: 1px solid var(--color-mention-border);
    padding: 0 2px;
    border-radius: 2px;
    font-weight: bold;
    cursor: pointer;
}

.mention.mention-self {
    background: #ffe0e0;
    border-color: #cc6666;
}

/* === Mention Dropdown === */

.mention-dropdown {
    position: fixed;
    background: var(--bg-field);
    box-shadow: var(--bevel-out);
    border: 1px solid var(--border-dark);
    max-height: 150px;
    overflow-y: auto;
    z-index: 200;
    min-width: 150px;
}

.mention-dropdown ul {
    list-style: none;
}

.mention-dropdown li {
    padding: 2px 8px;
    cursor: pointer;
    font-size: 11px;
}

.mention-dropdown li:hover,
.mention-dropdown li.selected {
    background: #000080;
    color: #fff;
}

/* === Reactions === */

.reactions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin-top: 1px;
    margin-left: 60px;
}

.reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1px 4px;
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    font-size: 10px;
    cursor: pointer;
    user-select: none;
}

.reaction-pill:hover {
    background: var(--border-light);
}

.reaction-pill.own {
    background: #d0d0ff;
}

.reaction-pill .reaction-emoji {
    font-size: 12px;
}

.reaction-pill .reaction-count {
    font-weight: bold;
}

/* === Reaction Picker === */

.reaction-picker {
    position: fixed;
    background: var(--bg-field);
    box-shadow: var(--bevel-out);
    border: 1px solid var(--border-dark);
    padding: 4px;
    z-index: 200;
}

.reaction-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}

.reaction-grid button {
    width: 28px;
    height: 28px;
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.reaction-grid button:hover {
    background: #000080;
    border-color: var(--border-dark);
    border-radius: 2px;
}

/* === Image Messages === */

.message-image {
    max-width: 300px;
    max-height: 200px;
    cursor: pointer;
    box-shadow: var(--bevel-in);
    margin-top: 2px;
    display: block;
}

.message-image:hover {
    opacity: 0.9;
}

/* === Audio Messages === */

.audio-player {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-window);
    box-shadow: var(--bevel-in);
    padding: 2px 6px;
    margin-top: 2px;
    max-width: 250px;
}

.audio-player button {
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    border: none;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-progress {
    flex: 1;
    height: 8px;
    background: var(--bg-field);
    box-shadow: var(--bevel-in);
    position: relative;
    cursor: pointer;
}

.audio-progress-bar {
    height: 100%;
    background: #000080;
    width: 0%;
    transition: width 0.1s;
}

.audio-time {
    font-size: 9px;
    color: var(--text-secondary);
    min-width: 30px;
    text-align: right;
}

/* === Lightbox === */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
}

.lightbox-img {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    z-index: 1;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    border: none;
    width: 24px;
    height: 24px;
    font-size: 16px;
    cursor: pointer;
    z-index: 2;
}

/* === Recording Indicator === */

.recording-indicator {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    padding: 4px 12px;
    font-size: 11px;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 6px;
}

.recording-dot {
    width: 8px;
    height: 8px;
    background: #cc0000;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* === System Messages === */

.message-system {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 2px 0;
    font-size: 10px;
}

/* === Loading === */

.loading-indicator {
    text-align: center;
    padding: 8px;
    color: var(--text-secondary);
    font-style: italic;
}

/* === Nudge === */

.nudge-shake {
    animation: nudgeShake 0.4s ease-in-out 3;
}

@keyframes nudgeShake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-6px, -3px); }
    20% { transform: translate(5px, 4px); }
    30% { transform: translate(-4px, 2px); }
    40% { transform: translate(6px, -4px); }
    50% { transform: translate(-3px, 5px); }
    60% { transform: translate(4px, -2px); }
    70% { transform: translate(-5px, 3px); }
    80% { transform: translate(3px, -5px); }
    90% { transform: translate(-2px, 4px); }
}

.nudge-message {
    text-align: center;
    color: #cc6600;
    font-weight: bold;
    font-style: italic;
    padding: 2px 0;
    font-size: 11px;
}

/* === Buddy Listening Status === */

.buddy-listening {
    font-style: italic;
    color: #660099;
    font-size: 10px;
    margin-left: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-item:hover .buddy-listening,
.sidebar-item.active .buddy-listening {
    color: #cc99ff;
}

/* === Radio Panel === */

.radio-panel {
    background: var(--bg-field);
    padding: 4px;
}

.radio-now-playing {
    padding: 3px 6px;
    background: #000;
    color: #00ff00;
    font-family: var(--font-mono);
    font-size: 10px;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.radio-controls {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 0;
    margin-bottom: 3px;
}

.radio-btn {
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    border: none;
    width: 22px;
    height: 20px;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.radio-btn:active {
    box-shadow: var(--bevel-in);
}

.radio-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.radio-volume {
    flex: 1;
    height: 12px;
    cursor: pointer;
}

.radio-station-list {
    list-style: none;
    max-height: 150px;
    overflow-y: auto;
}

.radio-station {
    padding: 2px 6px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    border-bottom: 1px solid var(--border-light);
}

.radio-station:hover {
    background: #000080;
    color: #fff;
}

.radio-station.active {
    background: #000080;
    color: #fff;
}

.station-name {
    font-weight: bold;
}

.station-genre {
    color: var(--text-secondary);
    font-size: 9px;
}

.radio-station:hover .station-genre,
.radio-station.active .station-genre {
    color: #aaa;
}

/* === Emoticons === */

.emoticon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    image-rendering: pixelated;
}

.emoticon-picker {
    position: fixed;
    background: var(--bg-field);
    box-shadow: var(--bevel-out);
    border: 1px solid var(--border-dark);
    padding: 4px;
    z-index: 200;
    max-width: 260px;
    max-height: 200px;
    overflow-y: auto;
}

.emoticon-pack-header {
    font-size: 9px;
    font-weight: bold;
    color: var(--text-secondary);
    padding: 2px 4px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 2px;
}

.emoticon-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin-bottom: 4px;
}

.emoticon-btn {
    width: 26px;
    height: 26px;
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.emoticon-btn:hover {
    background: #000080;
    border-color: var(--border-dark);
    border-radius: 2px;
}

.emoticon-empty {
    font-size: 10px;
    color: var(--text-secondary);
    padding: 8px;
    text-align: center;
    font-style: italic;
}

/* === Room Topic Bar === */

.topic-bar {
    display: flex;
    align-items: center;
    padding: 2px 6px;
    background: var(--bg-field);
    border-bottom: 1px solid var(--border-dark);
    font-size: 10px;
    min-height: 18px;
    gap: 4px;
}

.topic-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
}

.topic-edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    color: var(--text-secondary);
    padding: 0 2px;
    flex-shrink: 0;
}

.topic-edit-btn:hover {
    color: var(--text-primary);
}

/* === Message Search === */

.search-panel {
    border-bottom: 1px solid var(--border-dark);
    background: var(--bg-window);
    max-height: 50%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.search-bar {
    display: flex;
    gap: 4px;
    padding: 4px;
    align-items: center;
}

.search-bar .retro-input {
    flex: 1;
}

.search-results {
    overflow-y: auto;
    flex: 1;
    padding: 0 4px 4px;
}

.search-hint,
.search-loading {
    text-align: center;
    padding: 8px;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 10px;
}

.search-count {
    font-size: 10px;
    color: var(--text-secondary);
    padding: 2px 4px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 2px;
}

.search-result {
    padding: 4px 6px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    font-size: 11px;
}

.search-result:hover {
    background: var(--bg-field);
}

.search-result-header {
    display: flex;
    gap: 6px;
    align-items: baseline;
    margin-bottom: 1px;
}

.search-result-author {
    font-weight: bold;
    font-size: 11px;
}

.search-result-where {
    color: var(--text-secondary);
    font-size: 10px;
}

.search-result-time {
    color: var(--text-secondary);
    font-size: 9px;
    margin-left: auto;
}

.search-result-content {
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.search-highlight {
    background: #ffff00;
    color: #000;
    padding: 0 1px;
}

/* === Profile Card === */

.profile-card {
    position: fixed;
    z-index: 300;
    background: var(--bg-window);
    box-shadow: var(--bevel-out);
    border: 1px solid var(--border-dark);
    width: 220px;
    font-size: 11px;
}

.profile-card-inner {
    display: flex;
    gap: 8px;
    padding: 8px;
}

.profile-card-avatar {
    flex-shrink: 0;
}

.profile-card-avatar img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    box-shadow: var(--bevel-in);
}

.profile-card-no-avatar {
    width: 48px;
    height: 48px;
    background: #000080;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    box-shadow: var(--bevel-in);
}

.profile-card-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.profile-card-name {
    font-weight: bold;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-card-username {
    color: var(--text-secondary);
    font-size: 10px;
}

.profile-card-status {
    margin-top: 2px;
    font-size: 10px;
}

.profile-card-away {
    color: #996600;
    font-style: italic;
    font-size: 10px;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-card-listening {
    color: #660099;
    font-style: italic;
    font-size: 10px;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-card-joined {
    color: var(--text-secondary);
    font-size: 9px;
    margin-top: 4px;
}
