/* Global styles for jamr.io: design tokens and shared components */

:root {
    /* Surfaces */
    --bg: #0d0e10;
    --surface: #16171a;
    --surface-2: #1e1f23;
    --surface-3: #27282d;
    --border: #2a2b31;
    --border-strong: #3a3b42;

    /* Text */
    --text: #f4f4f5;
    --text-muted: #a1a1aa;
    --text-faint: #71717a;

    /* Brand */
    --accent: #1db954;
    --accent-hover: #1ed760;
    --accent-text: #04140a;
    --accent-soft: rgba(29, 185, 84, 0.12);
    --accent-border: rgba(29, 185, 84, 0.35);

    /* Status */
    --danger: #f04444;
    --danger-soft: rgba(240, 68, 68, 0.12);
    --warning: #f5a524;

    /* Shape and motion */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    --transition: 150ms ease;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, Cantarell, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* The hidden attribute must win over component display rules (e.g. .btn) */
[hidden] {
    display: none !important;
}

/* Form controls don't inherit fonts by default */
button,
input,
textarea,
select {
    font: inherit;
    color: inherit;
}

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

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

.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------- Top bar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(13, 14, 16, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 60px;
}

.brand {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
    text-decoration: none;
}

.brand span {
    color: var(--accent);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.topbar-user-name {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

a.topbar-user-name:hover {
    color: var(--text);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--surface-3);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--accent-hover);
}

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

.btn-secondary:hover:not(:disabled) {
    background-color: var(--surface-2);
    border-color: var(--text-faint);
}

.btn-ghost {
    background: none;
    color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
    background-color: var(--surface-2);
    color: var(--text);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.05rem;
}

.btn-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
}

.btn-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* ---------- Inputs ---------- */

.input {
    width: 100%;
    padding: 11px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    transition: border-color var(--transition), background-color var(--transition);
}

.input::placeholder {
    color: var(--text-faint);
}

.input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface);
}

/* ---------- Chips and tags ---------- */

.chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: capitalize;
}

.chip-accent {
    background: var(--accent-soft);
    color: var(--accent);
}

/* ---------- Footer ---------- */

footer {
    text-align: center;
    padding: 32px 0;
    color: var(--text-faint);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: 64px;
}

/* ---------- Loading, error and empty states ---------- */

.loading-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 20px;
    text-align: center;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--surface-3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text,
.loading {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.error-message {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background-color: var(--danger-soft);
    border: 1px solid rgba(240, 68, 68, 0.35);
    color: #fecaca;
    border-radius: var(--radius-sm);
}

.error-icon {
    font-size: 1.1rem;
}

.error-text {
    flex: 1;
}

.error-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

/* Floating error toast (showError without a container) */
.error-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    width: max-content;
    max-width: calc(100vw - 32px);
    background-color: #2a1414;
    box-shadow: var(--shadow);
    animation: toastIn 0.2s ease-out;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}

/* ---------- Toasts (socket.js showToast) ---------- */

.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: max-content;
    max-width: calc(100vw - 32px);
    pointer-events: none;
}

.toast {
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    color: var(--text);
    font-size: 0.9rem;
    box-shadow: var(--shadow);
    animation: toastIn 0.2s ease-out;
}

.toast.success {
    border-color: var(--accent-border);
}

.toast.error {
    border-color: rgba(240, 68, 68, 0.5);
    background: #2a1414;
}

.toast.warning {
    border-color: rgba(245, 165, 36, 0.5);
}

/* ---------- Animations ---------- */

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes toastIn {
    from { opacity: 0; translate: 0 8px; }
    to { opacity: 1; translate: 0 0; }
}

@keyframes toastOut {
    to { opacity: 0; translate: 0 8px; }
}

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

@media (max-width: 640px) {
    .container {
        padding: 0 16px;
    }

    .topbar-user-name {
        display: none;
    }
}

/* ---------- Role badges ---------- */

.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.5;
}

.role-mod {
    background: rgba(56, 189, 248, 0.15);
    color: #7dd3fc;
}

.role-admin {
    background: rgba(245, 165, 36, 0.15);
    color: #fcd34d;
}

.role-overseer {
    background: rgba(192, 132, 252, 0.18);
    color: #d8b4fe;
}
