/*
 * Loopback v1 SPA — overlays dashboard-v3.css (layout, shell, dashboard widgets).
 * Keep tokens aligned with v3 (--lb-*).
 */

:root {
    --color-text: var(--lb-text);
    --color-muted: var(--lb-muted);
    --color-border: #e2e8f0;
    --color-surface: #f8fafc;
    --color-card: #fff;
    --color-primary: var(--lb-blue);
    --color-primary-hover: #2563eb;
    --color-danger: #dc2626;
    --color-warning: #d97706;
    --radius: var(--lb-radius-sm);
    --radius-sm: 10px;
    --shadow: var(--lb-shadow);
    --shadow-lg: var(--lb-shadow-lg);
    --font: var(--lb-font);
}

/* Shell helpers (SPA) */
.lb-notif-wrap {
    position: relative;
}

.lb-icon-btn .lb-badge-count {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    background: #ef4444;
    color: #fff;
    border-radius: 999px;
    pointer-events: none;
}

.lb-icon-btn {
    position: relative;
}

/* Sidebar — redesigned help card (overrides dashboard-v3 .lb-help) */
.lb-help.lb-help--card {
    margin-top: 8px;
    padding: 0.9rem 0.95rem 1rem;
    border-radius: 16px;
    background: linear-gradient(155deg, #ffffff 0%, #f1f5f9 55%, #eef2ff 100%);
    border: 1px solid rgba(15, 23, 42, 0.07);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.95) inset,
        0 1px 2px rgba(15, 23, 42, 0.04),
        0 14px 36px -12px rgba(59, 130, 246, 0.18);
}

.lb-help--card .lb-help-visual {
    position: relative;
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lb-help--card .lb-help-glow {
    position: absolute;
    inset: -6px;
    border-radius: 18px;
    background:
        radial-gradient(circle at 25% 20%, rgba(59, 130, 246, 0.35), transparent 58%),
        radial-gradient(circle at 85% 80%, rgba(139, 92, 246, 0.28), transparent 55%);
    opacity: 0.9;
    pointer-events: none;
}

.lb-help--card .lb-help-ico {
    position: relative;
    z-index: 1;
    color: #1d4ed8;
    filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.08));
}

.lb-help--card .lb-help-copy {
    text-align: center;
}

.lb-help--card .lb-help-kicker {
    margin: 0 0 0.15rem;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #94a3b8;
}

.lb-help--card .lb-help-title {
    margin: 0 0 0.4rem;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--lb-text);
}

.lb-help--card .lb-help-desc {
    margin: 0 0 0.15rem;
    font-size: 0.75rem;
    line-height: 1.45;
    color: #64748b;
    font-weight: 500;
}

.lb-help--card .lb-help-btn {
    margin-top: 0.75rem;
    width: 100%;
    min-height: 38px;
    height: auto;
    padding: 0.45rem 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border-radius: 11px;
    border: 1px solid rgba(37, 99, 235, 0.35);
    background: transparent;
    color: #1d4ed8;
    font-size: 0.75rem;
    font-weight: 700;
    text-decoration: none;
    box-sizing: border-box;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.lb-help--card .lb-help-btn:hover {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.lb-help--card .lb-help-btn:focus-visible {
    outline: 2px solid var(--lb-blue);
    outline-offset: 2px;
}

/* Inner pages: hero (dashboard uses .lb-welcome from v3) */
.lb-page {
    max-width: 1100px;
}

.lb-hero {
    margin-bottom: 24px;
}

.lb-hero h1 {
    margin: 0 0 8px;
    font-size: clamp(22px, 3vw, 28px);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: var(--lb-text);
}

.lb-hero h1 span {
    color: var(--lb-blue);
}

.lb-hero-sub {
    margin: 0;
    font-size: 15px;
    color: var(--lb-muted);
    font-weight: 500;
}

/* Activity chart — room for in-chart legend */
.lb-chart-card-inner .lb-chart-canvas-wrap {
    min-height: 220px;
}

/* Donut + feed row (extra vs static v3) */
.lb-donut-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
    align-items: stretch;
    margin-bottom: 28px;
}

@media (max-width: 960px) {
    .lb-donut-row {
        grid-template-columns: 1fr;
    }
}

.lb-donut-wrap {
    position: relative;
    height: 220px;
    max-width: 280px;
    margin: 0 auto;
    padding: 8px 0 16px;
}

a.lb-card-link {
    color: var(--lb-blue);
    font-weight: 700;
    font-size: 12px;
}

/* Tabs */
.lb-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--lb-line);
}

