/* ===== Fonts (self-hosted, variable weight 100-900) ===== */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/inter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308,
        U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/inter-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
        U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ===== Palette ===== */
:root {
    --navy-950: #061426;
    --navy-900: #0a1f38;
    --navy-800: #0f2c4c;
    --navy-700: #163b63;
    --navy-600: #1e4d7f;
    --navy-500: #2c649c;
    --navy-100: #e8eef5;
    --navy-50: #f4f7fb;

    --ink: #16212e;
    --ink-muted: #5b6b7d;
    --border: #dfe6ee;

    --white: #ffffff;
    --success: #1b8a5a;
    --success-bg: #e6f6ee;
    --danger: #c62b3d;
    --danger-bg: #fbe9eb;
    --warning: #a9640c;
    --warning-bg: #fdf1e0;
    --info: #205c8f;
    --info-bg: #e7f0f9;

    --shadow-sm: 0 1px 2px rgba(10, 31, 56, 0.06), 0 1px 1px rgba(10, 31, 56, 0.04);
    --shadow-md: 0 4px 16px rgba(10, 31, 56, 0.08), 0 2px 6px rgba(10, 31, 56, 0.05);
    --radius: 10px;
}

/* ===== Base ===== */
html {
    /* Bumps every rem-based size (Bootstrap's included) up proportionally
       from the 16px default, rather than resizing body text alone. */
    font-size: 13px;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--navy-50);
    color: var(--ink);
    font-size: 1rem;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--navy-900);
    letter-spacing: -0.01em;
}

a {
    color: var(--navy-600);
    text-decoration: none;
}

a:hover {
    color: var(--navy-800);
}

code {
    color: var(--navy-700);
    background: var(--navy-100);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
}

/* ===== App shell (left sidebar + main column) ===== */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    flex: 0 0 240px;
    background: linear-gradient(180deg, var(--navy-900), var(--navy-950));
    color: rgba(255, 255, 255, 0.85);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 1.25rem 0.9rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.5rem 1.5rem;
    color: var(--white);
    text-decoration: none;
}

.sidebar-brand .mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.sidebar-brand span {
    font-weight: 700;
    font-size: 1.02rem;
    letter-spacing: -0.01em;
}

.sidebar-brand:hover {
    color: var(--white);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sidebar-nav .nav-link {
    color: rgba(255, 255, 255, 0.68);
    font-weight: 500;
    font-size: 0.92rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.sidebar-nav .nav-link:hover {
    color: var(--white);
    background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-nav .nav-link.active {
    color: var(--white);
    background-color: rgba(255, 255, 255, 0.14);
}

.sidebar-nav .nav-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.55;
    flex-shrink: 0;
}

.sidebar-section {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
    padding: 1rem 0.75rem 0.35rem;
}

.main-column {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ===== Topbar ===== */
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0.7rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-toggle {
    margin-right: auto;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.user-chip .avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--navy-100);
    color: var(--navy-800);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-chip .name {
    font-weight: 600;
    color: var(--ink);
    font-size: 0.88rem;
    line-height: 1.15;
}

.user-chip .role {
    font-size: 0.72rem;
    color: var(--ink-muted);
    font-weight: 500;
}

.user-chip.is-superadmin .role {
    color: var(--danger);
    font-weight: 700;
}

.logout-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-muted);
    transition: all 0.15s ease;
}

.logout-btn:hover {
    color: var(--danger);
    border-color: #f0c3c9;
    background-color: var(--danger-bg);
}

/* Offcanvas sidebar reuses the same navy styling on small screens */
.offcanvas.sidebar-offcanvas {
    background: linear-gradient(180deg, var(--navy-900), var(--navy-950));
    color: rgba(255, 255, 255, 0.85);
    width: 260px;
}

.offcanvas.sidebar-offcanvas .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.content {
    padding: 1.75rem;
    flex: 1;
}

/* ===== Footer ===== */
.app-footer {
    padding: 0.85rem 1.75rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--ink-muted);
    font-size: 0.8rem;
}

.version-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--ink-muted);
    font-size: 0.8rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    transition: color 0.15s ease;
}

.version-link:hover {
    color: var(--navy-700);
    text-decoration: underline;
}

.changelog-entry {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.changelog-entry:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.changelog-entry h6 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.changelog-entry ul {
    padding-left: 1.15rem;
    color: var(--ink);
}

/* ===== Buttons ===== */
.btn {
    font-weight: 600;
    border-radius: 8px;
    padding: 0.45rem 1rem;
    transition: all 0.15s ease;
}

.btn-primary {
    background-color: var(--navy-700);
    border-color: var(--navy-700);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--navy-800);
    border-color: var(--navy-800);
}

.btn-outline-secondary {
    color: var(--navy-700);
    border-color: var(--border);
}

.btn-outline-secondary:hover {
    background-color: var(--navy-700);
    border-color: var(--navy-700);
    color: var(--white);
}

.btn-outline-danger {
    color: var(--danger);
    border-color: #f0c3c9;
}

.btn-outline-danger:hover {
    background-color: var(--danger);
    border-color: var(--danger);
}

.btn-outline-light {
    border-color: rgba(255, 255, 255, 0.35);
    font-weight: 500;
}

.btn-outline-light:hover {
    background-color: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.5);
}

.btn-link {
    color: var(--ink-muted);
    font-weight: 500;
}

.btn-link:hover {
    color: var(--navy-800);
}

