/* spa.css - SPA-specific styles for Synchronet webv4 */

/* Push content below fixed navbar */
.spa-container {
    padding-top: 70px;
}

/* Terminal panel */
.terminal-panel {
    position: relative;
    z-index: 1020;
    background: #000;
    border-bottom: 2px solid #333;
    padding-top: 60px; /* below navbar */
}

.terminal-panel .fTelnetContainer {
    margin: 0 auto;
    max-width: 100%;
}

/* Ensure terminal canvas is responsive */
.terminal-panel canvas {
    max-width: 100%;
    height: auto !important;
}

/* When terminal is visible, adjust main content */
.terminal-panel:not(.d-none) + .modal + .spa-container,
.terminal-panel:not(.d-none) ~ .spa-container {
    /* Content flows below terminal naturally */
}

/* Sidebar styling */
#sidebar .list-group-item.sidebar {
    padding: 10px;
    border-left: 0;
    border-right: 0;
}

#sidebar .list-group-item.sidebar:first-child {
    border-top: 0;
}

/* Navigation transitions */
#content {
    min-height: 200px;
    opacity: 1;
    transition: opacity 0.15s ease;
}

#content.spa-loading {
    opacity: 0.5;
}

/* BS5 navbar tweaks */
.navbar .badge-unread {
    font-size: 0.65em;
    vertical-align: super;
}

/* Dark mode support */
[data-bs-theme="dark"] .terminal-panel {
    border-bottom-color: #555;
}

/* Mobile: terminal full-width */
@media (max-width: 767.98px) {
    .terminal-panel {
        padding-top: 56px;
    }

    .spa-container {
        padding-top: 60px;
    }

    #sidebar {
        margin-top: 1rem;
    }
}

/* fTelnet status bar tweak */
.fTelnetStatusBar {
    font-size: 12px;
}

