/* ===== VARIABLES CSS ===== */
:root {
    --primary-color: #87CEEB;
    --secondary-color: #5DADE2;
    --accent-color: #AED6F1;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --danger-color: #f44336;
    --result-bg: #dc3545;
    --result-text: #ffffff;
    --result-accent: #ffeb3b;
    --dark-color: #37474f;
    --light-color: #ffffff;
    --gray-color: #757575;
    --border-radius: 12px;
    --transition: all 0.3s ease;
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* ===== RESET ET BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background: url('background.jpg') center center fixed;
    background-size: cover;
    background-repeat: no-repeat;
    min-height: 100vh;
}

/* ===== GESTION DES PAGES ===== */
#app-container {
    width: 100%;
    height: 100vh;
    position: relative;
}

.app-page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

#login-page {
    display: block;
    z-index: 1000;
}

#main-page {
    display: none;
    z-index: 999;
}

body.logged-in #login-page {
    display: none !important;
}

body.logged-in #main-page {
    display: block !important;
}

/* ===== PAGE DE LOGIN ===== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--light-color);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: 40px;
    width: 100%;
    max-width: 450px;
    text-align: center;
}

.logo-section {
    margin-bottom: 30px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo i {
    font-size: 2.5rem;
    color: var(--primary-color);
}

.logo-text {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.logo-subtitle {
    font-size: 0.9rem;
    color: var(--gray-color);
    font-weight: 500;
    letter-spacing: 2px;
}

.welcome-section h1 {
    font-size: 2.5rem;
    color: var(--dark-color);
    margin-bottom: 10px;
    font-weight: 600;
}

.welcome-section p {
    color: var(--gray-color);
    font-size: 1.1rem;
    margin-bottom: 30px;
}

.login-form {
    text-align: left;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark-color);
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-group i {
    position: absolute;
    left: 15px;
    color: var(--primary-color);
    z-index: 2;
}

.input-group input {
    width: 100%;
    padding: 15px 15px 15px 50px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--light-color);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(135, 206, 235, 0.2);
}

.btn-login {
    width: 100%;
    padding: 15px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-login:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

/* ===== NAVIGATION ===== */
.navbar {
    background: var(--light-color);
    border-bottom: 1px solid #e0e0e0;
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
}

.nav-brand i {
    font-size: 1.5rem;
}

.nav-menu {
    display: flex;
    gap: 10px;
}

.nav-link {
    text-decoration: none;
    color: var(--dark-color);
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 25px;
    transition: var(--transition);
    position: relative;
}

.nav-link:hover,
.nav-link.active {
    background: var(--primary-color);
    color: white;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-name {
    font-weight: 600;
    color: var(--dark-color);
}

.btn-logout {
    padding: 8px 16px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background: #d32f2f;
}

/* ===== CONTENU PRINCIPAL ===== */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

/* ===== SECTION ACCUEIL ===== */
.welcome-header {
    text-align: center;
    margin-bottom: 50px;
    padding: 40px;
    background: var(--light-color);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
}

.welcome-header h1 {
    font-size: 2.5rem;
    color: var(--dark-color);
    margin-bottom: 10px;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

.service-card {
    background: var(--light-color);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.service-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.service-card h3 {
    font-size: 1.5rem;
    color: var(--dark-color);
    margin-bottom: 15px;
}

.service-card p {
    color: var(--gray-color);
    margin-bottom: 25px;
    line-height: 1.6;
}

.btn-service {
    padding: 12px 30px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-service:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

/* ===== SECTIONS GÉNÉRALES ===== */
.section-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px;
    background: var(--light-color);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
}

.section-header h2 {
    font-size: 2rem;
    color: var(--dark-color);
    margin-bottom: 10px;
}

.section-header p {
    color: var(--gray-color);
    font-size: 1.1rem;
}

/* ===== FORMULAIRES ===== */
form {
    background: var(--light-color);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 30px;
}

.save-patient-option {
    margin-bottom: 25px;
    padding: 20px;
    background: #e3f2fd;
    border-radius: var(--border-radius);
    border: 2px solid var(--primary-color);
}

.save-patient-option input[type="checkbox"] {
    margin-right: 10px;
    transform: scale(1.2);
    accent-color: var(--primary-color);
}

.save-patient-option label {
    font-size: 1.1rem;
    color: var(--dark-color);
    cursor: pointer;
}

#patient-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
    padding: 20px;
    background: #e8f5e8;
    border-radius: var(--border-radius);
    border: 2px solid var(--success-color);
}

#patient-fields input {
    padding: 12px;
    border: 2px solid #c8e6c9;
    border-radius: var(--border-radius);
    font-size: 1rem;
    background: var(--light-color);
}

.medical-data {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.medical-data input,
.medical-data select {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--light-color);
}

.medical-data input:focus,
.medical-data select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(135, 206, 235, 0.2);
}

.conditions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    padding: 20px;
    background: #fff3e0;
    border-radius: var(--border-radius);
    border: 2px solid var(--warning-color);
}

.conditions label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px;
    border-radius: var(--border-radius);
    transition: var(--transition);
    background: var(--light-color);
}

.conditions label:hover {
    background: #f5f5f5;
}

.conditions input[type="checkbox"] {
    transform: scale(1.2);
    accent-color: var(--primary-color);
}

