/* Carrion Chat - Main Stylesheet
 * Design: Minimalist dark theme with restrained red accents
 * Philosophy: Professional, functional, high contrast for readability
 */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    /* Colors */
    --color-bg: #1a1a1a;
    --color-surface: #2a2a2a;
    --color-border: #3a3a3a;
    --color-accent: #8b1a1a;
    --color-accent-hover: #a82020;
    --color-text: #e0e0e0;
    --color-text-header: #ffffff;
    --color-text-muted: #999999;
    --color-error: #d32f2f;
    --color-success: #388e3c;

    /* Spacing (multiples of 4px) */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-base: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-family-mono: 'Courier New', Courier, monospace;
    --font-size-base: 15px;
    --font-size-sm: 13px;
    --font-size-lg: 18px;
    --font-size-xl: 24px;
    --font-size-2xl: 32px;
    --line-height-base: 1.5;
    --line-height-tight: 1.3;

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;

    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-base: 200ms ease-in-out;
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) var(--color-bg);
}

/* Chromium/Chrome/Edge/Safari */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
    border: 2px solid var(--color-bg); /* Creates padding effect */
}

::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}

::-webkit-scrollbar-corner {
    background: var(--color-bg);
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
}

body {
    font-family: var(--font-family);
    background-color: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    color: var(--color-text-header);
    font-weight: 600;
    line-height: var(--line-height-tight);
    margin-bottom: var(--space-base);
}

h1 {
    font-size: var(--font-size-2xl);
}

h2 {
    font-size: var(--font-size-xl);
}

h3 {
    font-size: var(--font-size-lg);
}

p {
    margin-bottom: var(--space-base);
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-accent-hover);
}

a:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

code, pre {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-sm);
}

ul, ol {
    margin-left: var(--space-lg);
    margin-bottom: var(--space-base);
}

/* ============================================
   LAYOUT
   ============================================ */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-base);
}

.container-narrow {
    max-width: 600px;
}

.container-wide {
    max-width: 1400px;
}

main {
    flex: 1;
    padding: var(--space-xl) 0;
}

/* ============================================
   HEADER & NAVIGATION
   ============================================ */
.site-header {
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.4rem 0;
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-logo {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text-header);
}

.site-logo:hover {
    color: var(--color-accent-hover);
}

.site-nav ul {
    display: flex;
    list-style: none;
    gap: var(--space-lg);
    margin: 0;
    align-items: center;
}

.site-nav a {
    color: var(--color-text);
    font-size: var(--font-size-base);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.site-nav a:hover {
    background-color: var(--color-accent);
    color: var(--color-text-header);
}

.site-nav a:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Chat nav link needs position: relative for badge positioning */
#chat-nav-link {
    position: relative;
    white-space: nowrap;  /* Prevent text wrapping on narrow windows */
}

/* Notification badge (for chat nav link) */
.notification-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    display: inline-block;
    color: var(--color-error);
    font-size: 18px;
    line-height: 1;
    animation: pulse 2s ease-in-out infinite;
    pointer-events: none;
}

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

/* Character selector styling */
.character-selector-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background-color: rgba(139, 26, 26, 0.1);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-accent);
}

.character-selector-wrapper label {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    white-space: nowrap;
    margin: 0;
}

.character-selector-wrapper select {
    background-color: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: var(--font-size-base);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.character-selector-wrapper select:hover {
    border-color: var(--color-accent);
}

.character-selector-wrapper select:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-color: var(--color-accent);
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
    background-color: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: var(--space-lg) 0;
    margin-top: auto;
}

.site-footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-base);
}

.site-footer nav ul {
    display: flex;
    list-style: none;
    gap: var(--space-lg);
    margin: 0;
}

