* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    color: #333;
}

.navbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 20px;
}

.language-selector {
    display: flex;
    gap: 10px;
    align-items: center;
}

.lang-link {
    padding: 6px 12px;
    border-radius: 4px;
    text-decoration: none;
    color: white;
    font-size: 14px;
    transition: background 0.3s;
    border: 1px solid rgba(255,255,255,0.3);
}

.lang-link:hover {
    background: rgba(255,255,255,0.2);
}

.lang-link.active {
    background: rgba(255,255,255,0.3);
    border-color: white;
}

/* RTL Support */
[dir="rtl"] .nav-container {
    flex-direction: row-reverse;
}

[dir="rtl"] .nav-user {
    flex-direction: row-reverse;
}

[dir="rtl"] .menu-grid {
    direction: rtl;
}

[dir="rtl"] .form-row {
    direction: rtl;
}

[dir="rtl"] table th,
[dir="rtl"] table td {
    text-align: right;
}

[dir="rtl"] .filter-row {
    direction: rtl;
}

[dir="rtl"] .action-buttons {
    flex-direction: row-reverse;
}

[dir="rtl"] .stats-grid {
    direction: rtl;
}

.btn-logout {
    background: rgba(255,255,255,0.2);
    padding: 8px 16px;
    border-radius: 5px;
    text-decoration: none;
    color: white;
    transition: background 0.3s;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.3);
}

.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.dashboard h2 {
    margin-bottom: 2rem;
    color: #333;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
}

.menu-card {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-decoration: none;
    color: #333;
    transition: transform 0.3s, box-shadow 0.3s;
    display: block;
}

.menu-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

.menu-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.menu-card h3 {
    margin-bottom: 0.5rem;
    color: #667eea;
}

.menu-card p {
    color: #666;
    font-size: 0.9rem;
}

/* Formulaires */
.form-container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-width: 800px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

.alert {
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Tableaux */
.table-container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow-x: auto;
    max-width: 100%;
}

/* Styles pour défilement horizontal visible */
.table-container::-webkit-scrollbar {
    height: 10px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

table tr:hover {
    background: #f8f9fa;
}

/* Statistiques */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.stat-card h3 {
    color: #667eea;
    margin-bottom: 0.5rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #333;
}

/* Filtres */
.filter-section {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    align-items: end;
}

/* Actions */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-small {
    padding: 6px 10px;
    font-size: 13px;
    min-width: 36px; /* Largeur minimale pour les boutons icône uniquement */
}

/* Boutons d'actions dans les tableaux : encore plus compacts */
.data-table .btn-small {
    padding: 5px 8px;
    font-size: 16px; /* Les emojis sont plus lisibles en 16px */
    min-width: 32px;
    line-height: 1;
}

/* Tableaux - Unified Design */
.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Largeur minimale réduite */
    table-layout: auto; /* Permet une répartition intelligente des colonnes */
}

.data-table th {
    background: linear-gradient(135deg, #f0f2f5 0%, #e8eaee 100%);
    font-weight: 600;
    color: #333;
    padding: 10px 8px; /* Padding réduit */
    text-align: left;
    border-bottom: 2px solid #ddd;
    white-space: nowrap;
    font-size: 0.9em; /* Texte légèrement plus petit */
}

.data-table th a {
    color: #333;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
}

.data-table th a:hover {
    color: #667eea;
}

.data-table tbody tr {
    transition: background 0.2s;
}

.data-table tbody tr:hover {
    background: #f8f9fa;
}

.data-table td {
    padding: 10px 8px; /* Padding réduit pour gagner de l'espace */
    border-bottom: 1px solid #ddd;
    text-align: left;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9em;
}

/* Tooltip au survol pour voir le contenu complet */
.data-table td[title]:hover {
    position: relative;
    overflow: visible;
}

.data-table .patient-row:nth-child(even) {
    background: #fafbfc;
}

/* Column Styles */
.data-table .file-number {
    font-weight: 600;
    color: #667eea;
}

.data-table .patient-name {
    font-weight: 500;
}

.data-table .badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    font-size: 0.9em;
}

.data-table .statut-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
}

