/* ========================================
   APP.CSS - Fichier CSS principal avec styles responsive
   ======================================== */

/* ========================================
   STYLES COMMUNS (Desktop et Mobile)
   ======================================== */

/* Base */
* {
    font-family: Verdana, sans-serif;
}

html {
    height: 100% !important;
}

body {
    text-align: center;
    cursor: auto;
}

body.wait {
    cursor: progress !important;
}

main {
    text-align: center;
}

/* Utility Classes */
.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-white {
    color: #fff;
}

/* Forms */
form {
    text-align: left;
}

label.required:after {
    content: " *";
    color: red;
}

.invalid-feedback ul {
    margin: 0;
    padding: 0;
}

.invalid-feedback li {
    list-style: none;
    font-size: 0.875em;
}

.filter {
    border-color: black;
}

/* Buttons */
.btn:hover,
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
    color: #fff !important;
}

/* Accordion */
.accordion-button::after,
.accordion-button:not(.collapsed)::after {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23FFFFFF'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

.accordion-body {
    text-align: left;
}

.accordion-item {
    border: 1px solid white !important;
}

/* Cards */
.card {
    margin-top: 10px;
}

.card-header h2 {
    margin-top: 0.5rem !important;
}

.card-body .input-group-text {
    height: 100%;
}

.card-body .input-group {
    margin-bottom: 10px;
}

.input-group-text i{
     font-size: inherit;
    line-height: 1.5em;
}
/* Auth layout (page login) */
.auth-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px;
}

/* Login card */
#container_login {
    width: 100%;
    max-width: 420px;
}

#container_login .card {
    border: none;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    margin-top: 0;
}

#container_login .card-header {
    padding: 24px 28px 20px;
    text-align: center;
}

#container_login .card-body {
    padding: 24px 28px 28px;
}

.language-selector {
    margin-top: 16px;
    text-align: center;
}