button[type="submit"] {
    width: 100%;
    padding: 15px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

button[type="submit"]:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

/* ===== RÉSULTATS ===== */
.result-card {
    color: white;
    padding: 40px;
    border-radius: var(--border-radius);
    margin-bottom: 40px;
    text-align: center;
    border: 5px solid;
    position: relative;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    animation: pulse 3s infinite;
}

.result-card.result-positive {
    background: linear-gradient(135deg, #d32f2f, #f44336);
    border-color: #b71c1c;
    box-shadow: 0 8px 25px rgba(220, 53, 69, 0.4);
}

.result-card.result-negative {
    background: linear-gradient(135deg, #388e3c, #4caf50);
    border-color: #2e7d32;
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.4);
}

.result-card::before {
    content: '📊 RÉSULTAT DE L\'ANALYSE';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    font-weight: 800;
    font-size: 0.9rem;
    letter-spacing: 1px;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.result-card h3 {
    font-size: 2.2rem;
    margin: 35px 0 25px 0;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.result-card .confidence-section {
    margin: 25px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.result-card .confidence-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: #ffeb3b;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.result-card .confidence-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
}

.result-card .confidence-percentage {
    font-weight: 800;
    font-size: 1.2rem;
    color: #ffeb3b;
}

.result-card .organ-recommendation {
    margin: 20px 0;
    padding: 15px;
    background: rgba(255, 235, 59, 0.2);
    border: 2px solid #ffeb3b;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffeb3b;
}

.result-card button {
    padding: 15px 35px;
    background: #ffeb3b;
    color: #333;
    border: 3px solid #ffc107;
    border-radius: 25px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 800;
    font-size: 1.1rem;
    margin-top: 20px;
    box-shadow: 0 4px 15px rgba(255, 235, 59, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.result-card button:hover {
    background: #ffc107;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 235, 59, 0.4);
    border-color: #ff9800;
}

/* ===== DOSSIERS PATIENTS ===== */
#patient-id-search {
    width: 100%;
    padding: 15px;
    margin-bottom: 30px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    background: var(--light-color);
}

#patient-id-search:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(135, 206, 235, 0.2);
}

#patients-list {
    background: var(--light-color);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
}

.patient-card {
    border: 1px solid #e0e0e0;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.patient-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(135, 206, 235, 0.2);
}

/* ===== STATISTIQUES ===== */
#stats-content {
    background: var(--light-color);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    color: var(--dark-color);
}

.stats-container {
    margin-bottom: 20px;
}

.stats-container h3 {
    font-size: 1.8rem;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.stats-container p,
.stats-container ul {
    font-size: 1.1rem;
    line-height: 1.6;
}

.stats-container ul {
    list-style: none;
    padding-left: 0;
}

.stats-container li {
    padding: 5px 0;
}

.stats-container button {
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.stats-container button:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

/* ===== STYLES POUR LES GRAPHIQUES STATISTIQUES ===== */
.stats-summary {
    background: linear-gradient(135deg, #87CEEB, #5DADE2);
    color: white;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(135, 206, 235, 0.3);
}

.stats-summary h3 {
    margin-bottom: 15px;
    font-size: 1.5rem;
    font-weight: 700;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.summary-item {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    transition: var(--transition);
}

.summary-item:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.summary-number {
    font-size: 2rem;
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
}

.summary-label {
    font-size: 0.9rem;
    opacity: 0.9;
    font-weight: 500;
}

.stats-charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

.chart-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 2px solid #e0e0e0;
    transition: all 0.3s ease;
    overflow: hidden;
}

.chart-card:hover {
    border-color: #87CEEB;
    box-shadow: 0 8px 30px rgba(135, 206, 235, 0.2);
    transform: translateY(-2px);
}

.chart-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #37474f;
    margin-bottom: 20px;
    text-align: center;
    border-bottom: 2px solid #87CEEB;
    padding-bottom: 10px;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-container canvas {
    max-height: 100%;
    max-width: 100%;
}

/* ===== LOADING ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    text-align: center;
    color: white;
}

.loading-spinner i {
    font-size: 3rem;
    margin-bottom: 20px;
    color: var(--primary-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner p {
    font-size: 1.2rem;
}

/* ===== ALERTES ===== */
.alert {
    padding: 15px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-success {
    background: var(--success-color);
    color: white;
}

.alert-danger {
    background: var(--danger-color);
    color: white;
}

.alert-warning {
    background: var(--warning-color);
    color: white;
}

.alert-info {
    background: var(--primary-color);
    color: white;
}

/* ===== BOUTONS GÉNÉRAUX ===== */
.btn,
.btn-primary,
.btn-secondary,
button:not(.btn-logout):not(.result-card button) {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
}

.btn:hover,
.btn-primary:hover,
.btn-secondary:hover,
button:not(.btn-logout):not(.result-card button):hover {
    background: var(--secondary-color) !important;
    border-color: var(--secondary-color) !important;
    transform: translateY(-2px);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 20px;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    
    .services-grid {
        grid-template-columns: 1fr;
    }
    
    .medical-data {
        grid-template-columns: 1fr;
    }
    
    .conditions {
        grid-template-columns: 1fr;
    }
    
    .welcome-header h1 {
        font-size: 2rem;
    }
    
    .login-card {
        padding: 30px 20px;
    }
    
    .result-card h3 {
        font-size: 1.5rem;
    }
    
    .stats-charts-container {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        height: 250px;
    }
    
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 20px 10px;
    }
    
    form {
        padding: 20px;
    }
    
    .welcome-header {
        padding: 20px;
    }
    
    .service-card {
        padding: 25px;
    }
    
    .result-card {
        padding: 25px;
    }
    
    .chart-container {
        height: 200px;
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content-section.active {
    animation: fadeIn 0.5s ease-out;
}

@keyframes pulse {
    0% { box-shadow: 0 8px 30px rgba(220, 53, 69, 0.3); }
    50% { box-shadow: 0 12px 40px rgba(220, 53, 69, 0.5); }
    100% { box-shadow: 0 8px 30px rgba(220, 53, 69, 0.3); }
}

.result-card {
    animation: pulse 3s infinite;
}