.data-table .statut-planifie {
    background-color: #d1ecf1;
    color: #0c5460;
}

.data-table .statut-en_cours {
    background-color: #fff3cd;
    color: #856404;
}

.data-table .statut-termine {
    background-color: #d4edda;
    color: #155724;
}

.data-table .statut-annule {
    background-color: #f8d7da;
    color: #721c24;
}

.data-table .action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Colonnes d'actions : compact et sans troncature */
.data-table td.actions {
    white-space: nowrap;
    max-width: none;
    overflow: visible;
    padding: 8px 4px; /* Encore plus compact pour les actions */
}

/* Numéro de dossier : compact */
.data-table .file-number {
    white-space: nowrap;
    max-width: 80px;
    font-weight: 600;
}

/* Noms : limités mais pas trop */
.data-table .patient-name {
    max-width: 120px;
    font-weight: 500;
}

.data-table .mother-name {
    max-width: 100px;
}

/* Téléphone et organisme : très compacts */
.data-table .phone {
    max-width: 90px;
    font-size: 0.85em;
}

.data-table .insurance {
    max-width: 80px;
}

/* Dates : format court et compact */
.data-table .birth-date,
.data-table .creation-date,
.data-table .created-by {
    white-space: nowrap;
    max-width: 95px;
    font-size: 0.85em;
}

/* Badge de visite : très compact */
.data-table .visit-count {
    white-space: nowrap;
    max-width: 50px;
    text-align: center;
}

/* Search/Filter Form */
.search-form-wrapper {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-form .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    align-items: end;
}

/* Pagination */
.pagination {
    margin-top: 2rem;
    text-align: center;
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.pagination-info {
    margin-bottom: 1rem;
    color: #666;
    font-size: 0.95em;
}

.pagination-links {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pagination-links .btn {
    padding: 8px 12px;
    font-size: 13px;
}

.pagination-links .btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Filter Row */
.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    align-items: end;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #f0f0f0;
}

.page-header h1 {
    font-size: 2rem;
    color: #333;
    margin: 0;
}

.page-header > div {
    display: flex;
    gap: 1rem;
}

/* Patient Info Card */
.patient-info-card {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.patient-info-card h3 {
    color: #333;
    margin-bottom: 1.5rem;
    font-size: 1.3em;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.info-item {
    display: flex;
    flex-direction: column;
}

.info-item label {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 0.5rem;
    font-size: 0.9em;
}

.info-item span,
.info-item strong {
    color: #333;
}

/* RDV History Card */
.rdv-history-card {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.rdv-history-card h3 {
    color: #333;
    margin-bottom: 1.5rem;
    font-size: 1.3em;
}

/* Responsive */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .menu-grid {
        grid-template-columns: 1fr;
    }
    
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .page-header > div {
        width: 100%;
        flex-wrap: wrap;
    }

    .search-form .form-row {
        grid-template-columns: 1fr;
    }

    .data-table {
        font-size: 0.9em;
    }

    .data-table th,
    .data-table td {
        padding: 8px;
    }

    /* Sur mobile, forcer le scroll horizontal avec un indicateur visuel */
    .table-container {
        position: relative;
        padding-bottom: 1rem;
    }

    .table-container::after {
        content: "← Faire défiler →";
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        font-size: 0.85em;
        color: #999;
        padding: 0.5rem;
        background: rgba(255, 255, 255, 0.9);
        border-radius: 5px;
        pointer-events: none;
    }

    .data-table thead {
        display: none;
    }

    .data-table tbody {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .data-table tbody tr {
        display: block;
        border: 1px solid #e0e0e0;
        border-radius: 10px;
        padding: 0.5rem;
        background: #fff;
        box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        padding: 0.4rem 0;
        border-bottom: none;
    }

    .data-table td::before {
        content: attr(data-label);
        flex: 1 1 50%;
        font-weight: 600;
        color: #555;
        text-transform: capitalize;
        padding-right: 0.5rem;
    }

    .data-table td:last-child {
        border-bottom: none;
        padding-bottom: 0;
        margin-bottom: 0;
    }

    .data-table .table-actions {
        justify-content: flex-end;
    }
}