/* Override some BS3 classes that may appear in legacy page content */
.panel { border: 1px solid #dee2e6; border-radius: 0.375rem; margin-bottom: 1rem; }
.panel-heading { padding: 0.75rem 1.25rem; background-color: #f8f9fa; border-bottom: 1px solid #dee2e6; border-radius: 0.375rem 0.375rem 0 0; }
.panel-body { padding: 1.25rem; }
.panel-footer { padding: 0.75rem 1.25rem; background-color: #f8f9fa; border-top: 1px solid #dee2e6; border-radius: 0 0 0.375rem 0.375rem; }
.panel-default { }
.panel-primary .panel-heading { background-color: #0d6efd; color: #fff; border-color: #0d6efd; }
.well { padding: 1.25rem; background-color: #f8f9fa; border: 1px solid #dee2e6; border-radius: 0.375rem; margin-bottom: 1rem; }
.btn-default { color: #333; background-color: #fff; border-color: #ccc; }
.btn-default:hover { background-color: #e6e6e6; border-color: #adadad; }
.label { display: inline-block; padding: 0.25em 0.4em; font-size: 75%; font-weight: 700; border-radius: 0.25rem; }
.label-default { background-color: #6c757d; color: #fff; }
.label-primary { background-color: #0d6efd; color: #fff; }
.label-success { background-color: #198754; color: #fff; }
.label-info { background-color: #0dcaf0; color: #000; }
.label-warning { background-color: #ffc107; color: #000; }
.label-danger { background-color: #dc3545; color: #fff; }
/* BS3 Glyphicon -> Unicode replacements */
.glyphicon { display: inline-block; font-style: normal; font-weight: normal; line-height: 1; font-family: sans-serif; }
.glyphicon::before { content: '\25A1'; }
.glyphicon-trash::before { content: '\2717'; }
.glyphicon-link::before { content: '\1F517'; }
.glyphicon-comment::before { content: '\1F4AC'; }
.glyphicon-arrow-up::before { content: '\25B2'; }
.glyphicon-arrow-down::before { content: '\25BC'; }
.glyphicon-pencil::before { content: '\270E'; }
.glyphicon-plus::before { content: '\002B'; }
.glyphicon-remove::before { content: '\2715'; }
.glyphicon-user::before { content: '\1F464'; }
.glyphicon-star::before { content: '\2605'; }
.glyphicon-check::before { content: '\2713'; }
.glyphicon-ok-sign::before { content: '\2714'; }
.glyphicon-ban-circle::before { content: '\26D4'; }
.glyphicon-asterisk::before { content: '\002A'; }
.glyphicon-list-alt::before { content: '\2630'; }
.glyphicon-chevron-up::before { content: '\25B4'; }
.glyphicon-chevron-down::before { content: '\25BE'; }
.glyphicon-fast-backward::before { content: '\23EA'; }
.glyphicon-fast-forward::before { content: '\23E9'; }
.glyphicon-step-backward::before { content: '\23EE'; }
.glyphicon-step-forward::before { content: '\23ED'; }ebv4 */

/* Push content below fixed navbar */
.spa-container {
    padding-top: 70px;
}

/* Terminal panel */
.terminal-panel {
    position: relative;
    z-index: 1020;
    background: #000;
    border-bottom: 2px solid #333;
    padding-top: 60px; /* below navbar */
}

.terminal-panel .fTelnetContainer {
    margin: 0 auto;
    max-width: 100%;
}

/* Ensure terminal canvas is responsive */
.terminal-panel canvas {
    max-width: 100%;
    height: auto !important;
}

/* When terminal is visible, adjust main content */
.terminal-panel:not(.d-none) + .modal + .spa-container,
.terminal-panel:not(.d-none) ~ .spa-container {
    /* Content flows below terminal naturally */
}

/* Sidebar styling */
#sidebar .list-group-item.sidebar {
    padding: 10px;
    border-left: 0;
    border-right: 0;
}

#sidebar .list-group-item.sidebar:first-child {
    border-top: 0;
}

/* Navigation transitions */
#content {
    min-height: 200px;
    opacity: 1;
    transition: opacity 0.15s ease;
}

#content.spa-loading {
    opacity: 0.5;
}

/* BS5 navbar tweaks */
.navbar .badge-unread {
    font-size: 0.65em;
    vertical-align: super;
}

/* Dark mode support */
[data-bs-theme="dark"] .terminal-panel {
    border-bottom-color: #555;
}

/* Mobile: terminal full-width */
@media (max-width: 767.98px) {
    .terminal-panel {
        padding-top: 56px;
    }

    .spa-container {
        padding-top: 60px;
    }

    #sidebar {
        margin-top: 1rem;
    }
}

/* fTelnet status bar tweak */
.fTelnetStatusBar {
    font-size: 12px;
}

/* Override some BS3 classes that may appear in legacy page content */
.panel { border: 1px solid #dee2e6; border-radius: 0.375rem; margin-bottom: 1rem; }
.panel-heading { padding: 0.75rem 1.25rem; background-color: #f8f9fa; border-bottom: 1px solid #dee2e6; border-radius: 0.375rem 0.375rem 0 0; }
.panel-body { padding: 1.25rem; }
.panel-footer { padding: 0.75rem 1.25rem; background-color: #f8f9fa; border-top: 1px solid #dee2e6; border-radius: 0 0 0.375rem 0.375rem; }
.panel-default { }
.panel-primary .panel-heading { background-color: #0d6efd; color: #fff; border-color: #0d6efd; }
.well { padding: 1.25rem; background-color: #f8f9fa; border: 1px solid #dee2e6; border-radius: 0.375rem; margin-bottom: 1rem; }
.btn-default { color: #333; background-color: #fff; border-color: #ccc; }
.btn-default:hover { background-color: #e6e6e6; border-color: #adadad; }
.label { display: inline-block; padding: 0.25em 0.4em; font-size: 75%; font-weight: 700; border-radius: 0.25rem; }
.label-default { background-color: #6c757d; color: #fff; }
.label-primary { background-color: #0d6efd; color: #fff; }
.label-success { background-color: #198754; color: #fff; }
.label-info { background-color: #0dcaf0; color: #000; }
.label-warning { background-color: #ffc107; color: #000; }
.label-danger { background-color: #dc3545; color: #fff; }
.col-xs-12 { width: 100%; }
.col-xs-6 { width: 50%; }
.pull-left { float: left !important; }
.pull-right { float: right !important; }
.center-block { display: block; margin-left: auto; margin-right: auto; }
.visible-xs { display: none !important; }
@media (max-width: 767.98px) { .visible-xs { display: block !important; } }
.text-center { text-align: center; }

/* Who's Online avatar rows */
#nodelist-table td,
#nodelist-table th {
    vertical-align: middle;
    min-height: 48px;
    height: 48px;
}

.avatar-inline {
    display: inline-block;
    vertical-align: middle;
    width: 40px;
    height: 40px;
    margin-right: 4px;
    overflow: hidden;
    position: relative;
}

.avatar-inline img,
.avatar-inline canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

/* ---------- Games page ---------- */

.game-row {
    border: 1px solid rgba(128, 128, 128, 0.2);
    transition: background-color 0.15s;
}
.game-row:hover {
    background-color: rgba(128, 128, 128, 0.1);
}

.game-rank {
    font-size: 0.85rem;
    font-weight: bold;
    min-width: 2.2em;
    text-align: right;
}

.game-icon {
    width: 96px;
    height: 96px;
    overflow: hidden;
    background: #000;
    border: 1px solid rgba(128, 128, 128, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}
.game-icon-img {
    width: 96px;
    height: 96px;
    image-rendering: pixelated;
    display: block;
}
.game-icon-placeholder {
    width: 96px;
    height: 96px;
    background: #111;
    opacity: 0.5;
}

.game-title {
    font-size: 1rem;
}

.game-stat-label {
    opacity: 0.6;
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-right: 0.2em;
}

.game-stat-time  { color: var(--bs-success, #198754); }
.game-stat-launches { color: var(--bs-info, #0dcaf0); }
.game-stat-recent { color: var(--bs-warning, #ffc107); }
.game-stat-players { color: var(--bs-primary, #0d6efd); }

.game-top-players {
    font-size: 0.8rem;
}

.game-launch-btn {
    align-self: center;
}

.game-user-dropdown {
    max-height: 300px;
    overflow-y: auto;
    z-index: 1050;
}

.game-user-dropdown .avatar-inline {
    width: 24px;
    height: 24px;
}

#games-stats strong {
    margin-right: 0.15em;
}

/* CGA theme overrides for games */
[data-theme="cga"] .game-row {
    border-color: #545454;
}
[data-theme="cga"] .game-row:hover {
    background-color: rgba(84, 84, 84, 0.3);
}
[data-theme="cga"] .game-stat-time { color: #54FC54; }
[data-theme="cga"] .game-stat-launches { color: #54FCFC; }
[data-theme="cga"] .game-stat-recent { color: #FCFC54; }
[data-theme="cga"] .game-stat-players { color: #5454FC; }
[data-theme="cga"] .game-title { color: #A8A8A8; }
[data-theme="cga"] .game-launch-btn {
    color: #54FC54;
    border-color: #54FC54;
}
[data-theme="cga"] .game-launch-btn:hover {
    background-color: #54FC54;
    color: #000;
}

/* Small screen adjustments */
@media (max-width: 576px) {
    .game-icon {
        width: 64px;
        height: 64px;
    }
    .game-icon-img {
        width: 64px;
        height: 64px;
    }
    .game-icon-placeholder {
        width: 64px;
        height: 64px;
    }
    .game-rank {
        display: none;
    }
}

/* ---- Forum icons ---- */
.forum-item-with-icon {
    display: flex !important;
    align-items: flex-start;
    gap: 12px;
}
.forum-icon {
    width: 96px;
    min-width: 96px;
    height: 96px;
    overflow: hidden;
    background: #000;
    border: 1px solid rgba(128, 128, 128, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.forum-icon-img {
    width: 96px;
    height: 96px;
    image-rendering: pixelated;
    display: block;
}
.forum-item-content {
    flex: 1;
    min-width: 0;
}
.forum-item-content h3,
.forum-item-content h4 {
    margin-top: 0;
}
/* Breadcrumb icons */
.bc-icon {
    display: inline-block;
    width: 32px;
    height: 32px;
    overflow: hidden;
    vertical-align: middle;
}
.bc-icon .forum-icon-img {
    width: 32px;
    height: 32px;
}
/* CGA theme overrides */
[data-theme="cga"] .forum-icon {
    border-color: var(--cga-gray);
}
/* Responsive */
@media (max-width: 576px) {
    .forum-icon {
        width: 64px;
        min-width: 64px;
        height: 64px;
    }
    .forum-icon-img {
        width: 64px;
        height: 64px;
    }
    .bc-icon {
        width: 24px;
        height: 24px;
    }
    .bc-icon .forum-icon-img {
        width: 24px;
        height: 24px;
    }
}

/* ============ Chat ============ */

.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 160px);
    min-height: 300px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 8px 8px 0 0;
}

/* Message groups */
.chat-msg-group {
    display: flex;
    gap: 8px;
    max-width: 75%;
    margin-bottom: 4px;
}
.chat-msg-group-other {
    align-self: flex-start;
}
.chat-msg-group-self {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

/* Avatar column */
.chat-avatar-col {
    flex-shrink: 0;
    width: 40px;
    align-self: flex-end;
}
.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    overflow: hidden;
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-avatar img {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    display: block;
}
.chat-avatar-placeholder {
    color: #aaa;
    font-size: 18px;
    font-weight: bold;
    line-height: 40px;
    text-align: center;
    display: block;
    width: 100%;
}

/* Sender name */
.chat-sender-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--bs-secondary-color, #6c757d);
    padding: 0 8px;
    margin-top: 4px;
}

/* Bubbles */
.chat-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    word-break: break-word;
    position: relative;
}
.chat-bubble-other {
    background: var(--bs-tertiary-bg, #e9ecef);
    color: var(--bs-body-color, #212529);
    border-bottom-left-radius: 4px;
}
.chat-bubble-self {
    background: #0d6efd;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-bubble-self a {
    color: #cfe2ff;
}

/* Timestamp */
.chat-timestamp {
    font-size: 0.65rem;
    color: inherit;
    opacity: 0.55;
    text-align: right;
    margin-top: 2px;
}

/* System messages (join/part) */
.chat-system-msg {
    text-align: center;
    font-size: 0.8rem;
    color: var(--bs-secondary-color, #6c757d);
    padding: 4px 0;
    font-style: italic;
}

/* Chat text */
.chat-text {
    line-height: 1.4;
}
.chat-text a {
    text-decoration: underline;
}

/* Input area */
.chat-input-area {
    padding: 12px;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-top: none;
    border-radius: 0 0 8px 8px;
    background: var(--bs-body-bg, #fff);
}

/* ============ Chat Toasts ============ */

#chat-toasts {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1090;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    max-width: 360px;
    pointer-events: none;
}

.chat-toast {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    pointer-events: auto;
    cursor: pointer;
    transition: opacity 0.3s, transform 0.3s;
    opacity: 1;
    transform: translateX(0);
}

.chat-toast-enter {
    opacity: 0;
    transform: translateX(-30px);
}
.chat-toast-exit {
    opacity: 0;
    transform: translateX(-30px);
}

.chat-toast-body {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.chat-toast-avatar {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    overflow: hidden;
    background: #111;
    flex-shrink: 0;
}
.chat-toast-avatar img {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

.chat-toast-content {
    flex: 1;
    min-width: 0;
}

.chat-toast-sender {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 2px;
}

.chat-toast-text {
    font-size: 0.8rem;
    color: var(--bs-secondary-color, #6c757d);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-toast-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--bs-secondary-color, #6c757d);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    align-self: flex-start;
    pointer-events: auto;
}
.chat-toast-close:hover {
    color: var(--bs-body-color, #212529);
}

/* Chat badge in navbar */
#badge-chat-unread {
    font-size: 0.65rem;
    vertical-align: top;
}

/* ---- CGA theme overrides ---- */
[data-theme="cga"] .chat-messages,
.cga .chat-messages {
    background: #000;
    border-color: var(--cga-gray);
}
[data-theme="cga"] .chat-bubble-other,
.cga .chat-bubble-other {
    background: #222;
    color: var(--cga-lt-gray);
}
[data-theme="cga"] .chat-bubble-self,
.cga .chat-bubble-self {
    background: var(--cga-blue);
    color: var(--cga-white);
}
[data-theme="cga"] .chat-input-area,
.cga .chat-input-area {
    background: #000;
    border-color: var(--cga-gray);
}
[data-theme="cga"] .chat-system-msg,
.cga .chat-system-msg {
    color: var(--cga-gray);
}
[data-theme="cga"] .chat-sender-name,
.cga .chat-sender-name {
    color: var(--cga-lt-green);
}
[data-theme="cga"] .chat-toast,
.cga .chat-toast {
    background: #111;
    border-color: var(--cga-gray);
}


/* ---- Chat Users Panel ---- */
.chat-users-panel {
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: .375rem;
    margin-bottom: .75rem;
    max-height: 320px;
    overflow-y: auto;
    background: var(--bs-body-bg, #fff);
}
.chat-users-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    font-weight: 600;
    font-size: .9rem;
}
.chat-users-panel-header .btn-close {
    font-size: .65rem;
}
.chat-users-list {
    padding: .25rem 0;
}
.chat-user-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem .75rem;
}
.chat-user-item:hover {
    background: var(--bs-tertiary-bg, rgba(0,0,0,.03));
}
.chat-user-avatar {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 2px;
    overflow: hidden;
    background: #000;
}
.chat-user-avatar img,
.chat-user-avatar canvas {
    width: 100%;
    height: 100%;
    display: block;
}
.chat-user-info {
    min-width: 0;
}
.chat-user-nick {
    font-weight: 500;
    font-size: .85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-user-system {
    font-size: .7rem;
    color: var(--bs-secondary-color, #6c757d);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* CGA theme overrides for users panel */
[data-theme="cga"] .chat-users-panel,
.cga .chat-users-panel {
    background: #000;
    border-color: var(--cga-gray);
}
[data-theme="cga"] .chat-users-panel-header,
.cga .chat-users-panel-header {
    border-color: var(--cga-gray);
    color: var(--cga-lt-cyan);
}
[data-theme="cga"] .chat-user-item:hover,
.cga .chat-user-item:hover {
    background: rgba(85,85,85,.2);
}
[data-theme="cga"] .chat-user-nick,
.cga .chat-user-nick {
    color: var(--cga-lt-green);
}
[data-theme="cga"] .chat-user-system,
.cga .chat-user-system {
    color: var(--cga-gray);
}
/* ---- Responsive ---- */
@media (max-width: 576px) {
    .chat-msg-group {
        max-width: 90%;
    }
    .chat-container {
        height: calc(100vh - 140px);
    }
    #chat-toasts {
        left: 10px;
        right: 10px;
        max-width: none;
    }
}

/* Forum message body styles */
div.message {
    word-wrap: break-word;
    overflow-wrap: break-word;
}
div.message blockquote {
    border-left: 3px solid #555;
    margin: 0.5em 0;
    padding: 0.25em 0.75em;
    color: #aaa;
}
div.message pre.ansi {
    background-color: #000;
    color: #aaa;
    font-size: 14px;
    line-height: 1.1;
    padding: 0.5em;
    overflow-x: auto;
    max-width: 100%;
    width: 80ch;
    overflow: hidden;
}
[data-theme="cga"] div.message blockquote {
    border-left-color: #00aa00;
    color: #00aaaa;
}