.lb-tab {
    padding: 8px 14px;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    color: var(--lb-muted);
    cursor: pointer;
    margin-bottom: -1px;
    text-decoration: none;
}

.lb-tab.is-active {
    color: var(--lb-blue);
    border-bottom-color: var(--lb-blue);
}

/* Mission list */
.lb-mission-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lb-mission-card {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: var(--lb-radius-sm);
    padding: 16px;
    background: var(--lb-surface);
    text-decoration: none;
    color: inherit;
    display: block;
    transition: box-shadow 0.15s;
}

.lb-mission-card:hover {
    box-shadow: var(--lb-shadow);
}

.lb-mission-card h3 {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 600;
}

.lb-mission-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    color: var(--lb-muted);
}

.lb-mission-card .lb-mission-bar span {
    background: linear-gradient(90deg, #3b82f6 0%, #6366f1 50%, #8b5cf6 100%);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.35);
}

/* Pills */
.lb-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.lb-pill--p0 {
    background: #fef2f2;
    color: #b91c1c;
}

.lb-pill--p1 {
    background: #fff7ed;
    color: #c2410c;
}

.lb-pill--p2 {
    background: #eff6ff;
    color: #1d4ed8;
}

.lb-pill--p3 {
    background: #f1f5f9;
    color: var(--lb-muted);
}

.lb-status {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 6px;
}

.lb-status.is-progress {
    background: #dbeafe;
    color: #1e40af;
}

.lb-status.is-pending {
    background: #f1f5f9;
    color: #475569;
}

.lb-status.is-done {
    background: #d1fae5;
    color: #15803d;
}

.lb-tag {
    display: inline-block;
    font-size: 11px;
    padding: 0.15rem 0.4rem;
    background: #f1f5f9;
    border-radius: 4px;
    color: var(--lb-muted);
}

.lb-mission-bar {
    height: 6px;
    background: rgba(15, 23, 42, 0.06);
    border-radius: 999px;
    margin-top: 8px;
    overflow: hidden;
}

.lb-mission-bar span {
    display: block;
    height: 100%;
    border-radius: 999px;
}

/* Avatars in main (match header blue gradient) */
.lb-main .lb-avatar {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--lb-blue), #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.lb-avatar--sm {
    width: 28px;
    height: 28px;
    font-size: 10px;
}

/* Buttons */
.lb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--lb-radius-sm);
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
}

.lb-btn--primary {
    background: var(--lb-blue);
    color: #fff;
}

.lb-btn--primary:hover {
    filter: brightness(1.05);
}

.lb-btn--ghost {
    background: transparent;
    border-color: rgba(15, 23, 42, 0.12);
    color: var(--lb-text);
}

.lb-btn--ghost:hover {
    background: #f1f5f9;
}

.lb-btn--danger {
    background: var(--color-danger);
    color: #fff;
}

.lb-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}

/* Mission detail */
.lb-detail-grid {
    display: grid;
    gap: 16px;
}

@media (min-width: 900px) {
    .lb-detail-grid {
        grid-template-columns: 1fr 300px;
    }
}

.lb-prose {
    font-size: 0.95rem;
}

.lb-prose pre {
    background: #f1f5f9;
    padding: 0.75rem 1rem;
    border-radius: var(--lb-radius-sm);
    overflow: auto;
    font-size: 0.85rem;
}

.lb-timeline {
    list-style: none;
    margin: 0;
    padding: 0;
}

.lb-timeline li {
    padding: 0.65rem 0;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    font-size: 0.85rem;
}

.lb-timeline time {
    color: var(--lb-muted);
    font-size: 0.75rem;
}

.lb-side-card {
    padding: 16px;
}

.lb-side-card h3 {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 700;
}

/* Forms */
.lb-form-group {
    margin-bottom: 1rem;
}

.lb-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
}

.lb-input,
.lb-select,
.lb-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: var(--lb-radius-sm);
    font: inherit;
}

.lb-textarea {
    min-height: 140px;
    resize: vertical;
}

