/* ==========================================================================
   FastJoins v2 — layout & shared components
   ========================================================================== */

.app {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.app-body {
    flex: 1;
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 40px 24px 72px;
}

.app-body.wide { max-width: none; padding: 0 0 72px; }

/* ---------- Page header ---------- */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.page-head h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.page-head p {
    color: var(--text-2);
    margin-top: 6px;
    max-width: 560px;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title .count {
    color: var(--text-2);
    background: var(--surface-2);
    border-radius: 99px;
    padding: 0 7px;
    font-size: 12px;
    letter-spacing: 0;
}

/* ---------- Card ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-head h2 {
    font-size: 15px;
    font-weight: 600;
}

.card-head .hint {
    font-size: 13px;
    color: var(--text-3);
}

.card-body { padding: 20px; }
.card-body.flush { padding: 0; }

/* ---------- Buttons ---------- */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.1s var(--ease);
}

.button:hover { background: var(--accent-hover); }
.button:active { transform: translateY(1px); }
.button svg { width: 16px; height: 16px; flex-shrink: 0; }

.button.lg { height: 46px; padding: 0 22px; font-size: 15px; }
.button.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.button.block { width: 100%; }

.button.secondary {
    background: var(--surface-2);
    border-color: var(--border-strong);
    color: var(--text);
}
.button.secondary:hover { background: var(--surface-3); }

.button.ghost { background: transparent; color: var(--text-2); }
.button.ghost:hover { background: var(--surface-2); color: var(--text); }

.button.success { background: var(--green); }
.button.success:hover { background: #279a5b; }

.button.danger { background: var(--red-soft); color: var(--red); }
.button.danger:hover { background: rgba(239, 90, 111, 0.24); }

.button:disabled,
.button[disabled] {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text-3);
    cursor: not-allowed;
    transform: none;
}

/* ---------- Form fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-2); }

.input,
.select {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-raised);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.input::placeholder { color: var(--text-3); }
.input:hover, .select:hover { border-color: #414756; }
.input:focus, .select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.select {
    appearance: none;
    padding-right: 36px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a4a9b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}
.select option, .select optgroup { background: var(--surface); }

/* ---------- Badge / pill ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 22px;
    padding: 0 8px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-2);
    white-space: nowrap;
}
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.badge.green { background: var(--green-soft); color: #5fd394; }
.badge.red { background: var(--red-soft); color: #ff8c9c; }
.badge.amber { background: var(--amber-soft); color: #f0bd6a; }

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-3);
    flex-shrink: 0;
}
.dot.green { background: var(--green); }

/* ---------- Progress ---------- */
.progress {
    height: 6px;
    border-radius: 99px;
    background: var(--surface-3);
    overflow: hidden;
}
.progress > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 0.6s var(--ease);
}

/* ---------- Callout ---------- */
.callout {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid rgba(229, 162, 58, 0.28);
    background: var(--amber-soft);
    color: #f3d3a0;
    font-size: 14px;
}
.callout svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; color: var(--amber); }
.callout.info { border-color: rgba(60, 120, 242, 0.3); background: var(--accent-soft); color: #c4d6ff; }
.callout.info svg { color: var(--accent-text); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text-2);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background-color 0.1s; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.table td.strong { color: var(--text); font-weight: 600; }
.table td.right, .table th.right { text-align: right; }

.scroll-y { max-height: 360px; overflow-y: auto; }
.scroll-y .table th { position: sticky; top: 0; background: var(--surface); z-index: 1; }

/* ---------- Mentions (Discord-like) ---------- */
.mention {
    padding: 1px 4px;
    border-radius: 4px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.1s, color 0.1s;
}
.mention.user { color: #c9d6ff; background: rgba(60, 120, 242, 0.18); }
.mention.user:hover { color: #fff; background: var(--accent); }
.mention.timestamp { color: var(--text-2); background: var(--surface-2); }
.mention.timestamp:hover { color: var(--text); }

/* ---------- Avatar placeholder ---------- */
.acronym {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-3);
    color: var(--text-2);
    font-weight: 600;
    text-transform: uppercase;
    overflow: hidden;
}

/* ---------- Empty / error states ---------- */
.empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-3);
    font-size: 14px;
}
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

.state-error {
    max-width: 480px;
    margin: 64px auto;
    text-align: center;
}
.state-error h1 { font-size: 22px; margin-bottom: 8px; }
.state-error p { color: var(--text-2); margin-bottom: 20px; }

/* ---------- Skeleton ---------- */
.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
    background-size: 200% 100%;
    animation: skeleton 1.4s ease-in-out infinite;
    border-radius: var(--radius-sm);
}
@keyframes skeleton { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- Loader (thin top bar) ---------- */
.app-loader {
    position: fixed;
    inset: 0 0 auto 0;
    height: 2px;
    z-index: 100;
    overflow: hidden;
    pointer-events: none;
}
.app-loader::before {
    content: "";
    position: absolute;
    inset: 0;
    width: 40%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    animation: loaderSlide 1s var(--ease) infinite;
}
@keyframes loaderSlide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
body.is-loading { cursor: progress; }

/* ---------- Toasts ---------- */
.toasts {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 200;
    max-width: calc(100vw - 40px);
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 340px;
    max-width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    font-size: 14px;
    animation: toastIn 0.25s var(--ease);
}
.toast.out { opacity: 0; transform: translateY(6px); transition: 0.2s var(--ease); }
.toast .dot { margin-top: 6px; }
.toast.error .dot { background: var(--red); }
.toast.success .dot { background: var(--green); }
.toast small { display: block; color: var(--text-3); font-size: 12px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Tooltip ---------- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translate(-50%, -2px);
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    background: #0a0b0e;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s, transform 0.12s;
    z-index: 30;
}
[data-tooltip]:hover::after { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
    .app-body { padding: 24px 16px 96px; }
    .app-body.wide { padding: 0 0 96px; }
    .page-head h1 { font-size: 24px; }
    .card-head, .card-body { padding-left: 16px; padding-right: 16px; }
    .table th, .table td { padding-left: 16px; padding-right: 16px; }
    .toasts { right: 12px; left: 12px; bottom: 84px; }
    .toast { width: 100%; }
    [data-tooltip]::after { display: none; }
}
