/*
 * AuditFlow - custom styles on top of Bootstrap 5.3.8
 * Colours and spacing are kept in CSS variables so the look can be
 * changed in one place.
 */

:root {
    --af-primary: #2563eb;
    --af-primary-soft: #eaf1ff;
    --af-bg: #f3f4f6;
    --af-surface: #ffffff;
    --af-border: #e5e7eb;
    --af-text: #111827;
    --af-muted: #6b7280;
    --af-sidebar-width: 272px;
    --af-topbar-height: 72px;

    /* Tell Bootstrap to use our colours + font */
    --bs-primary: var(--af-primary);
    --bs-primary-rgb: 37, 99, 235;
    --bs-body-font-family: "Inter Variable", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-color: var(--af-text);
    --bs-body-bg: #ffffff; /* inputs, tables, dropdowns stay white */
    --bs-border-color: var(--af-border);
    --bs-border-radius: .375rem;
    --bs-link-color: var(--af-primary);
    --bs-link-color-rgb: 37, 99, 235;
}

body {
    background: var(--af-bg);
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
}

.btn-primary {
    --bs-btn-bg: var(--af-primary);
    --bs-btn-border-color: var(--af-primary);
    --bs-btn-hover-bg: #1d4ed8;
    --bs-btn-hover-border-color: #1d4ed8;
    --bs-btn-active-bg: #1e40af;
    --bs-btn-active-border-color: #1e40af;
    --bs-btn-disabled-bg: var(--af-primary);
    --bs-btn-disabled-border-color: var(--af-primary);
}

.btn-outline-secondary {
    --bs-btn-color: var(--af-text);
    --bs-btn-border-color: #d1d5db;
    --bs-btn-hover-bg: #f9fafb;
    --bs-btn-hover-color: var(--af-text);
    --bs-btn-hover-border-color: #d1d5db;
    --bs-btn-active-bg: #f3f4f6;
    --bs-btn-active-color: var(--af-text);
    --bs-btn-active-border-color: #d1d5db;
    background: #fff;
}

.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: #93b4f5;
    box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .15);
}
.form-check-input:checked { background-color: var(--af-primary); border-color: var(--af-primary); }
.form-label { font-weight: 500; font-size: .9rem; }

/* ------------------------------------------------------------------
 | Layout: sidebar + top bar + content
 * ------------------------------------------------------------------ */

.af-sidebar {
    width: var(--af-sidebar-width);
    /* !important: Bootstrap's .offcanvas-lg makes the background transparent on large screens */
    background: var(--af-surface) !important;
    border-right: 1px solid var(--af-border);
}

@media (min-width: 992px) {
    .af-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 1030;
    }
    .af-main { margin-left: var(--af-sidebar-width); }
}

.af-brand {
    height: var(--af-topbar-height);
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--af-border);
    color: var(--af-primary);
    font-weight: 700;
    font-size: 1.35rem;
    text-decoration: none;
    flex-shrink: 0;
}
.af-brand-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .6rem; }
.af-brand-link:hover { color: var(--af-primary); }
.af-brand .bi { font-size: 1.5rem; }

.af-nav { overflow-y: auto; flex-grow: 1; padding-bottom: 1rem; }

.af-nav-group { padding: .85rem 0 .4rem; border-bottom: 1px solid var(--af-border); }
.af-nav-group:last-child { border-bottom: 0; }

.af-nav-heading {
    padding: 0 1.5rem .5rem;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--af-muted);
}

