/* Styles de base */
body {
    font-family: "Poppins", sans-serif;
    background-color: #f8f9fa;
}

/* Styles de la sidebar */
.sidebar {
    height: 100vh;
    background: linear-gradient(180deg, #2c3e50 0%, #1a252f 100%);
    padding-top: 20px;
    position: fixed;
    left: 0;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    z-index: 1000;
    width: 250px;
    display: flex;
    flex-direction: column;
}

.sidebar h3 {
    font-weight: 600;
    letter-spacing: 1px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin: 0 15px 20px;
    color: #fff;
}

/* Conteneur de liens de navigation avec défilement */
.nav-links-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 15px;
    /* Stylisation de la barre de défilement */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.nav-links-container::-webkit-scrollbar {
    width: 5px;
}

.nav-links-container::-webkit-scrollbar-track {
    background: transparent;
}

.nav-links-container::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.nav-links-container::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.4);
}

/* Styles pour les liens de navigation */
.sidebar a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    margin: 4px 8px;
    border-radius: 8px;
    font-weight: 500;
}

.sidebar a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(5px);
}

.sidebar a.active {
    background: linear-gradient(45deg, #0d6efd, #0dcaf0);
    color: white;
    box-shadow: 0 4px 15px rgba(13, 110, 253, 0.2);
}

.sidebar a i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

/* Zone d'authentification utilisateur */
.user-auth-container {
    padding: 10px 0;
    margin-top: auto;
}

.sidebar-divider {
    border-color: rgba(255, 255, 255, 0.1);
    margin: 0 15px 15px;
}

.auth-link {
    margin: 5px 8px !important;
}

.login-link {
    color: #2ecc71 !important;
}

.logout-link {
    color: #ff6b6b !important;
}

/* Styles du contenu principal */
.main-content {
    margin-left: 250px;
    min-height: 100vh;
    background-color: #f8f9fa;
    transition: all 0.3s ease;
    padding: 15px;
}

/* Styles de la navbar */
.navbar {
    background: white !important;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
    padding: 15px 0;
}

.navbar-brand {
    color: #2c3e50 !important;
    font-weight: 600;
    font-size: 1.4rem;
}

/* Styles des conteneurs */
.container {
    padding: 20px;
}

/* Styles des cartes */
.card {
    border: none;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* Styles des alertes */
.alert {
    border: none;
    border-radius: 10px;
    padding: 15px 20px;
    margin-bottom: 20px;
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Styles des boutons */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* Styles des tableaux */
.table {
    font-size: 0.85rem;
}

.table th {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: normal;
    vertical-align: top;
}

.table td {
    text-align: left !important;
    padding: 0.5rem 0.75rem !important;
}

/* Styles des titres */
.card-title {
    font-size: 1.5rem;
}

h4 {
    font-size: 1.1rem;
}

/* Styles des totaux */
.status-totals {
    width: auto !important;
    max-width: 400px;
}

.status-totals td,
.status-totals th {
    padding: 0.5rem 1rem;
    text-align: left;
}

.status-totals td:last-child,
.status-totals th:last-child {
    text-align: right;
}

/* Styles du conteneur de statistiques */
.stats-container {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
}

.stats-left,
.stats-right {
    flex: 1;
}

/* Styles des filtres */
.filter-container {
    margin-bottom: 1.5rem;
    padding: 0.9rem;
    background-color: #f8f9fa;
    border-radius: 0.5rem;
    font-size: 0.9rem;
}

.filter-container .form-check {
    display: inline-block;
    margin-right: 1.5rem;
}

.filter-badge {
    font-size: 0.8rem;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Styles des lignes prioritaires */
.priority-row {
    background-color: rgba(255, 193, 7, 0.15) !important;
    font-weight: 600;
}

/* Styles des liens personnalisés */
.custom-link {
    color: #846605;
    text-decoration: underline;
}

.custom-link:hover {
    text-decoration: underline;
}

/* Styles du bouton toggle */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1001;
    background: #2c3e50;
    border: none;
    color: white;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    background: #1a252f;
    transform: scale(1.05);
}

.sidebar-toggle i {
    font-size: 1.2rem;
}

/* Media Queries */
@media (max-width: 1300px) {
    .sidebar {
        transform: translateX(-250px);
        transition: transform 0.3s ease;
    }

    .sidebar.show {
        transform: translateX(0);
        width: 250px;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 15px;
    }

    .container {
        padding: 10px;
    }

    .navbar {
        padding: 10px;
    }

    .navbar .container {
        display: flex;
        justify-content: center;
        text-align: center;
    }

    .navbar-brand {
        font-size: 1.2rem;
        margin: 0 auto;
    }

    .card {
        margin-bottom: 15px;
    }

    .sidebar-toggle {
        display: block;
    }

    /* Ajustements pour la navbar responsive */
    .nav-links-container {
        max-height: calc(100vh - 220px);
    }

    .user-auth-container {
        background: rgba(0, 0, 0, 0.25);
    }
}

@media (max-height: 600px) {
    .nav-links-container {
        max-height: calc(100vh - 180px);
    }

    .sidebar h3 {
        margin-bottom: 10px;
        padding-bottom: 10px;
    }

    .sidebar a {
        padding: 8px 20px;
        margin: 2px 8px;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 5px;
    }

    .card {
        border-radius: 10px;
    }

    .btn {
        padding: 8px 15px;
        font-size: 0.9rem;
    }

    .alert {
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    /* Ajustements pour petits écrans */
    .sidebar-toggle {
        padding: 8px;
    }

    .sidebar-toggle i {
        font-size: 1rem;
    }
}

/* Styles pour la page des commandes bloquées */
.table {
    font-size: 0.85rem;
}

.table th {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: normal;
    vertical-align: top;
}

.card-title {
    font-size: 1.5rem;
}

h4 {
    font-size: 1.1rem;
}

/* Style pour le tableau des totaux */
.status-totals {
    width: auto !important;
    max-width: 400px;
}

.status-totals td,
.status-totals th {
    padding: 0.5rem 1rem;
    text-align: left;
}

.status-totals td:last-child,
.status-totals th:last-child {
    text-align: right;
}

/* Alignement et padding des tableaux */
.table td,
.table th {
    text-align: left !important;
    padding: 0.5rem 0.75rem !important;
}

/* Styles pour la page de performance des centres d'usinage */
.chart-container {
    min-height: 300px;
    margin-bottom: 20px;
    width: 100%;
}

.info-box {
    padding: 0.75rem;
    border-radius: 0.5rem;
    background-color: #f8f9fa;
    margin-bottom: 1rem;
}

.info-box h6 {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
}

.info-box p.lead {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0;
}

.date-picker-container {
    position: relative;
}

.date-picker-container .form-control {
    background-color: #fff;
    cursor: pointer;
}

.date-picker-container .form-control:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.date-picker-container .calendar-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #6c757d;
}

.date-has-data {
    background-color: #e3f2fd !important;
    font-weight: bold;
}

.date-selected {
    background-color: #007bff !important;
    color: white !important;
}

/* Styles pour le calendrier */
input[type="date"]::-webkit-calendar-picker-indicator {
    background-color: #e3f2fd;
    padding: 5px;
    cursor: pointer;
    border-radius: 3px;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    background-color: #bbdefb;
}

.date-picker-container::after {
    content: "Utilisez les flèches pour naviguer entre les jours";
    position: absolute;
    bottom: -20px;
    left: 0;
    font-size: 0.8em;
    color: #666;
}

.date-suggestion {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    border-radius: 0.25rem;
    font-size: 0.9rem;
}

#prevDayBtn,
#nextDayBtn {
    padding: 0.375rem 0.75rem;
}

#loading-container {
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.spinner-border {
    animation: spinner-border 1s linear infinite;
}

@keyframes spinner-border {
    to {
        transform: rotate(360deg);
    }
}

/* Styles pour le chat OpenAI */
.chat-container {
    max-width: 900px;
    margin: 0 auto;
    height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 15px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 2rem;
    scroll-behavior: smooth;
}

.welcome-message {
    text-align: center;
    margin: 2rem 0;
    color: #2c3e50;
}

.welcome-message h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.welcome-message p {
    color: #666;
}

.message {
    max-width: 85%;
    margin: 1.5rem 0;
    padding: 1rem;
    border-radius: 10px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.message.user {
    margin-left: auto;
    background: #0d6efd;
    color: white;
}

.message.assistant {
    margin-right: auto;
    background: #f8f9fa;
    color: #2c3e50;
}

.chat-input-container {
    padding: 2rem;
    background: white;
    border-top: 1px solid #eee;
}

.chat-form {
    max-width: 800px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 10px;
}

.chat-input {
    flex-grow: 1;
    border: none;
    outline: none;
    padding: 8px;
    resize: none;
    max-height: 200px;
    font-family: inherit;
}

.send-button {
    position: relative;
    background: #0d6efd;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 40px;
}

.send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.send-button i {
    transition: opacity 0.3s ease;
}

.send-button.loading i {
    opacity: 0;
}

.loading-spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

.send-button.loading .loading-spinner {
    display: block;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

.disclaimer {
    text-align: center;
    margin: 1rem auto;
    max-width: 90%;
    padding: 0.8rem 1.2rem;
    background-color: #cce5ff;
    color: #004085;
    border: 1px solid #b8daff;
    border-radius: 10px;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    animation: slideIn 0.3s ease;
}

/* Style pour le défilement */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.error-message {
    background: #fee;
    color: #c00;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid #eee;
}

.reset-button {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.reset-button:hover {
    background: #c82333;
    transform: translateY(-2px);
}

/* Animation des points sautillants */
.typing-indicator {
    display: none;
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 10px;
    margin: 1rem 0;
    width: fit-content;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #2c3e50;
    border-radius: 50%;
    margin: 0 2px;
    opacity: 0.4;
}

.typing-indicator span:nth-child(1) {
    animation: bounce 1s infinite;
}
.typing-indicator span:nth-child(2) {
    animation: bounce 1s infinite 0.2s;
}
.typing-indicator span:nth-child(3) {
    animation: bounce 1s infinite 0.4s;
}

@keyframes bounce {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Styles pour la page des contacts */
.scrollable-table {
    max-height: 600px; /* Hauteur maximale */
    overflow-y: auto; /* Barre de défilement verticale */
    margin-top: 1rem;
}

/* Fixer l'en-tête du tableau pendant le défilement */
.table-fixed-header {
    position: relative;
}
.table-fixed-header thead th {
    position: sticky;
    top: 0;
    background-color: white;
    z-index: 1;
    border-bottom: 2px solid #dee2e6;
}

/* Styles pour la page des préplanifications */
.stats-dashboard {
    background-color: #fff;
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.section-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #f1f1f1;
}

.stats-card {
    display: flex;
    align-items: center;
    background-color: #fff;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%;
}

.stats-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.stats-card:hover .stats-value {
    color: #0d6efd;
}

.stats-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: linear-gradient(45deg, #0d6efd, #0dcaf0);
    color: white;
    border-radius: 12px;
    font-size: 1.5rem;
    margin-right: 1rem;
}

.stats-icon.warning {
    background: linear-gradient(45deg, #ffc107, #ff9800);
}

.stats-icon.info {
    background: linear-gradient(45deg, #3498db, #2980b9);
}

.stats-icon.pvc {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
}

.stats-icon.alu {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
}

.stats-content {
    flex: 1;
}

.stats-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    color: #2c3e50;
}

.stats-label {
    color: #6c757d;
    margin: 0;
    font-size: 0.9rem;
    font-weight: 500;
}

.floating-panel {
    background-color: #fff;
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
}

/* Style pour les graphiques */
.chart-container {
    min-height: 300px;
    width: 100%;
}

/* Styles pour les tableaux triables (DataTables) */
.dataTables_wrapper {
    padding: 0;
    margin-top: 1rem;
}

.dataTables_filter,
.dataTables_length {
    margin-bottom: 1rem;
}

.dataTables_filter input {
    border-radius: 6px;
    border: 1px solid #dee2e6;
    padding: 5px 10px;
    margin-left: 8px;
}

.dataTables_length select {
    border-radius: 6px;
    border: 1px solid #dee2e6;
    padding: 5px 10px;
    margin: 0 5px;
}

.table thead th {
    position: relative;
    cursor: pointer;
    padding-right: 20px !important;
    background-color: #f8f9fa;
}

.table thead th.sorting:after,
.table thead th.sorting_asc:after,
.table thead th.sorting_desc:after {
    position: absolute;
    right: 8px;
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 0.8rem;
}

.table thead th.sorting:after {
    content: "\f0dc";
    color: #bbbbbb;
}

.table thead th.sorting_asc:after {
    content: "\f0de";
    color: #0d6efd;
}

.table thead th.sorting_desc:after {
    content: "\f0dd";
    color: #0d6efd;
}

.table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

.dataTables_info,
.dataTables_paginate {
    margin-top: 1rem;
    font-size: 0.9rem;
}

.dataTables_paginate .paginate_button {
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    margin: 0 3px;
    border: 1px solid #dee2e6;
    cursor: pointer;
}

.dataTables_paginate .paginate_button.current {
    background: #0d6efd;
    color: white !important;
    border-color: #0d6efd;
}

.dataTables_paginate .paginate_button:hover:not(.current) {
    background: #f8f9fa;
    color: #0d6efd !important;
}

.dataTables_empty {
    padding: 2rem !important;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* Styles personnalisés pour DataTables avec recherche uniquement */
.dataTables_wrapper .dataTables_filter {
    width: 100%;
    margin-bottom: 1.5rem;
    text-align: right;
}

.dataTables_wrapper .dataTables_filter input {
    width: 300px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    padding: 8px 12px;
    margin-left: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.2);
}

/* Masquer les éléments de pagination non souhaités */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    display: none !important;
}

/* Style pour les lignes alternées dans le tableau */
.table tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}

.table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

/* Styles pour l'interface Expédition */
.expedition-only-notice {
    margin-bottom: 15px;
}

.expedition-only-notice .alert {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    border: none;
    color: white;
    font-size: 0.85rem;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(23, 162, 184, 0.3);
}

.expedition-only-notice .alert i {
    margin-right: 8px;
    font-size: 1rem;
}

.expedition-only-notice .alert strong {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.expedition-only-notice .alert small {
    opacity: 0.9;
    font-size: 0.75rem;
}

/* Mise en évidence du lien Expédition pour les utilisateurs expédition */
.sidebar a[href*="expedition"] {
    background: linear-gradient(45deg, #28a745, #20c997) !important;
    color: white !important;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3) !important;
    font-weight: 600;
}

.sidebar a[href*="expedition"]:hover {
    background: linear-gradient(45deg, #218838, #1e7e34) !important;
    transform: translateX(8px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4) !important;
}
