/**
 * Fine Thread portal — design system (Bootstrap 5 bridge + layout chrome).
 * Loaded after Bootstrap; overrides tokens and component chrome globally.
 */

:root {
    --ft-font-sans: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
    --ft-font-display: "Outfit", system-ui, sans-serif;
    --ft-font-mono: "JetBrains Mono", ui-monospace, monospace;

    --ft-ink: #0b1220;
    --ft-ink-muted: #556987;
    --ft-canvas: #e8f0fa;
    --ft-surface: #ffffff;
    --ft-surface-2: #f1f5fb;
    --ft-border: rgba(11, 18, 32, 0.07);
    --ft-border-strong: rgba(11, 18, 32, 0.12);

    /* Sidebar gradient stops (referenced in .ft-sidebar) */
    --ft-sidebar-a: #0f172a;
    --ft-sidebar-b: #1e1b4b;
    --ft-sidebar-c: #134e4a;
    --ft-sidebar-text: rgba(255, 255, 255, 0.78);
    --ft-sidebar-text-hover: #fff;
    --ft-sidebar-muted: rgba(226, 232, 240, 0.45);
    --ft-sidebar-active: rgba(45, 212, 191, 0.18);
    --ft-sidebar-border: rgba(255, 255, 255, 0.1);

    --ft-accent: #0d9488;
    --ft-accent-hover: #14b8a6;
    --ft-accent-soft: rgba(13, 148, 136, 0.14);
    --ft-accent-ink: #115e59;

    --ft-header-h: 3.75rem;
    --ft-radius: 0.875rem;
    --ft-radius-sm: 0.5rem;
    --ft-shadow: 0 1px 2px rgba(12, 14, 18, 0.04), 0 4px 24px rgba(12, 14, 18, 0.06);
    --ft-shadow-lg: 0 4px 8px rgba(12, 14, 18, 0.04), 0 16px 48px rgba(12, 14, 18, 0.08);

    /* Bootstrap 5.3 theme bridge */
    --bs-body-bg: var(--ft-canvas);
    --bs-body-color: var(--ft-ink);
    --bs-font-sans-serif: var(--ft-font-sans);
    --bs-border-color: var(--ft-border-strong);
    --bs-border-radius: var(--ft-radius-sm);
    --bs-primary: #0d9488;
    --bs-primary-rgb: 13, 148, 136;
    --bs-link-color: #0f766e;
    --bs-link-hover-color: #0d9488;
    --bs-secondary-color: var(--ft-ink-muted);
    --bs-success: #059669;
    --bs-danger: #dc2626;
    --bs-warning: #d97706;
    --bs-info: #0284c7;
}

html {
    scroll-behavior: smooth;
}

body.ft-portal {
    margin: 0;
    font-family: var(--ft-font-sans);
    font-size: 0.9375rem;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
}

.ft-display {
    font-family: var(--ft-font-display);
    letter-spacing: -0.03em;
}