.site-footer a {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.site-footer a:hover {
    color: var(--color-accent-hover);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-block;
    padding: var(--space-md) var(--space-lg);
    font-size: var(--font-size-base);
    font-weight: 500;
    text-align: center;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    text-decoration: none;
}

.btn:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.btn-primary {
    background-color: var(--color-accent);
    color: var(--color-text-header);
    border-color: var(--color-accent);
}

.btn-primary:hover {
    background-color: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
    color: var(--color-text-header);
}

.btn-secondary {
    background-color: transparent;
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-secondary:hover {
    background-color: var(--color-surface);
    border-color: var(--color-accent);
    color: var(--color-text);
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:disabled:hover,
.btn[disabled]:hover {
    background-color: var(--color-accent);
}

.btn-block {
    display: block;
    width: 100%;
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
    margin-bottom: var(--space-lg);
}

label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: 500;
    color: var(--color-text-header);
}

.required-indicator {
    color: var(--color-text);
    margin-left: var(--space-xs);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: var(--space-md);
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    background-color: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-accent);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

.help-text {
    display: block;
    margin-top: var(--space-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.errorlist {
    list-style: none;
    margin: var(--space-sm) 0 0 0;
    padding: 0;
}

.errorlist li {
    color: var(--color-error);
    font-size: var(--font-size-sm);
}

.form-error {
    border-color: var(--color-error);
}

fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

legend {
    padding: 0 var(--space-sm);
    font-weight: 600;
    color: var(--color-text-header);
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.card-header {
    margin-bottom: var(--space-base);
    padding-bottom: var(--space-base);
    border-bottom: 1px solid var(--color-border);
}

.card-header h2,
.card-header h3 {
    margin-bottom: 0;
}

.card-body {
    padding: var(--space-base) 0;
}

.card-footer {
    margin-top: var(--space-base);
    padding-top: var(--space-base);
    border-top: 1px solid var(--color-border);
}

/* ============================================
   ACCORDIONS / DETAILS
   ============================================ */
details {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
}

summary {
    padding: var(--space-md) var(--space-base);
    cursor: pointer;
    font-weight: 500;
    color: var(--color-text-header);
    user-select: none;
}

summary:hover {
    background-color: rgba(139, 26, 26, 0.1);
}

details[open] summary {
    border-bottom: 1px solid var(--color-border);
}

/* Add padding to collapsible content - only block-level elements, not inline links etc */
details > div,
details > p,
details > ul,
details > ol,
details > pre,
details > blockquote,
details > table,
details > h1,
details > h2,
details > h3,
details > h4,
details > h5,
details > h6 {
    padding: var(--space-base);
}

/* First and last block elements get consistent padding */
details > div:first-of-type,
details > p:first-of-type {
    padding-top: var(--space-base);
}

details > div:last-child,
details > p:last-child {
    padding-bottom: var(--space-base);
}

/* Reduce paragraph margins inside collapsibles to avoid double spacing */
details p {
    margin-bottom: var(--space-sm);
}

details p:last-child {
    margin-bottom: 0;
}

/* Nested collapsibles - add indentation and adjust styling */
details details {
    margin-top: var(--space-sm);
    margin-left: var(--space-base);
    background-color: rgba(0, 0, 0, 0.2);
    border-color: rgba(139, 26, 26, 0.3);
}

details details details {
    margin-left: calc(var(--space-base) * 1.5);
    background-color: rgba(0, 0, 0, 0.3);
}

/* Nested summary styling */
details details summary {
    font-size: 0.95em;
    padding: var(--space-sm) var(--space-base);
}

details details details summary {
    font-size: 0.9em;
}

/* ============================================
   MESSAGES / ALERTS
   ============================================ */
.messages {
    list-style: none;
    margin: 0 0 0 0;
    padding: 0;
}

.message {
    padding: var(--space-md) var(--space-base);
    margin-bottom: var(--space-md);
    border-radius: var(--radius-sm);
    border-left: 4px solid;
}

.message-info {
    background-color: rgba(33, 150, 243, 0.1);
    border-left-color: #2196f3;
    color: var(--color-text);
}

.message-success {
    background-color: rgba(56, 142, 60, 0.1);
    border-left-color: var(--color-success);
    color: var(--color-text);
}

.message-warning {
    background-color: rgba(255, 152, 0, 0.1);
    border-left-color: #ff9800;
    color: var(--color-text);
}

.message-error {
    background-color: rgba(211, 47, 47, 0.1);
    border-left-color: var(--color-error);
    color: var(--color-text);
}

/* ============================================
   UTILITIES
   ============================================ */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--color-text-muted);
}

.text-error {
    color: var(--color-error);
}

.text-success {
    color: var(--color-success);
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-base); }
.mt-3 { margin-top: var(--space-lg); }
.mt-4 { margin-top: var(--space-xl); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-base); }
.mb-3 { margin-bottom: var(--space-lg); }
.mb-4 { margin-bottom: var(--space-xl); }

.p-0 { padding: 0; }
.p-1 { padding: var(--space-sm); }
.p-2 { padding: var(--space-base); }
.p-3 { padding: var(--space-lg); }
.p-4 { padding: var(--space-xl); }

/* ============================================
   LANDING PAGE
   ============================================ */
.hero {
    text-align: center;
    padding: var(--space-2xl) 0;
}

.hero h1 {
    font-size: var(--font-size-2xl);
    margin-bottom: var(--space-lg);
}

.hero-subtitle {
    font-size: var(--font-size-lg);
    color: var(--color-text);
    margin-bottom: var(--space-xl);
}

.hero-cta {
    display: flex;
    gap: var(--space-base);
    justify-content: center;
    flex-wrap: wrap;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-lg);
    margin: var(--space-2xl) 0;
}

