/* ============================================
   TIM Interface - Styles Globaux et Layout
   ============================================ */

/* Variables CSS */
:root {
    /* Couleurs principales */
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    
    /* Couleurs de confiance */
    --confidence-high: #48bb78;
    --confidence-medium: #f59e0b;
    --confidence-low: #f56565;
    
    /* Couleurs de mise en évidence des preuves */
    --highlight-dp: #3b82f6;      /* Bleu pour DP */
    --highlight-dr: #10b981;      /* Vert pour DR */
    --highlight-das: #f59e0b;     /* Jaune pour DAS */
    --highlight-ccam: #8b5cf6;    /* Violet pour CCAM */
    
    /* Couleurs neutres */
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --border-color: #e0e0e0;
    
    /* Dimensions */
    --header-height: 80px;
    --codes-width: 25%;
    --documents-width: 45%;
    --details-width: 30%;
    
    /* Espacements */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Typographie */
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-size-base: 14px;
    --font-size-lg: 16px;
    --font-size-xl: 18px;
    
    /* Ombres */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.15);
}

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

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* En-tête avec informations patient */
#patient-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: var(--spacing-md) var(--spacing-lg);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 60px;
}

.patient-header-content {
    display: flex;
    justify-content: space-between;
    gap: var(--spacing-lg);
    max-width: 100%;
    margin: 0 auto;
}

.patient-info-section,
.stay-info-section {
    flex: 1;
}

.section-title {
    font-size: 0.9em;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    opacity: 0.95;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 4px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--spacing-sm);
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-label {
    font-size: 0.75em;
    opacity: 0.85;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 0.95em;
    font-weight: 600;
}

/* Anciens styles pour compatibilité */
.patient-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
    margin: 0 auto;
}

.patient-info-item {
    display: flex;
    flex-direction: column;
}

.patient-info-label {
    font-size: 0.85em;
    opacity: 0.9;
    margin-bottom: var(--spacing-xs);
}

.patient-info-value {
    font-size: 1.1em;
    font-weight: 600;
}

/* Layout 3 panneaux avec CSS Grid */
.three-panel-layout {
    display: grid;
    grid-template-columns: var(--codes-width) 1px var(--documents-width) 1px var(--details-width);
    height: calc(100vh - var(--header-height));
    gap: 0;
    overflow: hidden;
}

/* Panneaux */
.panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    overflow: hidden;
}

.panel-header {
    padding: var(--spacing-md);
    border-bottom: 2px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.panel-header h2 {
    color: var(--primary-color);
    font-size: var(--font-size-xl);
    margin-bottom: var(--spacing-sm);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
}

/* Séparateurs redimensionnables */
.panel-separator {
    cursor: col-resize;
    background: var(--border-color);
    position: relative;
    transition: background 0.2s;
    user-select: none;
}

.panel-separator:hover {
    background: var(--primary-color);
}

.panel-separator.dragging {
    background: var(--primary-dark);
}

/* Indicateur visuel du séparateur */
.panel-separator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 40px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.panel-separator:hover::before {
    opacity: 1;
}

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

.panel-content::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.panel-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Mode responsive - empilage vertical sur mobile */
@media (max-width: 768px) {
    .three-panel-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        height: auto;
        min-height: calc(100vh - var(--header-height));
    }
    
    .panel-separator {
        display: none;
    }
    
    .panel {
        min-height: 300px;
        border-bottom: 2px solid var(--border-color);
    }
    
    .panel:last-child {
        border-bottom: none;
    }
    
    #patient-header {
        position: relative;
        height: auto;
        min-height: auto;
    }
    
    .patient-header-content {
        flex-direction: column;
        gap: var(--spacing-md);
    }
    
    .info-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }
    
    /* Anciens styles pour compatibilité */
    .patient-info {
        flex-direction: column;
        gap: var(--spacing-md);
    }
    
    .patient-info-section {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
}

/* Tablettes */
@media (min-width: 769px) and (max-width: 1024px) {
    :root {
        --codes-width: 30%;
        --documents-width: 40%;
        --details-width: 30%;
    }
}

/* États de chargement */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

/* Messages d'erreur et de succès */
.message {
    padding: var(--spacing-md);
    border-radius: 8px;
    margin-bottom: var(--spacing-md);
    display: none;
}

.message.error {
    background: #fed7d7;
    color: #742a2a;
    border-left: 4px solid var(--confidence-low);
}

.message.success {
    background: #c6f6d5;
    color: #22543d;
    border-left: 4px solid var(--confidence-high);
}

.message.warning {
    background: #feebc8;
    color: #7c2d12;
    border-left: 4px solid var(--confidence-medium);
}

/* Boutons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
}

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

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

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

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

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

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

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

/* Accessibilité - indicateurs de focus */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

button:focus,
a:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Utilitaires */
.hidden {
    display: none !important;
}

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

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }

.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }


/* Badges de confiance */
.confidence-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    display: inline-block;
}

.confidence-high {
    background: #c6f6d5;
    color: #22543d;
}

.confidence-medium {
    background: #feebc8;
    color: #7c2d12;
}

.confidence-low {
    background: #fed7d7;
    color: #742a2a;
}

/* Styles pour l'interface de recherche */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Media queries additionnelles pour améliorer le responsive */
@media (max-width: 480px) {
    :root {
        --font-size-base: 13px;
        --spacing-md: 12px;
    }
    
    .patient-info-value {
        font-size: 1em;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 14px;
    }
}
