:root {
    --app-primary: #2563eb;
    --app-primary-dark: #1d4ed8;
    --app-sidebar-bg: #111827;
    --app-sidebar-text: #d1d5db;
    --app-sidebar-muted: #9ca3af;
    --app-background: #f3f4f6;
    --app-border: #e5e7eb;
    --app-text: #1f2937;
    --app-text-muted: #6b7280;
    --app-white: #ffffff;
    --app-sidebar-width: 270px;
    --app-topbar-height: 72px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--app-background);
    color: var(--app-text);
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

/* ---------------------------------------------------------------
   Structure générale
---------------------------------------------------------------- */

.app-layout {
    min-height: 100vh;
}

.app-sidebar {
    width: var(--app-sidebar-width);
    background: var(--app-sidebar-bg);
    color: var(--app-sidebar-text);
    border: 0;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 1.25rem;
}

.sidebar-brand {
    margin-bottom: 2rem;
}

.sidebar-brand a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--app-white);
    text-decoration: none;
}

.sidebar-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--app-primary);
    font-size: 1.25rem;
}

.sidebar-brand-text {
    font-size: 1.05rem;
    font-weight: 700;
}

.sidebar-navigation {
    flex: 1;
}

.sidebar-heading {
    margin: 0 0 0.75rem;
    color: var(--app-sidebar-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-height: 46px;
    margin-bottom: 0.35rem;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    color: var(--app-sidebar-text);
    text-decoration: none;
    transition:
        background-color 0.2s ease,
        color 0.2s ease;
}

.sidebar-link i {
    width: 22px;
    font-size: 1.05rem;
    text-align: center;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--app-white);
}

.sidebar-link.disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.sidebar-footer {
    padding-top: 1rem;
    color: var(--app-sidebar-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.app-main {
    min-width: 0;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1010;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--app-topbar-height);
    padding: 0.75rem 1.5rem;
    background: var(--app-white);
    border-bottom: 1px solid var(--app-border);
}

.topbar-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}

.user-menu-button {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    border: 0;
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--app-primary);
    color: var(--app-white);
    font-weight: 700;
}

.app-content {
    padding: 1.5rem;
}

/* ---------------------------------------------------------------
   En-tête des pages
---------------------------------------------------------------- */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header h2 {
    margin: 0 0 0.35rem;
    font-size: 1.6rem;
    font-weight: 700;
}

.page-header p {
    margin: 0;
    color: var(--app-text-muted);
}

/* ---------------------------------------------------------------
   Tableau de bord
---------------------------------------------------------------- */

.dashboard-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100%;
    min-height: 120px;
    padding: 1.25rem;
    background: var(--app-white);
    border: 1px solid var(--app-border);
    border-radius: 16px;
    box-shadow: 0 5px 20px rgba(17, 24, 39, 0.04);
}

.dashboard-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--app-primary);
    font-size: 1.35rem;
}

.dashboard-card-label {
    margin: 0 0 0.25rem;
    color: var(--app-text-muted);
    font-size: 0.9rem;
}

.dashboard-card-value {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 700;
}

.content-card {
    overflow: hidden;
    background: var(--app-white);
    border: 1px solid var(--app-border);
    border-radius: 16px;
    box-shadow: 0 5px 20px rgba(17, 24, 39, 0.04);
}

.content-card-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--app-border);
}

.content-card-header h3 {
    margin: 0 0 0.25rem;
    font-size: 1.05rem;
    font-weight: 700;
}

.content-card-header p {
    margin: 0;
    color: var(--app-text-muted);
    font-size: 0.9rem;
}

.content-card-body {
    padding: 1.25rem;
}

.empty-state {
    padding: 2rem 1rem;
    text-align: center;
}

.empty-state > i {
    display: inline-block;
    margin-bottom: 1rem;
    color: var(--app-primary);
    font-size: 2.5rem;
}

.empty-state h4 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.empty-state p {
    max-width: 520px;
    margin: 0 auto;
    color: var(--app-text-muted);
}

.user-information {
    margin: 0;
}

.user-information > div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--app-border);
}

.user-information > div:first-child {
    padding-top: 0;
}

.user-information > div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.user-information dt {
    color: var(--app-text-muted);
    font-weight: 500;
}