/* ===== Cards ===== */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* ===== Tables ===== */
/* A "table card": bordered panel with an optional search toolbar above the
   table and a pagination footer below, all sharing one visual container
   instead of a bare table floating on the page. */
.table-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-toolbar {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.table-toolbar .search-field {
    position: relative;
    flex: 0 1 280px;
}

.table-toolbar .search-field svg {
    position: absolute;
    left: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-muted);
    pointer-events: none;
}

.table-toolbar .search-field input {
    padding-left: 2rem;
}

.table-footer {
    padding: 0.65rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.table-card > .table-responsive > .table,
.table-card > .table {
    margin-bottom: 0;
    background-color: var(--white);
    --bs-table-bg: var(--white);
}

.table thead th {
    background-color: var(--navy-50);
    color: var(--navy-800);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 1.1rem;
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
    border-color: var(--border);
    color: var(--ink);
    padding: 0.7rem 1.1rem;
}

.table-card tbody tr:last-child td {
    border-bottom: none;
}

.table-hover tbody tr:hover {
    background-color: var(--navy-50);
}

.table-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--ink-muted);
    font-size: 0.9rem;
}

/* ===== Forms ===== */
.form-control,
.form-select {
    border-radius: 8px;
    border-color: var(--border);
    padding: 0.5rem 0.8rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--navy-500);
    box-shadow: 0 0 0 0.2rem rgba(44, 100, 156, 0.18);
}

.form-label {
    font-weight: 600;
    color: var(--navy-900);
    font-size: 0.88rem;
}

.form-check-input:checked {
    background-color: var(--navy-700);
    border-color: var(--navy-700);
}

/* ===== TomSelect (searchable dropdowns) — match the rest of the form theme ===== */
.ts-wrapper.form-select .ts-control,
.ts-wrapper.form-control .ts-control {
    border-radius: 8px;
    border-color: var(--border);
    padding: 0.4rem 0.7rem;
    font-family: inherit;
}

/* Tom Select auto-detects text direction per-select via getComputedStyle and
   right-aligns the label when it reads "rtl" — nothing in this app is RTL
   content, so pin every instance to left-aligned regardless of that check. */
.ts-control {
    text-align: left !important;
    direction: ltr !important;
}

.ts-wrapper.form-select.form-select-sm .ts-control {
    padding: 0.2rem 0.6rem;
    font-size: 0.85rem;
    min-height: calc(1.5em + 0.5rem + 2px);
}

.ts-wrapper.single.focus > .ts-control,
.ts-wrapper.multi.focus > .ts-control {
    border-color: var(--navy-500);
    box-shadow: 0 0 0 0.2rem rgba(44, 100, 156, 0.18);
}

/* Tom Select builds its own wrapper <div> and only copies the original
   <select>'s classes onto it, not its inline style — so width has to be set
   via a class like this one, not a `style="max-width:...` on the <select>. */
.field-search-select,
.ts-wrapper.field-search-select {
    max-width: 280px;
}

.ts-dropdown {
    border-color: var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    font-family: inherit;
}

.ts-dropdown .option.active,
.ts-dropdown .option:hover {
    background-color: var(--navy-50);
    color: var(--navy-900);
}

.ts-dropdown .option.selected {
    background-color: var(--navy-100);
    color: var(--navy-900);
    font-weight: 600;
}

.form-check-input:focus {
    border-color: var(--navy-500);
    box-shadow: 0 0 0 0.2rem rgba(44, 100, 156, 0.18);
}

/* ===== Badges ===== */
.badge {
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 0.4em 0.7em;
    border-radius: 6px;
}

.badge.text-bg-secondary {
    background-color: var(--navy-100) !important;
    color: var(--navy-800) !important;
}

.badge.text-bg-success {
    background-color: var(--success-bg) !important;
    color: var(--success) !important;
}

.badge.text-bg-danger {
    background-color: var(--danger-bg) !important;
    color: var(--danger) !important;
}

.badge.text-bg-warning {
    background-color: var(--warning-bg) !important;
    color: var(--warning) !important;
}

.badge.text-bg-info {
    background-color: var(--info-bg) !important;
    color: var(--info) !important;
}

/* ===== Alerts ===== */
.alert {
    border: none;
    border-radius: var(--radius);
    border-left: 4px solid transparent;
    font-weight: 500;
}

.alert-success {
    background-color: var(--success-bg);
    color: var(--success);
    border-left-color: var(--success);
}

.alert-danger {
    background-color: var(--danger-bg);
    color: var(--danger);
    border-left-color: var(--danger);
}

.alert-info {
    background-color: var(--info-bg);
    color: var(--info);
    border-left-color: var(--info);
}

/* ===== Login page ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.05), transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(44, 100, 156, 0.25), transparent 45%),
        linear-gradient(155deg, var(--navy-950), var(--navy-800) 65%, var(--navy-600));
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--white);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(6, 20, 38, 0.35);
    border: none;
    overflow: hidden;
}

.login-card .card-body {
    padding: 2.5rem 2.25rem;
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1.75rem;
}

.login-brand .mark {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(155deg, var(--navy-700), var(--navy-900));
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.2rem;
    margin-bottom: 0.85rem;
    box-shadow: var(--shadow-md);
}

.login-brand h1 {
    font-size: 1.15rem;
    margin: 0;
    color: var(--navy-900);
}

.login-brand p {
    margin: 0.15rem 0 0;
    color: var(--ink-muted);
    font-size: 0.82rem;
}