/* ——— Authenticated shell ——— */
.ft-app-shell {
    min-height: 100vh;
    background-color: #e0e7ef;
    background-image:
        radial-gradient(ellipse 120% 90% at 100% -10%, rgba(56, 189, 248, 0.22), transparent 52%),
        radial-gradient(ellipse 90% 70% at -10% 110%, rgba(129, 140, 248, 0.2), transparent 50%),
        radial-gradient(ellipse 60% 50% at 50% 40%, rgba(255, 255, 255, 0.85), transparent),
        linear-gradient(168deg, #f0f9ff 0%, #eef2ff 38%, #ecfeff 72%, #f8fafc 100%);
}

.ft-sidebar.offcanvas-lg.offcanvas-start {
    --bs-offcanvas-bg: var(--ft-sidebar-a);
    --bs-offcanvas-color: #f1f5f9;
    width: 17rem;
    max-width: 90vw;
    max-width: min(17rem, 90vw);
    background:
        linear-gradient(125deg, rgba(255, 255, 255, 0.09) 0%, transparent 42%),
        linear-gradient(200deg, transparent 0%, rgba(15, 118, 110, 0.35) 100%),
        linear-gradient(165deg, var(--ft-sidebar-a) 0%, var(--ft-sidebar-b) 42%, var(--ft-sidebar-c) 100%) !important;
    color: #f1f5f9;
    border-right: 1px solid var(--ft-sidebar-border);
    box-shadow:
        4px 0 40px rgba(15, 23, 42, 0.35),
        inset -1px 0 0 rgba(255, 255, 255, 0.06);
}

.ft-sidebar .offcanvas-body,
.ft-sidebar .offcanvas-header {
    background: transparent;
}

.ft-sidebar .offcanvas-header {
    border-bottom-color: var(--ft-sidebar-border) !important;
}

.ft-sidebar-brand {
    padding: 1.25rem 1rem 1rem;
    border-bottom: 1px solid var(--ft-sidebar-border);
}

.ft-sidebar-brand-mark {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--ft-radius-sm);
    background: linear-gradient(135deg, #2dd4bf 0%, #6366f1 48%, #38bdf8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--ft-font-display);
    font-weight: 800;
    font-size: 0.95rem;
    color: #fff;
    letter-spacing: -0.05em;
    box-shadow:
        0 4px 16px rgba(45, 212, 191, 0.35),
        0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

.ft-sidebar-brand-text {
    font-family: var(--ft-font-display);
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.25;
    color: #fff;
    letter-spacing: -0.02em;
}

.ft-sidebar-brand-tag {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ft-sidebar-muted);
    margin-top: 0.25rem;
}

.ft-sidebar-nav {
    padding: 0.75rem 0.625rem;
    flex: 1;
    overflow: auto;
}

.ft-sidebar-nav .nav-link {
    color: var(--ft-sidebar-text) !important;
    border-radius: var(--ft-radius-sm);
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.125rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    border: 1px solid transparent;
    transition:
        background 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease;
}

.ft-sidebar-nav .nav-link .ft-nav-icon {
    width: 1.25rem;
    height: 1.25rem;
    opacity: 0.65;
    flex-shrink: 0;
}

.ft-sidebar-nav .nav-link:hover {
    color: var(--ft-sidebar-text-hover) !important;
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.04);
}

.ft-sidebar-nav .nav-link:hover .ft-nav-icon {
    opacity: 1;
}

.ft-sidebar-nav .nav-link.active {
    color: #fff !important;
    background: linear-gradient(90deg, rgba(45, 212, 191, 0.2) 0%, rgba(99, 102, 241, 0.18) 100%);
    border-color: rgba(45, 212, 191, 0.45);
    font-weight: 600;
}

.ft-sidebar-nav .nav-link.active .ft-nav-icon {
    opacity: 1;
    color: #5eead4;
}

.ft-sidebar-nav .nav-link.notification-nav {
    justify-content: space-between;
}

.ft-sidebar-nav .notification-nav .badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.25em 0.5em;
    background: linear-gradient(135deg, #f43f5e, #e11d48) !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.ft-sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--ft-sidebar-muted);
    padding: 1rem 0.75rem 0.375rem;
    margin-top: 0.25rem;
}

.ft-sidebar-details {
    margin-bottom: 0.125rem;
}

.ft-sidebar-details > summary {
    list-style: none;
}

.ft-sidebar-details > summary::-webkit-details-marker {
    display: none;
}

.ft-sidebar-group-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.125rem;
    font-family: inherit;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ft-sidebar-muted);
    background: transparent;
    border: none;
    border-radius: var(--ft-radius-sm);
    text-align: left;
    cursor: pointer;
    transition:
        background 0.15s ease,
        color 0.15s ease;
}

.ft-sidebar-group-toggle:hover {
    color: var(--ft-sidebar-text-hover);
    background: rgba(255, 255, 255, 0.06);
}

.ft-sidebar-group-toggle:focus-visible {
    outline: 2px solid rgba(45, 212, 191, 0.55);
    outline-offset: 2px;
}

.ft-sidebar-group-toggle-label {
    flex: 1;
    min-width: 0;
}

.ft-sidebar-chevron {
    width: 0.875rem;
    height: 0.875rem;
    flex-shrink: 0;
    opacity: 0.55;
    transition: transform 0.2s ease, opacity 0.15s ease;
}

.ft-sidebar-group-toggle:hover .ft-sidebar-chevron {
    opacity: 0.9;
}

.ft-sidebar-details:not([open]) .ft-sidebar-chevron {
    transform: rotate(-90deg);
}

.ft-sidebar-group-items {
    padding: 0 0 0.25rem 0.5rem;
    margin: 0 0 0.25rem 0.5rem;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.ft-sidebar-group-items .nav-link {
    font-size: 0.8125rem;
}

.ft-sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--ft-sidebar-border);
    font-size: 0.8125rem;
    color: var(--ft-sidebar-muted);
}

.ft-sidebar-footer strong,
.ft-sidebar-footer .text-white {
    color: #f4f4f5 !important;
    font-weight: 600;
}