.feature {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
}

.feature h3 {
    margin-bottom: var(--space-md);
}

/* ============================================
   CHARACTER LISTINGS
   ============================================ */
.character-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-base);
    margin: var(--space-lg) 0;
}

@media (max-width: 1200px) {
    .character-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .character-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .character-grid {
        grid-template-columns: 1fr;
    }
}

.character-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    transition: border-color var(--transition-fast);
    /* Force consistent sizing */
    min-width: 0; /* Allow grid to shrink card below content width */
    max-width: 100%; /* Prevent expansion beyond grid column */
    overflow: hidden; /* Hide overflow content */
    /* Break long words and URLs */
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    /* Control vertical height */
    display: flex;
    flex-direction: column;
    max-height: 550px; /* Prevent extremely tall cards */
}

.character-card:hover {
    border-color: var(--color-accent);
}

.character-avatar {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin: 0 auto var(--space-md);
    display: block;
    flex-shrink: 0; /* Don't shrink avatar */
}

.character-name {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-sm);
    /* Prevent long names from breaking layout */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0; /* Don't shrink name */
}

.character-meta {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    /* Ensure metadata wraps properly */
    word-wrap: break-word;
    overflow-wrap: break-word;
    flex-shrink: 0; /* Don't shrink metadata */
}

/* Character description in cards */
.character-card p,
.character-description {
    /* Force description text to wrap and stay within card */
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    overflow: hidden;
    /* Constrain height to prevent vertical expansion */
    max-height: 5.6em; /* ~4 lines of text at 1.4 line-height */
    flex-shrink: 1; /* Allow description to shrink if needed */
}

/* Ensure all direct children of character cards respect boundaries */
.character-card > * {
    min-width: 0; /* Allow flex/grid children to shrink below content size */
    max-width: 100%; /* Never exceed card width */
}

