/* ===== Variables CSS ===== */
:root {
    --bg-color: #f5f5f5;          /* Fond gris clair */
    --nav-color: #2c3e50;         /* Couleur de la barre de navigation */
    --primary-color: #3498db;     /* Bleu primaire */
    --secondary-color: #2980b9;  /* Bleu secondaire (survol) */
    --text-color: #333;          /* Couleur du texte */
    --light-gray: #ecf0f1;       /* Gris clair pour les cartes */
    --highlight-color: #fff2a8;  /* Jaune clair pour la surbrillance */
    --border-radius: 8px;        /* Bordures arrondies */
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);  /* Ombre légère */
    --card-shadow: 0 6px 12px rgba(0, 0, 0, 0.15); /* Ombre pour les cartes au survol */
    --success-color: #28a745;     /* Vert pour les succès */
    --danger-color: #dc3545;     /* Rouge pour les erreurs */
    --warning-color: #ffc107;    /* Jaune pour les avertissements */
    --info-color: #17a2b8;       /* Bleu pour les infos */
}

/* ===== Réinitialisation et style de base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== Barre de navigation ===== */
nav.navbar {
    background-color: var(--nav-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--box-shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-brand {
    color: white !important;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
}

.navbar-brand img {
    height: 40px;
    margin-right: 10px;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    color: white;
    font-size: 0.9rem;
}

.user-nav {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.user-nav .nav-link {
    color: white !important;
    padding: 0.3rem 0.6rem;
    border-radius: var(--border-radius);
    transition: background-color 0.3s;
}

.user-nav .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* ===== Conteneur principal ===== */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* ===== Zone de recherche ===== */
.search-container {
    background-color: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 2rem;
}

.search-form {
    display: flex;
    gap: 1rem;
    max-width: 800px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.search-form input[type="text"],
.search-form select {
    flex: 1;
    min-width: 200px;
    padding: 0.8rem 1rem;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: border 0.3s;
}

.search-form input[type="text"]:focus,
.search-form select:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.search-form button {
    padding: 0.8rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

.search-form button:hover {
    background-color: var(--secondary-color);
}

/* ===== Filtres de types de fichiers ===== */
.filters-sidebar {
    position: sticky;
    top: 20px;
    height: fit-content;
    padding-right: 15px;
}

.filter-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.filter-list li {
    margin-bottom: 0.5rem;
}

.filter-list a {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.2s;
    background-color: white;
    box-shadow: var(--box-shadow);
}

.filter-list a:hover,
.filter-list a.active {
    background-color: var(--light-gray);
}

.filter-list img {
    width: 24px;
    height: 24px;
    margin-right: 0.75rem;
}

/* ===== Résultats de recherche (grille responsive) ===== */
.results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.document-card {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--box-shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.document-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--card-shadow);
}

.document-title-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.file-icon {
    width: 32px;
    height: 32px;
    margin-right: 1rem;
}

.document-title {
    flex-grow: 1;
    margin: 0 1rem;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
}

.document-title a {
    text-decoration: none;
    color: inherit;
    transition: color 0.3s;
}

.document-title a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

.document-content {
    margin: 1rem 0;
    line-height: 1.6;
    color: #555;
    flex-grow: 1;
}

.document-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #777;
    margin-top: auto;
}

/* ===== Surbrillance des mots-clés ===== */
.highlight {
    background-color: var(--highlight-color);
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
    font-weight: bold;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 2rem 0;
}

.pagination .page-item .page-link {
    padding: 0.5rem 1rem;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.3s;
}

.pagination .page-item .page-link:hover:not(.active) {
    background-color: var(--light-gray);
    border-color: var(--primary-color);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Supprimer les points dans la pagination */
.pagination .page-link::before {
    display: none !important;
}

/* ===== Alertes (messages flash) ===== */
.alert {
    padding: 1rem;
    margin: 1rem 0;
    border-radius: var(--border-radius);
    border-left: 4px solid;
}

.alert-success {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--success-color);
    border-left-color: var(--success-color);
}

.alert-error {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--danger-color);
    border-left-color: var(--danger-color);
}

.alert-warning {
    background-color: rgba(255, 193, 7, 0.1);
    color: var(--warning-color);
    border-left-color: var(--warning-color);
}

.alert-info {
    background-color: rgba(23, 162, 184, 0.1);
    color: var(--info-color);
    border-left-color: var(--info-color);
}

/* ===== Boutons et liens ===== */
.btn {
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-weight: 500;
    display: inline-block;
}

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

.btn-primary:hover {
    background-color: var(--secondary-color);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-outline-primary {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: white;
}

/* ===== Style du curseur dans l'éditeur ===== */
.EasyMDEContainer .CodeMirror {
    height: auto !important;
    min-height: 300px !important;
}

.EasyMDEContainer .CodeMirror-scroll {
    min-height: 300px !important;
}

.CodeMirror {
    border: 1px solid #ddd !important;
    border-radius: var(--border-radius) !important;
}

.CodeMirror-focused .CodeMirror-cursor {
    border-left: 2px solid black !important;
    border-left-color: black !important;
}

/* ===== Style pour les fichiers PowerPoint ===== */
.pptx-icon {
    filter: drop-shadow(0 0 2px rgba(255, 0, 0, 0.3));
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .search-form {
        flex-direction: column;
    }

    .results {
        grid-template-columns: 1fr;
    }

    .nav-links {
        flex-direction: column;
        gap: 0.5rem;
    }

    .filters-sidebar {
        position: static;
        margin-bottom: 1.5rem;
    }
}

/* ===== Admin et rôles ===== */
.admin-link {
    color: #dc3545;
    font-weight: bold;
}

.role-cards {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.role-card {
    display: block;
    width: 200px;
    padding: 20px;
    border: 1px solid #ccc;
    border-radius: var(--border-radius);
    text-align: center;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.3s;
}

.role-card:hover {
    background-color: #f0f0f0;
    box-shadow: var(--box-shadow);
}

.role-card h2 {
    margin-top: 0;
    color: var(--primary-color);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

/* ===== Style pour les fichiers téléchargés ===== */
.file-upload-area {
    border: 2px dashed #ced4da;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
    margin-bottom: 1rem;
    transition: all 0.2s;
}

.file-upload-area:hover {
    border-color: var(--primary-color);
    background-color: rgba(52, 152, 219, 0.05);
}

/* ===== Style pour les fichiers DOCX/PPTX ===== */
.document-card[data-type="docx"],
.document-card[data-type="pptx"] {
    border-left: 4px solid var(--primary-color);
}

/* ===== Style pour les boutons d'action ===== */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.action-buttons .btn {
    white-space: nowrap;
}

/* ===== Style pour l'éditeur Markdown ===== */
#editor {
    min-height: 400px;
    border: 1px solid #ced4da;
    border-radius: var(--border-radius);
    font-family: monospace;
    font-size: 14px;
    line-height: 1.5;
}

/* ===== Style pour les fichiers téléchargés ===== */
@media print {
    body {
        background-color: white;
    }

    .document-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Entrée Tailwind v4 */
@import "tailwindcss";

/* Base — typo système, confort visuel */
@layer base {
  :root {
    /* Palette de marque (ex. "brand") */
    --brand-50:  #eff6ff;
    --brand-100: #dbeafe;
    --brand-200: #bfdbfe;
    --brand-300: #93c5fd;
    --brand-400: #60a5fa;
    --brand-500: #3b82f6; /* primaire */
    --brand-600: #2563eb;
    --brand-700: #1d4ed8;
    --brand-800: #1e40af;
    --brand-900: #1e3a8a;
  }
  html {
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
    scroll-behavior: smooth;
  }
}

/* Composants — classes utilitaires composées */
@layer components {
  /* Boutons */
  .btn { @apply inline-flex items-center gap-2 rounded-md transition focus:outline-none focus:ring-2 focus:ring-blue-500; }
  .btn-primary { @apply bg-blue-600 text-white hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 px-3 py-2; }
  .btn-outline-primary { @apply border border-blue-600 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/20 px-3 py-2; }
  .btn-muted { @apply border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800 px-2 py-1; }

  /* Inputs / textarea */
  .input { @apply block w-full rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-900 px-3 py-2 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500; }

  /* Badges */
  .badge { @apply inline-flex items-center px-2 py-0.5 text-xs font-medium rounded-full; }
  .badge-primary { @apply bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200; }
  .badge-success { @apply bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200; }
  .badge-warning { @apply bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200; }
  .badge-danger  { @apply bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200; }

  /* Navbar links */
  .nav-link { @apply inline-flex items-center text-sm text-gray-700 dark:text-gray-200 hover:text-blue-600 dark:hover:text-blue-400; }

  /* Card */
  .card { @apply rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm; }

  /* Pagination (container + items) */
  .pagination { @apply flex items-center justify-center gap-2 mt-6; }
  .page-link { @apply inline-flex items-center justify-center px-3 py-1.5 border rounded-md text-sm; }
  .page-link-default { @apply border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800; }
  .page-link-active { @apply border-blue-600 bg-blue-600 text-white; }
  .page-link-disabled { @apply border-gray-200 text-gray-400 dark:border-gray-700 dark:text-gray-500 cursor-not-allowed; }

  /* Alert (flash messages) - structure déjà générée via base.html) */
}

/* Couleurs par type de fichier */
.badge-type-txt { background-color: #6c757d; color: white; }
.badge-type-md { background-color: #6f42c1; color: white; }
.badge-type-docx { background-color: #0d6efd; color: white; }
.badge-type-pptx { background-color: #d63384; color: white; }
.badge-type-pdf { background-color: #dc3545; color: white; }
.badge-type-xlsx { background-color: #198754; color: white; }

/* Boutons */
.btn-view { background-color: #0dcaf0; color: white; border-color: #0dcaf0; }
.btn-open { background-color: #198754; color: white; border-color: #198754; }
.btn-edit { background-color: #ffc107; color: black; border-color: #ffc107; }
.btn-delete { background-color: #dc3545; color: white; border-color: #dc3545; }

.btn-view:hover, .btn-open:hover, .btn-edit:hover {
    opacity: 0.9;
}