/* Table wrapper avec relief */
.access-table {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Status pills (badges ✔/✖) */
.status-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-yes { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.badge-no  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.badge-unk { background: #f3f4f6; color: #6b7280; border: 1px solid #d1d5db; }

/* Tables */
thead {
    border-bottom: 1px solid black;
}

th {
    text-align: center;
    position: relative;
}

.table td {
    vertical-align: middle;
    text-align: center;
}

/* Table Sorting Indicators */
.tri:before {
    bottom: 50%;
    content: "▲";
}

.tri:after {
    top: 50%;
    content: "▼";
}

.tri:after,
.tri:before {
    position: absolute;
    display: block;
    opacity: 0.125;
    line-height: 9px;
}

.asc:before,
.desc:after {
    opacity: 0.6;
}

/* ========================================
   STYLES DESKTOP (≥ 769px)
   ======================================== */

@media screen and (min-width: 769px) {
    * {
        font-size: 0.9rem;
    }

    body {
        padding: 10px;
        padding-top: 10px;
    }

    .py-4 {
        padding-top: 0.8rem !important;
        padding-bottom: 0.8rem !important;
    }

    /* Top Banner */
    #topBanner {
        width: calc(100% - 60px);
        margin-left: 60px;
    }

    #topBanner table {
        margin: 0 auto;
    }

    /* Footer */
    footer {
        text-align: center;
        width: 100%;
        padding: 8px 0;
        margin-top: 16px;
    }

    /* Content Wrapper */
    .content-wrapper {
        margin-left: 60px;
        min-height: 100vh;
    }

    /* Navbar */
    .navbar {
        padding: 0;
        margin-bottom: 10px;
        margin-top: 10px;
        border: 0;
    }

    .navbar .btn {
        border-radius: 0;
    }

    .navbar-nav {
        flex-direction: row;
    }

    .navbar-text {
        padding-top: 1rem;
    }

    .container-fluid {
        padding: 0;
        margin: 0;
        width: 100%;
        -webkit-transition: all 0.35s linear 0s;
        transition: all 0.35s linear 0s;
    }

    /* Sidebar Desktop */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 60px;
        background-color: #0d6efd;
        transition: width 0.3s ease;
        overflow: hidden;
        z-index: 1000;
    }

    .sidebar.collapsed {
        width: 60px;
    }

    .sidebar.expanded {
        width: 250px;
    }

    .sidebar .nav-link {
        color: white;
        padding: 15px 20px;
        white-space: nowrap;
        display: flex;
        align-items: center;
        text-decoration: none;
    }

    .sidebar .nav-link:hover {
        background-color: rgba(255, 255, 255, 0.3);
        color: #fff !important;
    }

    .sidebar .nav-link:hover span,
    .sidebar .nav-link:hover i {
        color: #fff !important;
    }

    .sidebar .nav-link i {
        min-width: 20px;
        margin-right: 15px;
        font-size: 1.2rem;
    }

    .sidebar .nav-link span {
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar.expanded .nav-link span {
        opacity: 1;
    }

    .sidebar .logout-section {

        width: 100%;
    }

    .sidebar .logout-link {
        border: none;
        background: none;
        width: 100%;
        text-align: left;
        cursor: pointer;
    }

    .sidebar .logout-link:hover {
        background-color: rgba(255, 255, 255, 0.3);
        color: #fff !important;
    }

    .sidebar .logout-link:hover span,
    .sidebar .logout-link:hover i {
        color: #fff !important;
    }

    .badge-sidebar {
        margin-left: auto;
        display: none;
    }

    .sidebar.expanded .badge-sidebar {
        display: inline;
    }

    /* Pas de menu burger sur desktop */
    .sidebar::before {
        display: none;
    }

    /* Pas de bouton burger externe sur desktop */
    body::before {
        display: none !important;
    }

    .accordion-button {
        padding: 8px !important;
    }

    table {
        border-spacing: 5px;
    }

    .table tbody td {
        padding: 2px;
    }

    .tri:after,
    .tri:before {
        right: 10px;
        font-size: 0.8em;
    }
}

/* ========================================
   STYLES MOBILE (≤ 768px)
   ======================================== */

@media screen and (max-width: 768px) {
    * {
        font-size: 0.85rem;
    }

    body {
        padding: 5px;
        padding-top: 5px;
        overflow-x: hidden;
    }

    main {
        padding: 0.5rem !important;
    }

    .py-4 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    /* Top Banner caché sur mobile */
    #topBanner {
        display: none !important;
    }

    /* Footer - Visible et adapté sur mobile */
    footer {
        text-align: center !important;
        position: relative;
        bottom: auto;
        width: 100% !important;
        margin-top: 20px;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 10px 5px;
        font-size: 0.75rem;
        display: flex !important; /* Force l'affichage sur mobile */
        justify-content: center !important;
        align-items: center !important;
    }

    footer * {
        font-size: 0.75rem;
        line-height: 1.4;
    }

    /* Correction du centrage du footer sur mobile */
    footer > div {
        margin-left: 0 !important; /* Annule le margin-left négatif */
        margin-right: 0 !important;
        text-align: center !important;
        width: 100% !important;
    }

    footer table {
        width: auto !important;
        max-width: 200px !important; /* Limite la largeur du tableau */
        margin: 10px auto !important;
        border: 0 !important;
        border-spacing: 5px !important;
        display: table !important;
    }

    footer tr {
        display: table-row !important;
    }

    footer td {
        text-align: center !important;
        padding: 5px !important;
        display: table-cell !important;
        vertical-align: middle !important;
    }

    footer img {
        max-width: 100px !important; /* Réduit la taille du logo sur mobile */
        width: 100px !important;
        height: auto !important;
        display: block !important;
        margin: 0 auto !important;
    }

    footer a {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }

    /* Content Wrapper */
    .content-wrapper {
        margin-left: 0;
        min-height: 100vh;
        width: 100%;
        padding-top: 10px;
    }

    /* Navbar */
    .navbar {
        padding: 0;
        margin-bottom: 5px;
        margin-top: 5px;
        border: 0;
    }

    .navbar .btn {
        border-radius: 0;
        font-size: 0.8rem;
        padding: 0.5rem;
    }

    .navbar-nav {
        flex-direction: column;
    }

    .navbar-text {
        padding-top: 0.5rem;
        font-size: 0.85rem;
    }

    .container-fluid {
        padding: 0;
        margin: 0;
        width: 100%;
        -webkit-transition: all 0.35s linear 0s;
        transition: all 0.35s linear 0s;
    }

    /* Sidebar Mobile - À gauche, masquée par défaut */
    .sidebar {
        position: fixed;
        top: 0;
        left: -250px; /* Masquée à gauche par défaut */
        height: 100vh;
        width: 250px;
        background-color: #0d6efd;
        transition: left 0.3s ease;
        overflow-y: auto;
        z-index: 1000;
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.3);
    }

    .sidebar.collapsed {
        left: -250px; /* Masquée */
    }

    .sidebar.expanded {
        left: 0; /* Visible */
    }

    .sidebar .nav {
        flex-direction: column;
        padding-top: 10px;
    }

    .sidebar .nav-link {
        color: white;
        padding: 12px 15px;
        white-space: nowrap;
        display: flex;
        align-items: center;
        text-decoration: none;
        font-size: 0.9rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .sidebar .nav-link:hover {
        background-color: rgba(255, 255, 255, 0.3);
        color: #fff !important;
    }

    .sidebar .nav-link:hover span,
    .sidebar .nav-link:hover i {
        color: #fff !important;
    }

    .sidebar .nav-link i {
        min-width: 25px;
        margin-right: 10px;
        font-size: 1.1rem;
    }

    .sidebar .nav-link span {
        opacity: 1;
        transition: opacity 0.3s ease;
    }

    /* Bouton Menu burger fixe en haut à gauche */
    .sidebar::before {
        content: none; /* Pas de burger dans la sidebar elle-même */
    }

    /* Créer un bouton burger externe */
    body::before {
        content: "☰";
        display: block;
        position: fixed;
        top: 10px;
        left: 10px;
        font-size: 2rem;
        color: #0d6efd;
        cursor: pointer;
        z-index: 999;
        background: white;
        width: 45px;
        height: 45px;
        line-height: 45px;
        text-align: center;
        border-radius: 5px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    }

    /* Overlay sombre quand le menu est ouvert */
    body::after {
        content: "";
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
    }

    /* Afficher l'overlay quand la sidebar est expanded */
    body:has(.sidebar.expanded)::after {
        display: block;
    }

    .sidebar .logout-section {
        position: relative;
        bottom: auto;
        width: 100%;
        margin-top: 10px;
    }

    .sidebar .logout-section form {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .sidebar .logout-link {
        border: none;
        background: none;
        width: 100%;
        text-align: left !important;
        cursor: pointer;
        display: flex !important;
        justify-content: flex-start !important;
        align-items: center !important;
        padding: 12px 15px !important;
    }

    .sidebar .logout-link:hover {
        background-color: rgba(255, 255, 255, 0.3);
        color: #fff !important;
    }

    .sidebar .logout-link:hover span,
    .sidebar .logout-link:hover i {
        color: #fff !important;
    }

    .badge-sidebar {
        margin-left: auto;
        display: inline;
    }

    /* Forms - Style form-control-sm pour mobile */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select,
    .form-control,
    .form-select {
        font-size: 14px !important;
        padding: 4px 8px !important;
        height: auto !important;
        min-height: 31px !important;
        line-height: 1.5 !important;
    }

    /* Tom Select sur mobile */
    .ts-wrapper .ts-control {
        font-size: 14px !important;
        padding: 4px 8px !important;
        min-height: 31px !important;
    }

    /* Labels plus petits */
    label {
        font-size: 0.85rem !important;
        margin-bottom: 3px !important;
    }

    /* Input groups */
    .input-group-text {
        font-size: 14px !important;
        padding: 4px 8px !important;
    }

    .invalid-feedback li {
        font-size: 0.75em;
    }

    .filter {
        width: 100%;
    }

    /* Buttons - Taille réduite pour mobile */
    .btn,
    button,
    input[type="submit"],
    input[type="button"],
    a.btn {
        padding: 6px 10px !important;
        font-size: 0.85rem !important;
        margin: 3px 2px !important;
        min-width: auto !important;
        min-height: auto !important;
        line-height: 1.5 !important;
        vertical-align: middle !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Correction pour les icônes dans les boutons */
    .btn i,
    a.btn i {
        vertical-align: middle;
        line-height: 1;
        margin-right: 4px;
    }

    /* Liens normaux (non boutons) */
    a:not(.btn) {
        display: inline-flex;
        align-items: center;
        vertical-align: middle;
    }

    a:not(.btn) i {
        margin-right: 4px;
        vertical-align: middle;
    }

    /* Accordion */
    .accordion-button {
        padding: 10px !important;
        font-size: 0.9rem;
    }

    .accordion-body {
        padding: 10px;
    }

    /* Cards */
    .card {
        margin-bottom: 10px;
    }

    .card-header {
        padding: 8px 12px !important;
    }

    .card-header h2 {
        font-size: 1.1rem !important;
        margin: 0 !important;
    }

    .card-body {
        padding: 10px !important;
    }

    .card-body .input-group {
        flex-wrap: wrap;
        margin-bottom: 8px !important;
    }

    /* Réduire les marges des formulaires */
    .mb-3 {
        margin-bottom: 8px !important;
    }

    .mt-3 {
        margin-top: 8px !important;
    }

    /* Tables responsive */
    table {
        border-spacing: 3px;
        font-size: 0.75rem;
        width: 100%;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    th {
        padding: 8px 4px;
        font-size: 0.75rem;
    }

    .table td {
        padding: 8px 4px;
        font-size: 0.75rem;
    }

    .table tbody td {
        padding: 4px 2px;
    }

    .tri:after,
    .tri:before {
        right: 5px;
        line-height: 8px;
        font-size: 0.7em;
    }

    /* Images responsive */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Alertes */
    .alert {
        font-size: 0.85rem;
        padding: 10px;
        margin: 5px 0;
    }

    /* Touch improvements */
    a, button, .btn {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }

    * {
        -webkit-overflow-scrolling: touch;
    }
}