.ft-header {
    position: relative;
    height: var(--ft-header-h);
    min-height: var(--ft-header-h);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.78) 0%, rgba(248, 250, 252, 0.65) 100%);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.28);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.75) inset,
        0 8px 32px rgba(15, 23, 42, 0.06);
}

.ft-header::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 3px;
    pointer-events: none;
    background: linear-gradient(90deg, #14b8a6, #6366f1, #38bdf8, #2dd4bf);
    opacity: 0.85;
}

.ft-header-title {
    font-family: var(--ft-font-display);
    font-size: 1.125rem;
    font-weight: 700;
    background: linear-gradient(90deg, #0f172a 0%, #0f766e 55%, #3730a3 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.03em;
}

.ft-header .btn-outline-secondary {
    border-color: var(--ft-border-strong);
    color: var(--ft-ink-muted);
}

.ft-header .btn-outline-secondary:hover {
    background: var(--ft-surface-2);
    border-color: var(--ft-border-strong);
    color: var(--ft-ink);
}

.ft-main {
    position: relative;
    background: transparent;
    min-height: calc(100vh - var(--ft-header-h));
}

/* Subtle depth on main content column (shows over shell mesh) */
.ft-main::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse 70% 55% at 50% 0%, rgba(255, 255, 255, 0.35), transparent 65%);
    z-index: 0;
}

.ft-main > * {
    position: relative;
    z-index: 1;
}

/* ——— Guest / login ——— */
.ft-auth-body {
    min-height: 100vh;
    margin: 0;
    background: linear-gradient(155deg, var(--ft-sidebar-a) 0%, var(--ft-sidebar-b) 45%, var(--ft-sidebar-c) 100%);
    font-family: var(--ft-font-sans);
}

.ft-auth-layout {
    display: grid;
    min-height: 100vh;
}

@media (min-width: 992px) {
    .ft-auth-layout {
        grid-template-columns: 42% 58%;
    }
}

.ft-auth-hero {
    display: none;
    position: relative;
    padding: 3rem 3.5rem;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    background:
        radial-gradient(ellipse 100% 90% at 10% 10%, rgba(45, 212, 191, 0.28), transparent 52%),
        radial-gradient(ellipse 90% 70% at 95% 85%, rgba(99, 102, 241, 0.35), transparent 48%),
        linear-gradient(125deg, rgba(255, 255, 255, 0.08) 0%, transparent 45%),
        linear-gradient(165deg, var(--ft-sidebar-a) 0%, var(--ft-sidebar-b) 42%, var(--ft-sidebar-c) 100%);
    border-right: 1px solid var(--ft-sidebar-border);
}

@media (min-width: 992px) {
    .ft-auth-hero {
        display: flex;
    }
}

.ft-auth-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
    opacity: 0.9;
}

.ft-auth-hero-content {
    position: relative;
    z-index: 1;
}

.ft-auth-hero h1 {
    font-family: var(--ft-font-display);
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.04em;
    line-height: 1.15;
    max-width: 16ch;
}

.ft-auth-hero p {
    color: var(--ft-sidebar-text);
    font-size: 1rem;
    line-height: 1.6;
    max-width: 36ch;
    margin-top: 1rem;
}

.ft-auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem 3rem;
    background-color: #e0e7ef;
    background-image:
        radial-gradient(ellipse 100% 80% at 100% 0%, rgba(56, 189, 248, 0.18), transparent 50%),
        radial-gradient(ellipse 80% 70% at 0% 100%, rgba(129, 140, 248, 0.16), transparent 48%),
        linear-gradient(168deg, #f0f9ff 0%, #eef2ff 45%, #ecfeff 100%);
}

@media (min-width: 992px) {
    .ft-auth-panel {
        padding: 3rem;
    }
}

.ft-auth-card {
    width: 100%;
    max-width: 26rem;
    background: var(--ft-surface);
    border-radius: var(--ft-radius);
    border: 1px solid var(--ft-border);
    box-shadow: var(--ft-shadow-lg);
    padding: 2rem 2rem 2.25rem;
}

.ft-auth-card h1 {
    font-family: var(--ft-font-display);
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -0.03em;
    color: var(--ft-ink);
}

/* ——— Page chrome (main app content) ——— */
.ft-page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.ft-page-head h1,
.ft-page-head .h1,
.ft-page-head .h3 {
    font-family: var(--ft-font-display);
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--ft-ink);
    margin: 0;
}

.ft-card-elevated {
    border: 1px solid var(--ft-border) !important;
    border-radius: var(--ft-radius) !important;
    box-shadow: var(--ft-shadow) !important;
    overflow: hidden;
    background: var(--ft-surface) !important;
}

