/* 
 * Feuille de style - Design Apple Laboratoire (Classique)
 * Minimaliste, élégant et professionnel
 */

/* Variables CSS - Palette Apple */
:root {
    --primary: #0071e3;
    --secondary: #666;
    --tertiary: #f5f5f7;
    --background: #ffffff;
    --border: #d2d2d7;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --success: #34c759;
    --danger: #ff3b30;
    --warning: #ff9500;
    --info: #0071e3;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
    color: var(--text-primary);
    background-color: var(--background);
    line-height: 1.6;
}

/* Conteneur principal */
.container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* En-tête */
.header {
    background-color: var(--background);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.username {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.username strong {
    color: var(--text-primary);
}

/* Contenu principal */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    width: 100%;
}

/* Pied de page */
.footer {
    background-color: var(--tertiary);
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    text-align: center;
    padding: 24px;
    margin-top: 40px;
    font-size: 13px;
}

/* Alertes */
.alert {
    padding: 16px;
    margin-bottom: 20px;
    border-radius: var(--radius-sm);
    border-left: 4px solid;
    background-color: var(--tertiary);
}

.alert-error {
    border-color: var(--danger);
    color: #d70015;
}

.alert-success {
    border-color: var(--success);
    color: #00a854;
}

.alert-warning {
    border-color: var(--warning);
    color: #ff6b00;
}

.alert-info {
    border-color: var(--info);
    color: var(--primary);
}

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

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

.btn-primary:hover {
    background-color: #0055cc;
}

.btn-secondary {
    background-color: var(--tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

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

.btn-success:hover {
    background-color: #30b84f;
}

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

.btn-danger:hover {
    background-color: #ff1f1f;
}

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

.btn-info:hover {
    background-color: #0055cc;
}

.btn-small {
    padding: 8px 12px;
    font-size: 13px;
}

.btn-block {
    display: block;
    width: 100%;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background-color: var(--background);
    color: var(--text-primary);
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

/* Page de connexion */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f5f5f7 0%, #ffffff 100%);
}

.login-container {
    width: 100%;
    max-width: 360px;
    padding: 20px;
}

.login-box {
    background-color: var(--background);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 28px;
    font-weight: 600;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 14px;
}

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

/* Statistiques */
.stats-section {
    margin-bottom: 40px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.stat-card {
    background-color: var(--tertiary);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-align: center;
    transition: all 0.2s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-card h3 {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 32px;
    font-weight: 600;
    color: var(--primary);
}

/* Section d'upload */
.upload-section {
    margin-bottom: 40px;
}

.upload-section h2 {
    margin-bottom: 20px;
    font-size: 20px;
    font-weight: 600;
}

.upload-box {
    background-color: var(--tertiary);
    padding: 32px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.file-input-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.file-input-wrapper input[type="file"] {
    display: none;
}

.file-input-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: var(--background);
}

.file-input-label:hover {
    border-color: var(--primary);
    background-color: rgba(0, 113, 227, 0.05);
}

.file-input-label .icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.file-input-label .text {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.file-input-label .subtext {
    font-size: 13px;
    color: var(--text-secondary);
}

.file-list {
    margin-bottom: 20px;
}

.file-item {
    background-color: var(--background);
    padding: 12px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
}

.file-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.file-item-size {
    color: var(--text-secondary);
    font-size: 12px;
    margin-left: 10px;
}

.file-item-remove {
    background-color: var(--danger);
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 10px;
    transition: all 0.2s ease;
}

.file-item-remove:hover {
    background-color: #ff1f1f;
}

/* Section de recherche */
.search-section {
    margin-bottom: 30px;
}

.search-section h2 {
    margin-bottom: 20px;
    font-size: 20px;
    font-weight: 600;
}

.search-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.search-form input,
.search-form select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.search-form input {
    flex: 1;
    min-width: 200px;
}

.search-form select {
    min-width: 150px;
}

.search-form button {
    padding: 10px 16px;
}

/* ===== TABLES CORRIGÉES ===== */

/* Container pour tables avec défilement horizontal */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background-color: var(--background);
    margin-bottom: 20px;
}

/* Style de base pour TOUS les tableaux */
.files-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed; /* IMPORTANT : fixe les largeurs */
    font-size: 14px;
}

/* En-têtes */
.files-table thead {
    background-color: var(--tertiary);
    border-bottom: 2px solid var(--border);
}

.files-table th {
    padding: 16px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* Cellules */
.files-table td {
    padding: 16px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
}

/* Hover effect */
.files-table tbody tr:hover {
    background-color: rgba(0, 113, 227, 0.03);
}

/* Éléments spécifiques */
.filename {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    word-break: break-word;
    white-space: normal; /* Permet le retour à la ligne */
}

.file-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    white-space: nowrap; /* Garde les boutons sur une ligne */
}

.no-files {
    padding: 48px 20px;
    text-align: center;
    color: var(--text-secondary);
}

/* ===== LARGEURS SPÉCIFIQUES PAR PAGE ===== */

/* Dashboard - Admin (7 colonnes) */
.files-table.admin-view th:nth-child(1),
.files-table.admin-view td:nth-child(1) { width: 25%; min-width: 200px; } /* Nom */
.files-table.admin-view th:nth-child(2),
.files-table.admin-view td:nth-child(2) { width: 10%; min-width: 80px; white-space: nowrap; } /* Taille */
.files-table.admin-view th:nth-child(3),
.files-table.admin-view td:nth-child(3) { width: 15%; min-width: 100px; white-space: nowrap; } /* Type */
.files-table.admin-view th:nth-child(4),
.files-table.admin-view td:nth-child(4) { width: 15%; min-width: 120px; white-space: nowrap; } /* Date */
.files-table.admin-view th:nth-child(5),
.files-table.admin-view td:nth-child(5) { width: 12%; min-width: 100px; } /* Utilisateur */
.files-table.admin-view th:nth-child(6),
.files-table.admin-view td:nth-child(6) { width: 10%; min-width: 90px; } /* Visibilité */
.files-table.admin-view th:nth-child(7),
.files-table.admin-view td:nth-child(7) { width: 13%; min-width: 180px; } /* Actions */

/* Dashboard - Utilisateur normal (5 colonnes) */
.files-table:not(.admin-view) th:nth-child(1),
.files-table:not(.admin-view) td:nth-child(1) { width: 30%; min-width: 200px; } /* Nom */
.files-table:not(.admin-view) th:nth-child(2),
.files-table:not(.admin-view) td:nth-child(2) { width: 12%; min-width: 80px; white-space: nowrap; } /* Taille */
.files-table:not(.admin-view) th:nth-child(3),
.files-table:not(.admin-view) td:nth-child(3) { width: 18%; min-width: 100px; white-space: nowrap; } /* Type */
.files-table:not(.admin-view) th:nth-child(4),
.files-table:not(.admin-view) td:nth-child(4) { width: 20%; min-width: 120px; white-space: nowrap; } /* Date */
.files-table:not(.admin-view) th:nth-child(5),
.files-table:not(.admin-view) td:nth-child(5) { width: 20%; min-width: 180px; } /* Actions */

/* Shared.php (6 colonnes) - classe .shared-view */
.files-table.shared-view th:nth-child(1),
.files-table.shared-view td:nth-child(1) { width: 25%; min-width: 200px; } /* Nom */
.files-table.shared-view th:nth-child(2),
.files-table.shared-view td:nth-child(2) { width: 10%; min-width: 80px; white-space: nowrap; } /* Taille */
.files-table.shared-view th:nth-child(3),
.files-table.shared-view td:nth-child(3) { width: 15%; min-width: 100px; white-space: nowrap; } /* Type */
.files-table.shared-view th:nth-child(4),
.files-table.shared-view td:nth-child(4) { width: 15%; min-width: 120px; white-space: nowrap; } /* Date */
.files-table.shared-view th:nth-child(5),
.files-table.shared-view td:nth-child(5) { width: 15%; min-width: 100px; } /* Propriétaire */
.files-table.shared-view th:nth-child(6),
.files-table.shared-view td:nth-child(6) { width: 20%; min-width: 150px; } /* Actions */

/* Users.php (4 colonnes) - classe .users-view */
.files-table.users-view th:nth-child(1),
.files-table.users-view td:nth-child(1) { width: 30%; min-width: 150px; } /* Username */
.files-table.users-view th:nth-child(2),
.files-table.users-view td:nth-child(2) { width: 20%; min-width: 100px; } /* Rôle */
.files-table.users-view th:nth-child(3),
.files-table.users-view td:nth-child(3) { width: 25%; min-width: 150px; white-space: nowrap; } /* Date de création */
.files-table.users-view th:nth-child(4),
.files-table.users-view td:nth-child(4) { width: 25%; min-width: 120px; } /* Actions */

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid var(--border);
}

.page-info {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Informations du fichier */
.file-info {
    background-color: var(--tertiary);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.file-info h2 {
    margin-bottom: 16px;
    font-size: 20px;
    font-weight: 600;
}

.file-details {
    margin-bottom: 20px;
}

.file-details p {
    margin-bottom: 8px;
    font-size: 14px;
}

.file-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* Prévisualisation */
.file-preview {
    background-color: var(--background);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

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

.preview-image img {
    max-width: 100%;
    max-height: 600px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

.preview-pdf {
    margin-top: 20px;
}

.preview-pdf iframe {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.preview-text {
    background-color: var(--tertiary);
    padding: 20px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    border: 1px solid var(--border);
}

.preview-text pre {
    margin: 0;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-primary);
}

.preview-unavailable {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

.badge-admin {
    background-color: #fff3cd;
    color: #856404;
}

/* Paramètres */
.settings-section {
    max-width: 600px;
}

.settings-section h2 {
    margin-bottom: 24px;
    font-size: 20px;
    font-weight: 600;
}

.settings-card {
    background-color: var(--tertiary);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.settings-card h3 {
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 600;
}

.info-group p {
    margin-bottom: 12px;
    font-size: 14px;
}

.settings-form {
    margin-top: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 12px;
    }

    .header h1 {
        font-size: 20px;
    }

    .user-info {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 8px;
    }

    .main-content {
        padding: 20px 16px;
    }

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

    .search-form {
        flex-direction: column;
    }

    .search-form input,
    .search-form select {
        width: 100%;
    }

    /* Tables responsive */
    .files-table {
        min-width: 600px; /* Force le défilement horizontal */
    }
    
    .files-table th,
    .files-table td {
        padding: 12px 8px;
        font-size: 13px;
    }

    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    .actions .btn {
        width: 100%;
        text-align: center;
        margin-bottom: 4px;
    }

    .file-input-label {
        padding: 24px;
    }

    .file-input-label .icon {
        font-size: 36px;
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 24px;
    }

    .header h1 {
        font-size: 18px;
    }

    .user-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .username {
        flex-direction: column;
        gap: 4px;
    }

    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .btn-small {
        padding: 6px 10px;
        font-size: 12px;
    }

    .file-input-label {
        padding: 16px;
    }

    .file-input-label .icon {
        font-size: 32px;
    }

    .main-content {
        padding: 16px 12px;
    }
    
    .filename {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}