/* Force inline elements like tags and spans to wrap */
.character-card span {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Don't shrink button containers, tag containers, and avatar links */
.character-card > div,
.character-card > a {
    flex-shrink: 0;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
    margin: var(--space-xl) 0;
    list-style: none;
}

.pagination a,
.pagination span {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background-color: var(--color-surface);
}

.pagination a:hover {
    border-color: var(--color-accent);
    background-color: var(--color-accent);
    color: var(--color-text-header);
}

.pagination .current {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-text-header);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    :root {
        --font-size-base: 16px;
    }

    .site-header .container {
        flex-direction: column;
        gap: var(--space-base);
    }

    .site-nav ul {
        flex-wrap: wrap;
        justify-content: center;
    }

    .hero-cta {
        flex-direction: column;
        align-items: center;
    }

    .hero-cta .btn {
        min-width: 200px;
    }

    .site-footer .container {
        flex-direction: column;
        text-align: center;
    }

    .features {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   PRE-ALPHA BANNER
   ============================================ */
.pre-alpha-banner {
    background-color: #2a1a1a;
    border-bottom: 2px solid var(--color-accent);
    padding: var(--space-md) 0;
    text-align: center;
    font-size: var(--font-size-sm);
}

.pre-alpha-banner strong {
    color: var(--color-accent-hover);
    margin-right: var(--space-sm);
}

.pre-alpha-banner a {
    color: var(--color-accent-hover);
    text-decoration: underline;
}

.pre-alpha-banner a:hover {
    color: #ff6b6b;
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999999;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1;
    pointer-events: all;
}

.modal-content {
    position: relative;
    background-color: var(--color-surface);
    border: 2px solid var(--color-accent);
    border-radius: var(--radius-md);
    padding: var(--space-2xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 2;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
    pointer-events: all;
}

.modal-content h2 {
    color: var(--color-text-header);
    margin-bottom: var(--space-lg);
    text-align: center;
}

.modal-content p {
    margin-bottom: var(--space-base);
    line-height: 1.6;
}

.modal-content ul {
    margin-left: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.modal-content li {
    margin-bottom: var(--space-sm);
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: var(--space-base);
    margin-top: var(--space-xl);
    justify-content: center;
    flex-wrap: wrap;
}

.modal-actions .btn {
    flex: 1;
    min-width: 150px;
}

/* Prevent scrolling when modal is active */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Skip to main content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-accent);
    color: var(--color-text-header);
    padding: var(--space-sm) var(--space-base);
    text-decoration: none;
    border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
    top: 0;
}

/* ============================================
   MARKDOWN CONTENT STYLES
   ============================================ */
.message-body,
#character-description {
    /* Reset white-space to allow normal markdown rendering */
    white-space: normal !important;
}

/* Markdown Paragraphs */
.message-body p,
#character-description p {
    margin: 0 0 0.75em 0;
}

.message-body p:last-child,
#character-description p:last-child {
    margin-bottom: 0;
}

/* Markdown Headings */
.message-body h1,
#character-description h1 {
    font-size: 1.5em;
    font-weight: 600;
    margin: 0.5em 0 0.5em 0;
    color: #ffffff;
    border-bottom: 1px solid #3a3a3a;
    padding-bottom: 0.3em;
}

.message-body h2,
#character-description h2 {
    font-size: 1.3em;
    font-weight: 600;
    margin: 0.5em 0 0.4em 0;
    color: #ffffff;
}

.message-body h3,
#character-description h3 {
    font-size: 1.15em;
    font-weight: 600;
    margin: 0.5em 0 0.3em 0;
    color: #e0e0e0;
}

.message-body h4,
#character-description h4,
.message-body h5,
#character-description h5,
.message-body h6,
#character-description h6 {
    font-size: 1em;
    font-weight: 600;
    margin: 0.4em 0 0.3em 0;
    color: #e0e0e0;
}

/* Markdown Emphasis */
.message-body strong,
#character-description strong,
.message-body b,
#character-description b {
    font-weight: 700;
    /* Use inherit to respect parent color (e.g., from {color:red}...{/color} syntax) */
    color: inherit;
}

.message-body em,
#character-description em,
.message-body i,
#character-description i {
    font-style: italic;
    /* Use inherit to respect parent color (e.g., from {color:red}...{/color} syntax) */
    /* Falls back to parent color, which is typically white */
    color: inherit;
}

/* Markdown Links */
.message-body a,
#character-description a {
    color: #66aaff;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-bottom-color 0.2s;
}

.message-body a:hover,
#character-description a:hover {
    border-bottom-color: #66aaff;
}

.message-body a:visited,
#character-description a:visited {
    color: #9988ff;
}

/* Markdown Code */
.message-body code,
#character-description code {
    background-color: #333333;
    color: #ff79c6;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: var(--font-family-mono);
    font-size: 0.9em;
}

.message-body pre,
#character-description pre {
    background-color: #333333;
    padding: 0.75em;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0.75em 0;
    border-left: 3px solid #66aaff;
}