.ft-card-elevated .card-header {
    font-family: var(--ft-font-display);
    font-weight: 700;
    font-size: 0.875rem;
    letter-spacing: -0.02em;
    background: var(--ft-surface-2) !important;
    border-bottom: 1px solid var(--ft-border) !important;
    color: var(--ft-ink);
    padding: 0.875rem 1.125rem;
}

.ft-stat-card {
    border: 1px solid var(--ft-border) !important;
    border-radius: var(--ft-radius) !important;
    box-shadow: var(--ft-shadow) !important;
    background: var(--ft-surface) !important;
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.ft-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ft-shadow-lg) !important;
}

.ft-stat-card .card-body {
    padding: 1.125rem 1.25rem;
}

.ft-stat-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ft-ink-muted);
}

.ft-stat-value {
    font-family: var(--ft-font-display);
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.1;
    margin-top: 0.25rem;
}

/* Global Bootstrap polish */
.ft-portal .card {
    border-radius: var(--ft-radius);
    border: 1px solid var(--ft-border);
    box-shadow: var(--ft-shadow);
    overflow: hidden;
}

.ft-portal .card.shadow-sm {
    box-shadow: var(--ft-shadow) !important;
}

.ft-portal .table {
    --bs-table-bg: transparent;
}

.ft-portal .table thead th {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ft-ink-muted);
    border-bottom-width: 1px;
    background: var(--ft-surface-2);
}

.ft-portal .table > :not(caption) > * > * {
    padding: 0.65rem 1rem;
    vertical-align: middle;
}

.ft-portal .badge.text-bg-light {
    background: var(--ft-surface-2) !important;
    color: var(--ft-ink) !important;
    border: 1px solid var(--ft-border);
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
}

.ft-portal .btn {
    font-weight: 600;
    border-radius: var(--ft-radius-sm);
    padding: 0.5rem 1rem;
}

.ft-portal .btn-primary {
    background: linear-gradient(180deg, #14b8a6 0%, #0d9488 45%, #0f766e 100%);
    border: none;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.35);
}

.ft-portal .btn-primary:hover {
    background: linear-gradient(180deg, #2dd4bf 0%, #14b8a6 50%, #0d9488 100%);
    box-shadow: 0 6px 20px rgba(13, 148, 136, 0.4);
}

.ft-portal .btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8125rem;
}

.ft-portal .form-control,
.ft-portal .form-select {
    border-radius: var(--ft-radius-sm);
    border-color: var(--ft-border-strong);
}

.ft-portal .form-control:focus,
.ft-portal .form-select:focus {
    border-color: var(--ft-accent);
    box-shadow: 0 0 0 3px var(--ft-accent-soft);
}

.ft-portal .list-group-item {
    border-color: var(--ft-border);
}

.ft-portal .list-group-item-action:hover {
    background: var(--ft-surface-2);
}

.ft-portal .pagination .page-link {
    border-radius: var(--ft-radius-sm);
    margin: 0 0.125rem;
    font-weight: 600;
    color: var(--ft-ink-muted);
    border-color: var(--ft-border-strong);
}

.ft-portal .pagination .page-item.active .page-link {
    background: var(--bs-primary);
    border-color: var(--bs-primary);
}

.ft-alert {
    border-radius: var(--ft-radius-sm);
    border: 1px solid transparent;
    padding: 0.875rem 1rem;
    font-weight: 500;
}

.ft-alert-success {
    background: rgba(5, 150, 105, 0.1);
    border-color: rgba(5, 150, 105, 0.25);
    color: #047857;
}

.ft-alert-error {
    background: rgba(220, 38, 38, 0.08);
    border-color: rgba(220, 38, 38, 0.22);
    color: #b91c1c;
}

.ft-alert-error ul {
    margin: 0;
    padding-left: 1.1rem;
}

.ft-portal .alert {
    border-radius: var(--ft-radius-sm);
    border-width: 1px;
    font-weight: 500;
}

.ft-portal .alert-success {
    background: rgba(5, 150, 105, 0.1);
    border-color: rgba(5, 150, 105, 0.25);
    color: #047857;
}

.ft-portal .alert-danger {
    background: rgba(220, 38, 38, 0.08);
    border-color: rgba(220, 38, 38, 0.22);
    color: #b91c1c;
}

.ft-portal .alert-light {
    background: var(--ft-surface-2);
    border-color: var(--ft-border);
    color: var(--ft-ink);
    box-shadow: var(--ft-shadow);
}
