/* ============ RESET & BASE ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    color: #2c3e50;
    font-size: 14px;
    line-height: 1.5;
}

/* ============ LAYOUT PRINCIPAL ============ */
.app {
    display: flex;
    min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.logo {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    margin-bottom: 20px;
}

.logo h2 {
    font-size: 22px;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo small {
    opacity: 0.75;
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.nav-menu {
    padding: 0;
    list-style: none;
}

.nav-item {
    display: block;
    padding: 13px 20px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    font-size: 14px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: rgba(255, 255, 255, 0.5);
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.15);
    border-left-color: #f39c12;
    color: white;
    font-weight: 600;
}

/* ============ CONTENU PRINCIPAL ============ */
.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 25px 30px;
    min-height: 100vh;
}

/* ============ TOPBAR ============ */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e6ed;
}

.topbar h1 {
    font-size: 24px;
    color: #1e3c72;
    font-weight: 700;
}

.period-filter {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    background: white;
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.period-filter label {
    font-weight: 600;
    color: #555;
    font-size: 13px;
}

.period-filter input[type="date"] {
    padding: 7px 10px;
    border: 1px solid #d0d7de;
    border-radius: 5px;
    font-size: 13px;
    outline: none;
    transition: border 0.2s;
}

.period-filter input[type="date"]:focus {
    border-color: #2a5298;
}

/* ============ CARDS ============ */
.card {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
    border: 1px solid #e8ecf1;
}

.card h2 {
    margin-bottom: 20px;
    color: #1e3c72;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f2f5;
}

/* ============ STATS GRID ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    padding: 22px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border-left: 5px solid #2a5298;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.stat-card.success {
    border-left-color: #27ae60;
}

.stat-card.danger {
    border-left-color: #e74c3c;
}

.stat-card.warning {
    border-left-color: #f39c12;
}

.stat-label {
    font-size: 11px;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 600;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    margin-top: 10px;
    color: #2c3e50;
}

/* ============ TABLES ============ */
.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e8ecf1;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th {
    background: #1e3c72;
    color: white;
    padding: 13px 12px;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 600;
    position: sticky;
    top: 0;
}

td {
    padding: 11px 12px;
    border-bottom: 1px solid #ecf0f1;
    font-size: 13px;
}

tr:hover td {
    background: #f8f9fa;
}

tr:nth-child(even) td {
    background: #fafbfc;
}

tr:nth-child(even):hover td {
    background: #f0f4f8;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.text-success {
    color: #27ae60 !important;
    font-weight: 600;
}

.text-danger {
    color: #e74c3c !important;
    font-weight: 600;
}

.text-total {
    font-weight: 700 !important;
    background: #ecf0f1 !important;
}

.text-total td {
    background: #ecf0f1 !important;
    font-weight: 700;
    border-top: 2px solid #1e3c72;
}

/* ============ BADGES ============ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-depense {
    background: #fadbd8;
    color: #c0392b;
}

.badge-recette {
    background: #d5f5e3;
    color: #1e8449;
}

.badge-terminé {
    background: #d5f5e3;
    color: #1e8449;
}

.badge-annulé {
    background: #fadbd8;
    color: #c0392b;
}

/* ============ BUTTONS ============ */
.btn {
    padding: 9px 18px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #2a5298;
    color: white;
}

.btn-primary:hover {
    background: #1e3c72;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(42, 82, 152, 0.3);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* ============ ACTION BUTTONS & FILTERS ============ */
.action-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e8ecf1;
}

.filter-bar .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 180px;
}

.filter-bar label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
    font-size: 12px;
    text-transform: uppercase;
}

/* ============ FORMS ============ */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #34495e;
    font-size: 13px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    font-size: 14px;
    transition: border 0.2s, box-shadow 0.2s;
    background: white;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #2a5298;
    box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.1);
}

.form-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 200px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #ecf0f1;
}

/* ============ MODAL ============ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(3px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #1e3c72;
    font-size: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f2f5;
}

/* ============ ALERTS ============ */
.alert {
    padding: 13px 18px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 14px;
}

.alert.success {
    background: #d5f5e3;
    color: #1e8449;
    border-left: 4px solid #27ae60;
}

.alert.error {
    background: #fadbd8;
    color: #c0392b;
    border-left: 4px solid #e74c3c;
}

.info {
    background: #ebf5fb;
    padding: 13px 18px;
    border-radius: 6px;
    color: #2874a6;
    margin-bottom: 15px;
    border-left: 4px solid #3498db;
}

/* ============ UTILITIES ============ */
.loading {
    text-align: center;
    padding: 50px 20px;
    color: #7f8c8d;
    font-size: 16px;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #e0e6ed;
    border-top-color: #2a5298;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.view-container {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: relative;
        height: auto;
    }

    .main-content {
        margin-left: 0;
    }

    .app {
        flex-direction: column;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ============ PRINT ============ */
@media print {

    .sidebar,
    .topbar,
    .filter-bar,
    .action-buttons,
    .btn,
    .period-filter {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }

    body {
        background: white;
    }
}