.user-information dd {
    margin: 0;
    font-weight: 600;
    text-align: right;
}

/* ---------------------------------------------------------------
   Connexion
---------------------------------------------------------------- */

.login-page {
    min-height: 100vh;
    background:
        radial-gradient(
            circle at top left,
            rgba(37, 99, 235, 0.18),
            transparent 35%
        ),
        linear-gradient(145deg, #eff6ff 0%, #f8fafc 55%, #e5e7eb 100%);
}

.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 460px;
    padding: 2rem;
    background: var(--app-white);
    border: 1px solid rgba(229, 231, 235, 0.9);
    border-radius: 22px;
    box-shadow: 0 25px 60px rgba(17, 24, 39, 0.12);
}

.login-brand {
    margin-bottom: 1.75rem;
    text-align: center;
}

.login-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 62px;
    height: 62px;
    margin-bottom: 1rem;
    border-radius: 18px;
    background: var(--app-primary);
    color: var(--app-white);
    font-size: 1.6rem;
}

.login-brand h1 {
    margin: 0 0 0.5rem;
    font-size: 1.65rem;
    font-weight: 750;
}

.login-brand p {
    margin: 0;
    color: var(--app-text-muted);
}

.login-footer {
    margin-top: 1.5rem;
    color: var(--app-text-muted);
    text-align: center;
}

.form-control:focus {
    border-color: rgba(37, 99, 235, 0.6);
    box-shadow: 0 0 0 0.25rem rgba(37, 99, 235, 0.12);
}

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

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

/* ---------------------------------------------------------------
   Responsive
---------------------------------------------------------------- */

@media (min-width: 992px) {
    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        visibility: visible !important;
        transform: none !important;
    }

    .app-main {
        margin-left: var(--app-sidebar-width);
    }
}

@media (max-width: 991.98px) {
    .app-sidebar {
        max-width: 290px;
    }

    .sidebar-content {
        min-height: calc(100vh - 65px);
    }

    .app-content {
        padding: 1rem;
    }

    .app-topbar {
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 575.98px) {
    .page-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .login-card {
        padding: 1.4rem;
        border-radius: 18px;
    }

    .user-information > div {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.25rem;
    }

    .user-information dd {
        text-align: left;
    }
}

/* ---------------------------------------------------------------
   Paramètres de l'entreprise
---------------------------------------------------------------- */

.sidebar-brand-logo {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    padding: 4px;
    background: #ffffff;
    border-radius: 12px;
    object-fit: contain;
}

.company-logo-preview {
    display: inline-block;
    padding: 1rem;
    background: #f9fafb;
    border: 1px solid var(--app-border);
    border-radius: 12px;
}

.company-logo-preview img {
    display: block;
    max-width: 220px;
    max-height: 120px;
    object-fit: contain;
}

.form-control-color {
    width: 64px;
    height: 44px;
    padding: 0.3rem;
}

/* ---------------------------------------------------------------
   Tableaux
---------------------------------------------------------------- */

.app-table thead th {
    padding: 1rem;
    background: #f9fafb;
    color: var(--app-text-muted);
    border-bottom-width: 1px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.app-table tbody td {
    padding: 1rem;
    border-color: var(--app-border);
}

.app-table tbody tr:last-child td {
    border-bottom: 0;
}

.app-table tbody tr:hover {
    background: rgba(37, 99, 235, 0.025);
}

/* ---------------------------------------------------------------
   Ouvriers
---------------------------------------------------------------- */

.worker-identity {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-width: 210px;
}

.worker-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--app-primary);
    font-size: 0.85rem;
    font-weight: 750;
}

@media (max-width: 575.98px) {
    .page-header > .btn {
        width: 100%;
    }
}

/* ---------------------------------------------------------------
   Chantiers
---------------------------------------------------------------- */

.project-identity {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 220px;
}

.project-color {
    display: inline-block;
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(17, 24, 39, 0.12);
    border-radius: 50%;
    vertical-align: middle;
}

.project-color-lg {
    width: 28px;
    height: 28px;
}

.project-information {
    margin: 0;
}

.project-information > div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--app-border);
}

.project-information > div:first-child {
    padding-top: 0;
}

