/* css/styles.css - Version mise à jour avec styles Drag & Drop */
/* Styles personnalisés pour l'application de gestion des patients */

/* Variables CSS pour une personnalisation facile */
:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --gray-light: #f3f4f6;
    --gray-dark: #374151;
}

/* Police de base */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Loader animé */
.loader {
    border: 3px solid var(--gray-light);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Modal backdrop */
.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

/* Animations de transition */
.transition-colors {
    transition: background-color 0.2s, color 0.2s;
}

/* ===== STYLES DRAG & DROP ===== */

/* Cartes de patients draggables */
.patient-card {
    cursor: grab;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
}

.patient-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.patient-card:hover .drag-handle {
    opacity: 1;
}

/* Handle de drag */
.drag-handle {
    opacity: 0.3;
    transition: opacity 0.2s ease;
    cursor: grab;
    padding: 4px;
    border-radius: 4px;
}

.drag-handle:hover {
    opacity: 1;
    background-color: rgba(59, 130, 246, 0.1);
}

/* État pendant le drag */
.patient-card-dragging {
    opacity: 0.7;
    transform: rotate(3deg) scale(1.02);
    cursor: grabbing;
    z-index: 1000;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    border: 2px solid var(--primary-color);
}

/* Zones de drop */
.drop-zone {
    transition: all 0.3s ease;
    border-radius: 8px;
    position: relative;
    min-height: 80px;
}

.drop-zone-active {
    border: 2px dashed var(--primary-color) !important;
    background-color: rgba(59, 130, 246, 0.05) !important;
    transform: scale(1.01);
}

.drop-zone-over {
    border: 3px solid var(--success-color) !important;
    background-color: rgba(16, 185, 129, 0.1) !important;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
    transform: scale(1.02);
}

/* Indicateur de drop */
.drop-indicator {
    position: absolute;
    left: 10px;
    right: 10px;
    height: 4px;
    background: linear-gradient(90deg, var(--success-color), #34d399);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.drop-indicator.show {
    opacity: 1;
    animation: pulse-indicator 1.5s infinite;
}

@keyframes pulse-indicator {
    0%, 100% { transform: scaleX(1); }
    50% { transform: scaleX(1.05); }
}

/* Messages de zone vide avec instructions drag & drop */
.drop-zone p small {
    color: #9ca3af;
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drop-zone-active p small,
.drop-zone:hover p small {
    opacity: 1;
}

/* Cards de jours améliorées */
.day-card {
    transition: all 0.2s ease;
}

.day-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.day-card.drop-zone-active {
    background-color: rgba(59, 130, 246, 0.05) !important;
}

.day-card.drop-zone-over {
    background-color: rgba(16, 185, 129, 0.05) !important;
}

/* ===== STYLES DRAG & DROP TABLEAUX ===== */

/* Tables avec support drag & drop */
.patient-table-row {
    transition: all 0.2s ease;
}

.patient-table-row:hover {
    background-color: rgba(59, 130, 246, 0.05) !important;
}

/* Styles spécifiques pour les sections du dashboard */
#day-section-\* {
    transition: all 0.3s ease;
}

#future-section,
#discuss-section {
    transition: all 0.3s ease;
}

/* États des zones de drop pour sections */
.table-drop-zone-active#future-section,
.table-drop-zone-active#discuss-section,
.table-drop-zone-active[id^="day-section-"] {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

.table-drop-zone-over#future-section,
.table-drop-zone-over#discuss-section,
.table-drop-zone-over[id^="day-section-"] {
    transform: scale(1.03);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
}

/* États vides avec zones de drop */
.empty-day-zone,
.empty-future-zone,
.empty-discuss-zone {
    transition: all 0.3s ease;
}

.table-drop-zone-active .empty-day-zone,
.table-drop-zone-active .empty-future-zone,
.table-drop-zone-active .empty-discuss-zone {
    border-color: #3b82f6 !important;
    background-color: rgba(59, 130, 246, 0.1) !important;
    transform: scale(1.05);
}

.table-drop-zone-over .empty-day-zone,
.table-drop-zone-over .empty-future-zone,
.table-drop-zone-over .empty-discuss-zone {
    border-color: #10b981 !important;
    background-color: rgba(16, 185, 129, 0.1) !important;
    transform: scale(1.08);
}

/* Animation pour les compteurs de patients */
.patient-count {
    transition: all 0.3s ease;
}

.patient-count.updated {
    color: #10b981;
    font-weight: 600;
    animation: countUpdate 0.6s ease-out;
}

@keyframes countUpdate {
    0% {
        transform: scale(1);
        color: inherit;
    }
    50% {
        transform: scale(1.2);
        color: #10b981;
    }
    100% {
        transform: scale(1);
        color: #10b981;
    }
}

/* Amélioration responsive pour les handles de drag sur mobile */
@media (max-width: 768px) {
    .table-drag-handle {
        opacity: 0.8 !important;
        padding: 8px;
        margin-right: 4px;
    }

    /* Plus d'espace pour les doigts sur mobile */
    .patient-table-row td:first-child {
        padding-left: 12px;
    }

    /* Réduction des effets d'animation sur mobile pour les performances */
    .table-drop-zone-active,
    .table-drop-zone-over {
        transform: none;
    }
}

/* ===== FIN STYLES DRAG & DROP TABLEAUX ===== */

/* Style pour les zones de drag & drop (anciens styles conservés pour compatibilité) */
.drop-zone-highlight {
    border-style: dashed !important;
    border-color: var(--primary-color) !important;
    background-color: #eff6ff !important;
}

.patient-row-dragging {
    opacity: 0.5;
    background-color: #e0e7ff;
    cursor: grabbing;
}

/* Patient row styles */
.patient-row-selected {
    background-color: #dbeafe !important;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.patient-row-decided {
    background-color: #dcfce7 !important;
}

/* Amélioration de l'accessibilité */
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Navigation active */
.nav-btn {
    position: relative;
    transition: all 0.2s;
}

.nav-btn.border-b-2 {
    border-bottom-width: 2px;
}

/* Cards hover effect */
.hover\:shadow-lg {
    transition: box-shadow 0.3s;
}

/* Responsive tables */
@media (max-width: 768px) {
    .patient-card {
        display: block;
        margin-bottom: 1rem;
    }

    /* Réduire les effets hover sur mobile */
    .patient-card:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }

    .drag-handle {
        opacity: 0.7;
    }
}

/* ===== STYLES D'IMPRESSION OPTIMISES ===== */
@media print {
    /* Masquer éléments non imprimables */
    .no-print, .drag-handle, header, nav, button, .btn, #user-info,
    .table-drag-handle, .print-hide, .empty-section-print-hide,
    td button, .text-center.py-4 { display: none !important; }

    /* Reset de base */
    body { background: white; font-size: 5pt; padding: 0; margin: 0; }
    #main-content { padding: 0 !important; margin: 0 !important; }
    .shadow, .rounded-lg { box-shadow: none !important; border-radius: 0 !important; }

    /* En-tête d'impression */
    .print-header { display: block !important; text-align: center; padding: 5px 0; border-bottom: 1px solid #333; margin-bottom: 5px; }
    .print-header h1 { font-size: 12pt; margin: 0; }
    .print-header .print-date { font-size: 8pt; color: #666; }

    /* Tables - règles simplifiées */
    table { width: 100%; border-collapse: collapse; font-size: 5pt; table-layout: fixed; }
    th, td { border: 1px solid #999; padding: 1px 2px; vertical-align: top; font-size: 5pt; line-height: 1.2; overflow: hidden; }
    th { background: #ddd; font-weight: bold; }

    /* Colonnes dashboard */
    table:not(#hospitalises-table) td:nth-child(1) { width: 12%; }
    table:not(#hospitalises-table) td:nth-child(2) { width: 15%; }
    table:not(#hospitalises-table) td:nth-child(3) { width: 13%; }
    table:not(#hospitalises-table) td:nth-child(4) { width: 60%; }

    /* Masquer colonne Actions */
    th:last-child, td:last-child { display: none !important; }

    /* Sections */
    h3, h4 { margin: 4px 0 2px 0; font-size: 8pt; page-break-after: avoid; }
    tr { page-break-inside: avoid; }

    /* Badges compacts */
    .lesion-type-badge, [class*="bg-"][class*="-100"] { font-size: 4pt; padding: 0 2px; }

    /* Page A4 portrait */
    @page { margin: 0.5cm; size: A4 portrait; }
}

/* Styles pour l'en-tête d'impression (masqué en mode normal) */
.print-header {
    display: none;
}

.print-footer {
    display: none;
}

/* Bouton d'impression */
.btn-print {
    background-color: #6b7280;
    color: white;
    transition: all 0.2s;
}

.btn-print:hover {
    background-color: #4b5563;
}

/* Scrollbar personnalisée */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-light);
}

::-webkit-scrollbar-thumb {
    background: #9ca3af;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-dark);
}

/* Badge de notification */
.badge {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

/* Amélioration des formulaires */
input[type="text"],
input[type="date"],
select,
textarea {
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* État désactivé */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Tooltips (optionnel) */
[title] {
    position: relative;
}

[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.25rem 0.5rem;
    background: var(--gray-dark);
    color: white;
    font-size: 0.75rem;
    border-radius: 0.25rem;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
}

/* Animation d'apparition pour les nouvelles cartes */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.patient-card {
    animation: slideIn 0.3s ease-out;
}

/* Feedback visuel pour les actions réussies */
@keyframes successPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.success-animation {
    animation: successPulse 0.6s ease-out;
}

/* Styles supplémentaires pour la gestion des lésions */

/* Conteneur des lésions */
#lesions-container {
    max-height: 400px;
    overflow-y: auto;
}

/* Animation pour l'ajout de lésions */
#lesions-container > div {
    animation: slideInFade 0.3s ease-out;
    transition: all 0.3s ease;
}

@keyframes slideInFade {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Style pour les sections du modal */
.bg-gray-50 h4,
.bg-blue-50 h4 {
    border-bottom: 2px solid var(--primary-color);
    display: inline-block;
    padding-bottom: 2px;
}

/* Bouton de suppression de lésion */
.lesion-remove-btn {
    transition: all 0.2s;
}

.lesion-remove-btn:hover {
    background-color: rgba(239, 68, 68, 0.1);
    border-radius: 50%;
}

/* Amélioration des champs de lésion */
.lesion-field {
    position: relative;
}

.lesion-field input:focus,
.lesion-field select:focus,
.lesion-field textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    transform: translateY(-1px);
}

/* Indicateur de lésion obligatoire */
.lesion-required::after {
    content: " *";
    color: var(--danger-color);
    font-weight: bold;
}

/* Styles pour les badges de type de lésion */
.lesion-type-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.lesion-type-plaie {
    background-color: #fef2f2;
    color: #dc2626;
}

.lesion-type-fracture {
    background-color: #fff7ed;
    color: #ea580c;
}

.lesion-type-sepsis {
    background-color: #fefce8;
    color: #ca8a04;
}

.lesion-type-polytraumatise {
    background-color: #f3e8ff;
    color: #9333ea;
}

.lesion-type-autre {
    background-color: #f1f5f9;
    color: #475569;
}

/* Style pour le modal plus large */
.modal-wide {
    max-width: 1024px;
}

/* Responsive pour les lésions */
@media (max-width: 768px) {
    #lesions-container {
        max-height: 300px;
    }

    .lesion-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* Animation pour la suppression de lésion */
.lesion-removing {
    animation: slideOutFade 0.3s ease-in forwards;
}

@keyframes slideOutFade {
    from {
        opacity: 1;
        transform: translateY(0);
        max-height: 200px;
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
        max-height: 0;
        margin: 0;
        padding: 0;
    }
}

/* Amélioration du contraste des labels */
.lesion-container label {
    color: #374151;
    font-weight: 500;
}

/* Style pour les placeholders */
.lesion-container input::placeholder,
.lesion-container textarea::placeholder {
    color: #9ca3af;
    font-style: italic;
}

/* Bordure colorée pour différencier les lésions */
.lesion-container {
    border-left: 4px solid var(--primary-color);
}

.lesion-container:nth-child(odd) {
    border-left-color: #10b981;
}

.lesion-container:nth-child(even) {
    border-left-color: #f59e0b;
}

/* Corriger uniquement le tooltip de drag & drop sans masquer l'icône */
.table-drag-handle:hover::after {
    display: none !important;
}

/* Ajuster le z-index si le tooltip apparaît quand même */
.drag-handle {
    position: relative;
    z-index: 1;
}

/* Styles additionnels à ajouter à css/styles.css pour les lésions */

/* Animation pour l'ajout/suppression de lésions */
#lesions-container > div {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Style pour les boutons de lésion */
.lesion-remove-btn {
    transition: all 0.2s;
    padding: 0.25rem;
    border-radius: 0.25rem;
}

.lesion-remove-btn:hover {
    background-color: #fee2e2;
}

/* Amélioration des formulaires de lésion */
#lesions-container input[type="text"],
#lesions-container select,
#lesions-container textarea {
    font-size: 0.875rem;
}

#lesions-container .border {
    border-color: #e5e7eb;
}

#lesions-container .bg-gray-50 {
    background-color: #f9fafb;
}

/* Responsive pour les lésions */
@media (max-width: 768px) {
    #lesions-container .grid-cols-2 {
        grid-template-columns: 1fr;
    }
}

/* ===== Patients hospitalisés - Cellules éditables ===== */

.editable-cell {
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.editable-cell:hover {
    background-color: rgba(59, 130, 246, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.editable-cell.editing {
    background-color: #ffffff;
    padding: 2px;
}

/* Icône crayon au survol */
.editable-cell::after {
    content: '✎';
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 11px;
    color: #9ca3af;
    opacity: 0;
    transition: opacity 0.2s;
}

.editable-cell:hover::after {
    opacity: 0.6;
}

.editable-cell.editing::after {
    display: none;
}

/* Éditeur (input/textarea) */
.editable-cell textarea,
.editable-cell input {
    font-family: inherit;
    line-height: 1.4;
}

.editable-cell textarea {
    resize: vertical;
    min-height: 60px;
}

.editable-cell textarea:focus,
.editable-cell input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Scroll horizontal pour grande table */
.overflow-x-auto {
    scrollbar-width: thin;
    scrollbar-color: #9ca3af #e5e7eb;
}

.overflow-x-auto::-webkit-scrollbar {
    height: 10px;
}

.overflow-x-auto::-webkit-scrollbar-track {
    background: #e5e7eb;
    border-radius: 5px;
}

.overflow-x-auto::-webkit-scrollbar-thumb {
    background: #9ca3af;
    border-radius: 5px;
}

.overflow-x-auto::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}
/* ===== PAGE DE LOGIN ===== */

.login-page {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255, 255, 255, 0.03) 10px,
        rgba(255, 255, 255, 0.03) 20px
    );
    animation: slide 20s linear infinite;
}

@keyframes slide {
    0% { transform: translate(0, 0); }
    100% { transform: translate(50px, 50px); }
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    margin: 0 0 8px 0;
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
}

.login-header .subtitle {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-form label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.login-form input[type="text"],
.login-form input[type="password"] {
    padding: 12px 16px;
    font-size: 15px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    transition: all 0.2s;
    font-family: inherit;
}

.login-form input[type="text"]:focus,
.login-form input[type="password"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper input {
    width: 100%;
    padding-right: 48px;
}

.toggle-password {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.toggle-password:hover {
    color: #6b7280;
}

.toggle-password.active {
    color: #3b82f6;
}

.toggle-password .eye-icon {
    width: 20px;
    height: 20px;
}

.error-message {
    padding: 12px 16px;
    background: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    color: #991b1b;
    font-size: 14px;
    text-align: center;
}

.error-message.shake {
    animation: shake 0.4s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.btn-login {
    padding: 14px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 52px;
}

.btn-login:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-login:active:not(:disabled) {
    transform: translateY(0);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-loader {
    display: flex;
    align-items: center;
}

.spinner {
    animation: spin 1s linear infinite;
}

.spinner-track {
    stroke: rgba(255, 255, 255, 0.3);
}

.spinner-head {
    stroke: white;
    stroke-dasharray: 50;
    stroke-dashoffset: 25;
    stroke-linecap: round;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

.login-footer {
    margin-top: 24px;
    text-align: center;
}

.help-text {
    margin: 0;
    font-size: 13px;
    color: #6b7280;
}

.version-info {
    margin-top: 20px;
    text-align: center;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
}

/* Responsive */
@media (max-width: 480px) {
    .login-card {
        padding: 30px 24px;
    }

    .login-header h1 {
        font-size: 24px;
    }
}
