@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
    --bg-1: #f5f9ff;
    --bg-2: #eef3fb;
    --text-1: #1f2937;
    --text-2: #4b5563;
    --card: #ffffff;
    --line: #e5e7eb;
    --primary: #2563eb;
    --success: #16a34a;
    --danger: #dc2626;
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Poppins', Arial, sans-serif;
    color: var(--text-1);
    background: radial-gradient(circle at top right, #e7f0ff 0%, var(--bg-1) 45%, var(--bg-2) 100%);
}

.container {
    max-width: 1240px;
    margin: 28px auto 0;
    padding: 0 20px 40px;
}

.user-info {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 15px 20px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 20px;
}

.online-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #28a745;
    margin-right: 8px;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 12px;
    border-radius: 999px;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    margin-left: 8px;
}

.role-badge.role-Entreprise, .role-badge.role-entreprise { background: linear-gradient(135deg, #dc3545, #c82333); }
.role-badge.role-Dirigeant, .role-badge.role-dirigeant { background: linear-gradient(135deg, #fd7e14, #e55a00); }
.role-badge.role-Lieutenant, .role-badge.role-lieutenant { background: linear-gradient(135deg, #6f42c1, #5a2d91); }
.role-badge.role-Responsable, .role-badge.role-responsable { background: linear-gradient(135deg, #20c997, #198754); }
.role-badge.role-Vendeur, .role-badge.role-vendeur { background: linear-gradient(135deg, #0d6efd, #0b5ed7); }
.role-badge.role-Livreur, .role-badge.role-livreur { background: linear-gradient(135deg, #198754, #146c43); }
.role-badge.role-Guetteur, .role-badge.role-guetteur { background: linear-gradient(135deg, #ffc107, #ffca2c); color: #111827; }
.role-badge.role-Préparateur, .role-badge.role-préparateur, .role-badge.role-Preparateur, .role-badge.role-preparateur { background: linear-gradient(135deg, #6610f2, #520dc2); }
.role-badge.role-Ravitailleur, .role-badge.role-ravitailleur { background: linear-gradient(135deg, #d63384, #b02a5b); }
.role-badge.role-Standartdiste, .role-badge.role-standartdiste { background: linear-gradient(135deg, #495057, #343a40); }

.logout-link {
    color: var(--danger);
    text-decoration: none;
    margin-left: 10px;
    font-weight: 700;
    transition: color 0.2s ease;
}

.logout-link:hover {
    color: #b02a37;
}

h1 {
    margin-top: 0;
    margin-bottom: 24px;
    text-align: center;
    color: #444;
    font-size: 28px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.success-message,
.error-message {
    max-width: 760px;
    margin: 14px auto 20px;
    padding: 13px 16px;
    border-radius: 12px;
    font-weight: 600;
    text-align: center;
    border: 1px solid transparent;
}

.success-message {
    color: #166534;
    background: #ecfdf5;
    border-color: #bbf7d0;
}

.error-message {
    color: #991b1b;
    background: #fef2f2;
    border-color: #fecaca;
}

.btn-ajouter,
.btn-rembourser,
.btn-supprimer,
.confirm-btn {
    border: none;
    border-radius: 10px;
    padding: 8px 13px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.16s ease, filter 0.16s ease;
}

.btn-ajouter:hover,
.btn-rembourser:hover,
.btn-supprimer:hover,
.confirm-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

.btn-ajouter {
    background: linear-gradient(135deg, #16a34a, #10b981);
    margin-bottom: 20px;
    font-size: 14px;
    padding: 10px 16px;
}

.btn-rembourser {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.btn-supprimer,
.confirm-yes {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.confirm-no {
    background: linear-gradient(135deg, #6b7280, #4b5563);
}

.table-container {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
    overflow: hidden;
    margin-top: 12px;
}

.table-header {
    padding: 20px 22px 12px;
}

.table-header h2 {
    margin: 0;
    font-size: 20px;
}

.table-wrapper {
    overflow-x: auto;
    padding: 0 12px 14px;
}

.investments-table {
    width: 100%;
    min-width: 900px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.investments-table th,
.investments-table td {
    padding: 12px 10px;
    text-align: center;
    border-bottom: 1px solid #edf2f7;
}

.investments-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.45px;
    color: #374151;
    background: linear-gradient(180deg, #f9fbff, #f2f6fd);
}

.investments-table tbody tr {
    transition: background-color 0.18s ease;
}

.investments-table tbody tr:nth-child(even) {
    background: #fafcff;
}

.investments-table tbody tr:hover {
    background: #f4f8ff;
}

.rembourse-ok {
    color: #166534;
    font-weight: 700;
}

.restant {
    color: #b91c1c;
    font-weight: 700;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    overflow-y: auto;
    padding: 20px 0;
    background: rgba(2, 6, 23, 0.58);
    backdrop-filter: blur(4px);
}

.modal-content {
    width: min(92%, 460px);
    margin: 4% auto;
    background: #fff;
    border-radius: 16px;
    border: 1px solid #e6ebf2;
    box-shadow: 0 24px 50px rgba(2, 6, 23, 0.25);
    padding: 24px;
    position: relative;
}

.close {
    position: absolute;
    right: 14px;
    top: 10px;
    font-size: 30px;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
}

.close:hover {
    color: #ef4444;
}

.confirm-modal-content {
    max-width: 500px;
    text-align: center;
}

.confirm-modal-title {
    margin: 10px 0 8px;
    color: #1f2937;
    font-size: 22px;
}

.confirm-modal-text {
    margin: 0 0 20px;
    color: #4b5563;
    font-size: 14px;
}

.confirm-modal-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
}

select,
input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="number"]:focus,
select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    outline: none;
}

.native-select-hidden {
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 1px !important;
    height: 1px !important;
}

.enhanced-user-select {
    position: relative;
}

.enhanced-user-select-trigger {
    width: 100%;
    min-height: 42px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #fff;
    color: #1f2937;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.enhanced-user-select-trigger:hover {
    border-color: #93c5fd;
}

.enhanced-user-select-trigger:focus-visible,
.enhanced-user-select.is-open .enhanced-user-select-trigger {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    outline: none;
}

.enhanced-user-select-trigger.is-placeholder .enhanced-user-select-label {
    color: #6b7280;
}

.enhanced-user-select-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.enhanced-user-select-arrow {
    font-size: 12px;
    color: #64748b;
    transition: transform 0.15s ease;
}

.enhanced-user-select.is-open .enhanced-user-select-arrow {
    transform: rotate(180deg);
}

.enhanced-user-select-panel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 25;
    border: 1px solid #dbe5f3;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12);
    overflow: hidden;
}

.enhanced-user-select.is-open .enhanced-user-select-panel {
    display: block;
}

.enhanced-user-select-search {
    width: 100%;
    border: 0;
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 12px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
}

.enhanced-user-select-options {
    max-height: 220px;
    overflow-y: auto;
    padding: 6px;
}

.enhanced-user-select-option {
    width: 100%;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #1f2937;
    text-align: left;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
}

.enhanced-user-select-option:hover,
.enhanced-user-select-option:focus-visible {
    background: #eff6ff;
    outline: none;
}

.enhanced-user-select-option.is-selected {
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 600;
}

.enhanced-user-select-empty {
    padding: 10px;
    text-align: center;
    color: #64748b;
    font-size: 12px;
}

#max_remb {
    font-size: 12px !important;
    color: #64748b !important;
    margin-top: 6px !important;
}

@media (max-width: 980px) {
    .investments-table {
        min-width: 760px;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 0 10px 28px;
    }

    .user-info {
        font-size: 13px;
    }

    h1 {
        font-size: 22px;
        margin-bottom: 18px;
    }

    .table-header {
        padding: 16px 14px 10px;
    }

    .table-wrapper {
        padding: 0 8px 10px;
    }

    .modal-content {
        width: 96%;
        padding: 16px;
        margin: 2.5% auto;
    }
}