.project-information > div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.project-information dt {
    color: var(--app-text-muted);
    font-weight: 500;
}

.project-information dd {
    margin: 0;
    font-weight: 600;
    text-align: right;
}

@media (max-width: 575.98px) {
    .project-information > div {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.3rem;
    }

    .project-information dd {
        text-align: left;
    }
}

/* ---------------------------------------------------------------
   Affectations
---------------------------------------------------------------- */

.assignment-list-summary {
    padding: 0.8rem 1rem;
    background: #f9fafb;
    color: var(--app-text-muted);
    border-bottom: 1px solid var(--app-border);
    font-size: 0.88rem;
    font-weight: 600;
}

select[multiple].form-select {
    min-height: 240px;
    padding: 0.5rem;
}

select[multiple].form-select option {
    padding: 0.55rem 0.65rem;
    border-radius: 6px;
}

select[multiple].form-select option:checked {
    background: var(--app-primary);
    color: #ffffff;
}

/* ---------------------------------------------------------------
   Sidebar claire et lisible
---------------------------------------------------------------- */

:root {
    --app-sidebar-bg: #ffffff;
    --app-sidebar-text: #334155;
    --app-sidebar-muted: #64748b;
    --app-sidebar-border: #e2e8f0;
    --app-sidebar-hover: #f1f5f9;
    --app-sidebar-accent: #e2e8f0;
}

.app-sidebar {
    background: var(--app-sidebar-bg);
    color: var(--app-sidebar-text);
    border-right: 1px solid var(--app-sidebar-border);
    box-shadow: 8px 0 28px rgba(15, 23, 42, 0.04);
}

.sidebar-content {
    padding: 1.25rem 1rem;
}


/* ---------------------------------------------------------------
   En-tête et identité de l'entreprise
---------------------------------------------------------------- */

.sidebar-brand {
    position: relative;
    margin-bottom: 2rem;
    padding: 0 0.35rem 1.35rem;
}

.sidebar-brand::after {
    position: absolute;
    right: 0.35rem;
    bottom: 0;
    left: 0.35rem;
    height: 3px;
    background: linear-gradient(
        90deg,
        var(--app-primary),
        var(--app-sidebar-accent)
    );
    border-radius: 999px;
    content: "";
}

.sidebar-brand a {
    gap: 0.85rem;
    color: #0f172a;
}

.sidebar-brand a:hover {
    color: #0f172a;
}

.sidebar-brand-logo {
    width: 48px;
    height: 48px;
    padding: 4px;
    background: #ffffff;
    border: 1px solid var(--app-sidebar-border);
    border-radius: 13px;
    box-shadow: 0 5px 14px rgba(15, 23, 42, 0.08);
}

.sidebar-brand-icon {
    width: 48px;
    height: 48px;
    background: var(--app-primary);
    color: #ffffff;
    border-radius: 13px;
    box-shadow: 0 5px 14px rgba(15, 23, 42, 0.1);
}

.sidebar-brand-text {
    overflow: hidden;
    color: #0f172a;
    font-size: 1.02rem;
    font-weight: 750;
    line-height: 1.25;
    text-overflow: ellipsis;
}


/* ---------------------------------------------------------------
   Titres des rubriques
---------------------------------------------------------------- */

.sidebar-heading {
    position: relative;
    margin: 0 0.4rem 0.85rem;
    padding-left: 0.7rem;
    color: var(--app-sidebar-muted);
    font-size: 0.73rem;
    font-weight: 800;
    letter-spacing: 0.09em;
}

.sidebar-heading::before {
    position: absolute;
    top: 50%;
    left: 0;
    width: 3px;
    height: 14px;
    background: var(--app-sidebar-accent);
    border-radius: 999px;
    content: "";
    transform: translateY(-50%);
}


/* ---------------------------------------------------------------
   Liens de navigation
---------------------------------------------------------------- */

.sidebar-link {
    position: relative;
    gap: 0.85rem;
    min-height: 48px;
    margin-bottom: 0.35rem;
    padding: 0.75rem 0.9rem;
    color: var(--app-sidebar-text);
    border: 1px solid transparent;
    border-radius: 11px;
    font-size: 0.94rem;
    font-weight: 600;
    line-height: 1.25;
    transition:
        background-color 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease,
        box-shadow 0.18s ease;
}