.af-nav-link {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .5rem 1.25rem .5rem 1.5rem;
    color: #374151;
    text-decoration: none;
    font-size: .94rem;
    white-space: nowrap;
    border-right: 3px solid transparent;
}
.af-nav-link .bi { font-size: 1.1rem; color: #4b5563; }
.af-nav-link:hover { background: #f9fafb; color: var(--af-text); }

.af-nav-link.active {
    background: var(--af-primary-soft);
    color: var(--af-primary);
    border-right-color: var(--af-primary);
    font-weight: 500;
}
.af-nav-link.active .bi { color: var(--af-primary); }

/* Modules that are not built yet */
.af-nav-link.disabled { color: #9ca3af; cursor: default; pointer-events: none; }
.af-nav-link.disabled .bi { color: #c4c8cf; }
.af-soon {
    margin-left: auto;
    font-size: .6rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #9ca3af;
    background: #f3f4f6;
    border-radius: 999px;
    padding: .1rem .4rem;
}

.af-sidebar-footer {
    border-top: 1px solid var(--af-border);
    padding: 1rem 1.5rem 1.25rem;
    flex-shrink: 0;
}
.af-signout {
    background: none;
    border: 0;
    padding: 0;
    color: #dc2626;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-weight: 500;
}
.af-signout:hover { color: #b91c1c; }

.af-topbar {
    height: var(--af-topbar-height);
    background: var(--af-surface);
    border-bottom: 1px solid var(--af-border);
    position: sticky;
    top: 0;
    z-index: 1020;
}
.af-page-title { font-size: 1.2rem; font-weight: 600; margin: 0; }

.af-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--af-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}
.af-avatar-sm { width: 32px; height: 32px; font-size: .85rem; }

.af-content { padding: 2rem 1rem; }
@media (min-width: 768px) { .af-content { padding: 2.5rem 2rem; } }
.af-container { max-width: 1320px; margin: 0 auto; }

/* ------------------------------------------------------------------
 | Cards, stat tiles, tables, badges
 * ------------------------------------------------------------------ */

.af-card {
    background: var(--af-surface);
    border: 1px solid var(--af-border);
    border-radius: .375rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.af-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--af-border);
}
.af-card-title { font-size: 1.15rem; font-weight: 600; margin: 0; }
.af-card-subtitle { color: var(--af-muted); font-size: .9rem; margin: .25rem 0 0; }
.af-card-body { padding: 1.5rem; }

.af-stat { padding: 1.5rem 1.75rem; height: 100%; }
.af-stat-label {
    font-size: .8rem;
    font-weight: 500;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #4b5563;
}
.af-stat-value { font-size: 2.25rem; font-weight: 700; line-height: 1.2; margin: .6rem 0 .25rem; }
.af-stat-note { font-size: .85rem; color: var(--af-muted); }

/* Compact tables: more rows fit on a normal laptop screen, text stays readable.
   Used by every table in the dashboard (Team, Departments, Projects, ...). */
.af-table { margin: 0; font-size: .875rem; }
.af-table > :not(caption) > * > * { padding: .55rem .75rem; border-color: var(--af-border); vertical-align: middle; }
.af-table > :not(caption) > * > *:first-child { padding-left: 1.25rem; }
.af-table > :not(caption) > * > *:last-child { padding-right: 1.25rem; }
.af-table thead th {
    background: #fafafa;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #4b5563;
    white-space: nowrap;
    padding-top: .6rem;
    padding-bottom: .6rem;
}
.af-table tbody tr:last-child td { border-bottom: 0; }
.af-table tbody tr:hover > * { background: #fafbfc; }
.af-table .small, .af-table small { font-size: .8rem; }
.af-table .btn-sm { --bs-btn-padding-y: .15rem; --bs-btn-padding-x: .5rem; --bs-btn-font-size: .8rem; }
.af-table .af-badge { font-size: .72rem; padding: .15rem .5rem; }
.af-table .af-avatar-sm { width: 28px; height: 28px; font-size: .78rem; }

/* Column widths for long text, so rows do not grow 5-6 lines tall */
.af-col-md { min-width: 170px; max-width: 230px; }
.af-col-lg { min-width: 220px; max-width: 340px; }

/* Progress bar with the % written on it (visits done / total visits) */
.af-col-progress { min-width: 96px; }
.af-progress {
    position: relative;
    height: 16px;
    min-width: 80px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}
.af-progress-bar { height: 100%; background: var(--af-primary); border-radius: 999px; }
.af-progress-label {
    position: absolute;
    inset: 0;
    text-align: center;
    font-size: .68rem;
    font-weight: 600;
    line-height: 16px;
    color: var(--af-text);
    text-shadow: 0 0 2px #fff, 0 0 2px #fff; /* readable on both the blue and the grey part */
}

/* Show at most 2 lines; the full text appears on mouse hover (title attribute) */
.af-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Label / value list on detail pages (e.g. a project) */
.af-details { display: grid; grid-template-columns: 160px 1fr; gap: .6rem 1rem; margin: 0; }
.af-details dt { font-weight: 500; color: var(--af-muted); font-size: .9rem; }
.af-details dd { margin: 0; }
@media (max-width: 575px) {
    .af-details { grid-template-columns: 1fr; gap: .15rem; }
    .af-details dd { margin-bottom: .6rem; }
}

.af-badge {
    display: inline-block;
    font-size: .78rem;
    font-weight: 500;
    padding: .2rem .6rem;
    border-radius: 999px;
    white-space: nowrap;
}
.af-badge-success { background: #e8f6ec; color: #1e7b3a; }
.af-badge-danger  { background: #fdecec; color: #c62828; }
.af-badge-warning { background: #fdf6dd; color: #a16207; }
.af-badge-info    { background: #e8f0fe; color: #1d4ed8; }
.af-badge-muted   { background: #f3f4f6; color: #4b5563; }

.af-empty { padding: 3rem 1rem; text-align: center; color: var(--af-muted); }
.af-empty .bi { font-size: 2rem; display: block; margin-bottom: .5rem; color: #c4c8cf; }

/* ------------------------------------------------------------------
 | Login page
 * ------------------------------------------------------------------ */

.af-auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
}
.af-auth-card {
    width: 100%;
    max-width: 460px;
    padding: 2.75rem 2.5rem 2.5rem;
}
@media (max-width: 480px) { .af-auth-card { padding: 2rem 1.25rem; } }
.af-auth-logo { font-size: 2.75rem; color: var(--af-primary); line-height: 1; }
.af-auth-title { font-size: 1.6rem; font-weight: 700; margin: 1rem 0 .35rem; }
.af-auth-company { color: #4b5563; font-size: .92rem; }
.af-auth-card .form-control { padding: .7rem .9rem; }
.af-auth-card .btn-primary { padding: .7rem; font-weight: 600; }