/* Modal */
.lb-modal-root:empty {
    display: none;
}

.lb-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.lb-modal {
    background: var(--lb-surface);
    border-radius: var(--lb-radius);
    max-width: 480px;
    width: 100%;
    box-shadow: var(--lb-shadow-lg);
    padding: 1.25rem;
}

.lb-modal h2 {
    margin: 0 0 0.75rem;
    font-size: 1.1rem;
}

.lb-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* Undo toast */
.lb-undo-host:empty {
    display: none;
}

.lb-undo {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    background: var(--lb-text);
    color: #fff;
    padding: 0.65rem 1rem;
    border-radius: var(--lb-radius-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    box-shadow: var(--lb-shadow-lg);
}

.lb-undo button {
    background: none;
    border: none;
    color: #93c5fd;
    font-weight: 700;
    cursor: pointer;
    font: inherit;
}

/* Empty */
.lb-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--lb-muted);
}

.lb-empty h2 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    color: var(--lb-text);
}

/* Table */
.lb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.lb-table th,
.lb-table td {
    padding: 0.65rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.lb-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--lb-muted);
}

/* Signals / settings */
.lb-signal-card {
    padding: 1.25rem;
    border-left: 4px solid var(--color-warning);
}

.lb-signal-card.watch {
    border-left-color: var(--color-warning);
}

.lb-settings-section {
    margin-bottom: 1.5rem;
}

.lb-settings-section h3 {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
}

.lb-integration {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: var(--lb-radius-sm);
    margin-bottom: 0.5rem;
}

.lb-badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.lb-badge-card {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: var(--lb-radius);
    padding: 1rem;
    text-align: center;
}

.lb-badge-card.locked {
    opacity: 0.55;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ── Loading state ────────────────────────────────────────────────────────── */
.lb-loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 3rem 1.5rem;
    color: var(--color-muted, #94a3b8);
    font-size: 0.9rem;
}

.lb-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(148, 163, 184, 0.25);
    border-top-color: var(--lb-accent, #4f46e5);
    border-radius: 50%;
    animation: lb-spin 0.7s linear infinite;
    flex-shrink: 0;
}

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

/* ── Error state ─────────────────────────────────────────────────────────── */
.lb-error {
    padding: 1rem 1.5rem;
    background: #fef2f2;
    color: #b91c1c;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    margin: 1rem 0;
}

/* ── Notification preference table ───────────────────────────────────────── */
.lb-settings-hint {
    color: var(--color-muted, #94a3b8);
    font-size: 0.875rem;
    margin: 0 0 1rem;
}

.lb-pref-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.lb-pref-table th,
.lb-pref-table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--lb-border, rgba(255, 255, 255, 0.08));
}

.lb-pref-table th {
    color: var(--color-muted, #94a3b8);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Toggle switch ───────────────────────────────────────────────────────── */
.lb-toggle {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.lb-toggle input {
    display: none;
}

.lb-toggle-track {
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background: var(--lb-surface-2, rgba(255, 255, 255, 0.1));
    transition: background 0.2s;
    position: relative;
}

.lb-toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.lb-toggle input:checked + .lb-toggle-track {
    background: var(--lb-accent, #4f46e5);
}

.lb-toggle input:checked + .lb-toggle-track::after {
    transform: translateX(16px);
}

.lb-toggle--disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── User dropdown (topbar) ──────────────────────────────────────────────── */
.lb-user-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    color: inherit;
    font: inherit;
}

.lb-user-btn:hover {
    background: rgba(255,255,255,0.06);
}

.lb-user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--lb-surface, #1e1e2e);
    border: 1px solid var(--lb-border, rgba(255,255,255,0.08));
    border-radius: 0.5rem;
    min-width: 160px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    z-index: 200;
    overflow: hidden;
}

.lb-user-dropdown a,
.lb-user-dropdown button {
    display: block;
    width: 100%;
    padding: 0.65rem 1rem;
    font-size: 0.875rem;
    color: inherit;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: none;
    font: inherit;
}

.lb-user-dropdown a:hover,
.lb-user-dropdown button:hover {
    background: rgba(255,255,255,0.06);
}

.lb-avatar--img {
    border-radius: 50%;
    object-fit: cover;
}