.sidebar-link i {
    width: 23px;
    color: #64748b;
    font-size: 1.15rem;
    transition:
        color 0.18s ease,
        transform 0.18s ease;
}

.sidebar-link span {
    color: inherit;
}

.sidebar-link:hover {
    background: var(--app-sidebar-hover);
    color: #0f172a;
    border-color: var(--app-sidebar-border);
    transform: translateX(2px);
}

.sidebar-link:hover i {
    color: var(--app-primary);
    transform: scale(1.04);
}

.sidebar-link.active {
    background: var(--app-primary);
    color: #ffffff;
    border-color: var(--app-primary);
    box-shadow: 0 7px 18px rgba(15, 23, 42, 0.14);
}

.sidebar-link.active::before {
    position: absolute;
    top: 50%;
    left: -0.48rem;
    width: 4px;
    height: 24px;
    background: var(--app-sidebar-accent);
    border-radius: 0 999px 999px 0;
    content: "";
    transform: translateY(-50%);
}

.sidebar-link.active i {
    color: #ffffff;
}

.sidebar-link.active:hover {
    background: var(--app-primary);
    color: #ffffff;
    border-color: var(--app-primary);
    transform: none;
}

.sidebar-link.active:hover i {
    color: #ffffff;
}

.sidebar-link.disabled {
    color: #94a3b8;
    opacity: 0.65;
}


/* ---------------------------------------------------------------
   Pied de la sidebar
---------------------------------------------------------------- */

.sidebar-footer {
    margin-top: 1rem;
    padding: 1rem 0.4rem 0;
    color: var(--app-sidebar-muted);
    border-top: 1px solid var(--app-sidebar-border);
    font-size: 0.78rem;
    font-weight: 600;
}


/* ---------------------------------------------------------------
   En-tête mobile de la sidebar
---------------------------------------------------------------- */

.app-sidebar .offcanvas-header {
    min-height: 65px;
    background: #ffffff;
    color: #0f172a;
    border-bottom: 1px solid var(--app-sidebar-border);
}

.app-sidebar .offcanvas-title {
    color: #0f172a;
    font-weight: 700;
}

.app-sidebar .btn-close {
    opacity: 0.7;
}

.app-sidebar .btn-close:hover {
    opacity: 1;
}


/* ---------------------------------------------------------------
   Responsive
---------------------------------------------------------------- */

@media (max-width: 991.98px) {
    .app-sidebar {
        box-shadow: 18px 0 42px rgba(15, 23, 42, 0.14);
    }

    .sidebar-content {
        min-height: calc(100vh - 65px);
        padding: 1.1rem 0.9rem;
    }

    .sidebar-brand {
        margin-bottom: 1.5rem;
    }
}

/* ---------------------------------------------------------------
   Sidebar adaptative avec défilement vertical
---------------------------------------------------------------- */

.app-sidebar {
    height: 100vh;
    overflow: hidden;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    padding-bottom: 0;
}

.sidebar-brand {
    flex: 0 0 auto;
}

.sidebar-navigation {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding-right: 0.35rem;
    padding-bottom: 1rem;
    scrollbar-gutter: stable;
}

.sidebar-footer {
    flex: 0 0 auto;
    margin-top: 0;
    padding: 1rem 0.4rem;
    background: var(--app-sidebar-bg);
    border-top: 1px solid var(--app-sidebar-border);
}


/* ---------------------------------------------------------------
   Barre de défilement discrète
---------------------------------------------------------------- */

.sidebar-navigation {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.sidebar-navigation::-webkit-scrollbar {
    width: 7px;
}

.sidebar-navigation::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-navigation::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}

.sidebar-navigation::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
    border: 2px solid transparent;
    background-clip: padding-box;
}


/* ---------------------------------------------------------------
   Mobile
---------------------------------------------------------------- */

@media (max-width: 991.98px) {
    .app-sidebar {
        height: 100vh;
    }

    .sidebar-content {
        height: calc(100vh - 65px);
        min-height: 0;
    }

    .sidebar-navigation {
        padding-bottom: 1.25rem;
    }
}