.message-body pre code,
#character-description pre code {
    background-color: transparent;
    padding: 0;
    color: #e0e0e0;
}

/* Markdown Lists */
.message-body ul,
#character-description ul {
    list-style-type: disc;
    margin: 0.5em 0 0.75em 1.5em;
    padding-left: 0.5em;
}

.message-body ol,
#character-description ol {
    list-style-type: decimal;
    margin: 0.5em 0 0.75em 1.5em;
    padding-left: 0.5em;
}

.message-body li,
#character-description li {
    margin: 0.3em 0;
    line-height: 1.5;
}

.message-body li > p,
#character-description li > p {
    margin: 0.2em 0;
}

/* Nested lists */
.message-body ul ul,
#character-description ul ul,
.message-body ol ol,
#character-description ol ol,
.message-body ul ol,
#character-description ul ol,
.message-body ol ul,
#character-description ol ul {
    margin: 0.3em 0 0.3em 1em;
}

/* Markdown Blockquotes */
.message-body blockquote,
#character-description blockquote {
    border-left: 4px solid #66aaff;
    padding: 0.5em 0 0.5em 1em;
    margin: 0.75em 0;
    background-color: #252525;
    color: #cccccc;
    font-style: italic;
}

.message-body blockquote p,
#character-description blockquote p {
    margin: 0.3em 0;
}

/* Markdown Horizontal Rules */
.message-body hr,
#character-description hr {
    border: none;
    border-top: 2px solid #3a3a3a;
    margin: 1em 0;
}

/* Markdown Tables */
.message-body table,
#character-description table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.75em 0;
    overflow-x: auto;
    display: block;
}

.message-body th,
#character-description th,
.message-body td,
#character-description td {
    border: 1px solid #3a3a3a;
    padding: 0.5em 0.75em;
    text-align: left;
}

.message-body th,
#character-description th {
    background-color: #333333;
    font-weight: 600;
    color: #ffffff;
}

.message-body tr:nth-child(even),
#character-description tr:nth-child(even) {
    background-color: #252525;
}

/* Table cell alignment overrides (from markdown or inline styles) */
.message-body td[align="center"],
.message-body th[align="center"],
#character-description td[align="center"],
#character-description th[align="center"] {
    text-align: center;
}

.message-body td[align="right"],
.message-body th[align="right"],
#character-description td[align="right"],
#character-description th[align="right"] {
    text-align: right;
}

.message-body td[valign="top"],
.message-body th[valign="top"],
#character-description td[valign="top"],
#character-description th[valign="top"] {
    vertical-align: top;
}

.message-body td[valign="middle"],
.message-body th[valign="middle"],
#character-description td[valign="middle"],
#character-description th[valign="middle"] {
    vertical-align: middle;
}

.message-body td[valign="bottom"],
.message-body th[valign="bottom"],
#character-description td[valign="bottom"],
#character-description th[valign="bottom"] {
    vertical-align: bottom;
}

/* Markdown Images in chat messages */
.message-body img {
    max-width: 50vw;
    max-height: 50vh;
    height: auto;
    border-radius: 4px;
    margin: 0.5em 0;
    object-fit: contain;
    /* Prevent layout breaks from images */
    display: block;
}

/* Profile images - allow larger sizes */
#character-description img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 0.5em 0;
}

/* Markdown Strikethrough */
.message-body del,
#character-description del,
.message-body s,
#character-description s {
    text-decoration: line-through;
    color: #999999;
}

/* Markdown Mark/Highlight */
.message-body mark,
#character-description mark {
    background-color: #ffeb3b;
    color: #1a1a1a;
    padding: 0.1em 0.2em;
    border-radius: 2px;
}

/* Subscript and Superscript */
.message-body sub,
#character-description sub,
.message-body sup,
#character-description sup {
    font-size: 0.75em;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}

.message-body sup,
#character-description sup {
    top: -0.5em;
}

.message-body sub,
#character-description sub {
    bottom: -0.25em;
}

/* ============================================
   UNIFIED NOTIFICATION BANNER (Drakensberg)
   ============================================ */
