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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    color: #222;
    line-height: 1.6;
}

/* Layout global : sidebar gauche + contenu droit */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: #ffffff;
    border-right: 1px solid #e0e0e0;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 24px;
    color: #111;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 8px;
}

.sidebar-nav a {
    display: block;
    padding: 8px 10px;
    font-size: 14px;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: #f0f0f0;
}

.sidebar-footer {
    margin-top: auto;
    font-size: 12px;
    color: #777;
}

.main {
    flex: 1;
    padding: 24px 32px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.topbar-title {
    font-size: 20px;
    font-weight: 600;
    color: #111;
}

.topbar-user {
    font-size: 14px;
    color: #555;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Login */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: #ffffff;
    padding: 32px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 24px;
    color: #111;
    font-size: 20px;
}

.login-info {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
    font-size: 14px;
    color: #666;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #999;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    background: #f7f7f7;
    color: #222;
}

.btn-primary {
    background: #e0e0e0;
    border-color: #c0c0c0;
}

.btn-danger {
    background: #f5f5f5;
    border-color: #d0d0d0;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* Alerts */
.alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-error {
    background: #fdf1f1;
    color: #a33;
    border: 1px solid #f0d0d0;
}

.alert-info {
    background: #f3f3f3;
    color: #444;
    border: 1px solid #e0e0e0;
}

.alert-success {
    background: #f1f9f1;
    color: #2f6f33;
    border: 1px solid #cfe3cf;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #ffffff;
    padding: 16px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.stat-card h3 {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: #333;
}

.stat-value.positive {
    color: #1f7a3a;
}

.stat-value.negative {
    color: #b03a2e;
}

.stat-card small {
    display: block;
    margin-top: 5px;
    color: #999;
    font-size: 12px;
}

/* Sections */
.section {
    background: #ffffff;
    padding: 20px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    margin-bottom: 24px;
}

.section h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 24px;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #999;
    font-style: italic;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

table thead {
    background: #f8f9fa;
}

table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #e0e0e0;
}

table td {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
}

table tbody tr:hover {
    background: #f8f9fa;
}

/* Badges */
.badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

/* Admin */
.admin-form {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.admin-form h3 {
    margin-bottom: 20px;
    color: #333;
}

/* Buttons in tables */
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Modal */
#explanationModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

#explanationModal > div {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 600px;
    max-height: 80vh;
    overflow: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

#explanationContent {
    margin: 20px 0;
    line-height: 1.6;
}

/* Chart container */
#pnlChart {
    max-height: 300px;
}

/* Responsive */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .navbar .container {
        flex-direction: column;
        gap: 15px;
    }
    
    table {
        font-size: 14px;
    }
    
    table th,
    table td {
        padding: 8px;
    }
    
    #explanationModal > div {
        max-width: 90%;
        padding: 20px;
    }
}