.notification-banner {
    position: fixed;
    top: 70px;  /* Position below navbar to avoid blocking navigation */
    left: 0;
    right: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.notification-banner.info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.notification-banner.success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.notification-banner.warning {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.banner-message {
    flex: 1;
}

.banner-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.8;
    padding: 0 0.5rem;
    margin-left: 1rem;
}

.banner-close:hover {
    opacity: 1;
}

/* ============================================
   ONLINE STATUS INDICATORS (Site-wide)
   ============================================ */

/* Green: User is actively in chat (in at least one room) */
.status-in-chat {
    color: #4caf50;
    font-weight: 500;
}

/* Yellow/amber: User is online but just browsing the site */
.status-online {
    color: #ffbb33;
    font-weight: 500;
}

/* Gray: User is offline */
.status-offline {
    color: #999999;
}

/* Gold: User is looking for RP (diamond icon ◆) */
.status-looking {
    color: #ffd700;
    font-weight: 500;
}

/* Orange: User is away (half moon icon ◐) */
.status-away {
    color: #ff9800;
    font-weight: 500;
}

/* Red: User is busy (square icon ■) */
.status-busy {
    color: #f44336;
    font-weight: 500;
}

/* Dark red: Do Not Disturb (no entry icon ⊘) */
.status-dnd {
    color: #b71c1c;
    font-weight: 500;
}

/* ============================================
   PROFILE HOVER CARD
   ============================================ */

.profile-hover-card {
    position: fixed;
    width: 350px;
    max-width: 90vw;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    opacity: 0;
    transition: opacity var(--transition-base);
    pointer-events: all;
    overflow: hidden; /* Contain any overflowing content */
}

/* Contain inline images in hover cards */
.profile-hover-card img {
    max-width: 100%;
    height: auto;
}

.profile-hover-card.visible {
    opacity: 1;
}

.hover-card-link {
    display: flex;
    gap: 12px;
    padding: 16px;
    text-decoration: none;
    color: inherit;
}

.hover-card-link:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.hover-card-avatar {
    width: 80px;
    height: 80px;
    min-width: 80px;
    max-width: 80px;
    min-height: 80px;
    max-height: 80px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
}

.hover-card-avatar-placeholder {
    background-color: #3a3a3a;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999999;
    font-size: 48px;
    font-weight: 300;
    user-select: none;
    overflow: hidden;
}

.hover-card-content {
    flex: 1;
    min-width: 0; /* Allow text truncation */
    overflow: hidden; /* Prevent inline images/links from stretching out */
}

.hover-card-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-header);
    margin: 0 0 4px 0;
}

.hover-card-meta {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.hover-card-footer {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--color-border);
}

.hover-card-cta {
    font-size: 12px;
    color: var(--color-accent);
    font-weight: 500;
}

.hover-card-link:hover .hover-card-cta {
    color: var(--color-accent-hover);
}

/* Profile link styling (for character names in content) */
.profile-link {
    color: var(--color-text);
    text-decoration: none;
    cursor: pointer;
    border-bottom: 1px dotted var(--color-border);
}

.profile-link:hover {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

/* ============================================
   USER BADGES
   ============================================ */
.user-badges {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.user-badges .badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
    cursor: help;
    transition: opacity var(--transition-fast);
}

.user-badges .badge:hover {
    opacity: 0.9;
}

.user-badges .badge-icon {
    font-size: 14px;
    line-height: 1;
}

.user-badges .badge-label {
    line-height: 1;
}

/* Badge size variations */
.user-badges--small .badge {
    padding: 2px 6px;
    font-size: 11px;
}

.user-badges--small .badge-icon {
    font-size: 12px;
}

.user-badges--large .badge {
    padding: 6px 12px;
    font-size: 15px;
}

.user-badges--large .badge-icon {
    font-size: 16px;
}

/* Hide badge labels on very small screens */
@media (max-width: 480px) {
    .user-badges .badge-label {
        display: none;
    }

    .user-badges .badge {
        padding: 4px 6px;
    }
}
