/* ================================================= */
/* VARIABLES CSS - THÈME CLAIR ET SOMBRE */
/* ================================================= */
:root[data-theme="light"] {
    /* Couleurs principales */
    --primary: #10b981;
    --primary-dark: #059669;
    --primary-light: #d1fae5;
    
    /* Couleurs de fond */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    
    /* Couleurs de texte */
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    
    /* Bordures */
    --border-color: #e5e7eb;
    --border-light: #f3f4f6;
    
    /* Ombres */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Couleurs de statut */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    /* Sidebar */
    --sidebar-bg: #1f2937;
    --sidebar-text: #d1d5db;
    --sidebar-hover: #374151;
    --sidebar-active: var(--primary);
}

:root[data-theme="dark"] {
    /* Couleurs principales */
    --primary: #10b981;
    --primary-dark: #059669;
    --primary-light: #064e3b;
    
    /* Couleurs de fond */
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    
    /* Couleurs de texte */
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-tertiary: #9ca3af;
    
    /* Bordures */
    --border-color: #374151;
    --border-light: #4b5563;
    
    /* Ombres */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
    
    /* Couleurs de statut */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    /* Sidebar */
    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-hover: #1e293b;
    --sidebar-active: var(--primary);
}

/* ================================================= */
/* RESET ET BASE */
/* ================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ================================================= */
/* SIDEBAR */
/* ================================================= */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
}

.logo i {
    font-size: 1.5rem;
    color: var(--primary);
}

.logo-clover {
    width: 32px;
    height: 32px;
    color: white;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-section-title {
    padding: 1.5rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.9375rem;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: white;
}

.nav-item.active {
    background: linear-gradient(90deg, var(--primary) 0%, transparent 100%);
    color: white;
    border-left: 3px solid var(--primary);
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1.125rem;
}

.sidebar-footer {
    padding: 1rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-nav-horizontal {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 1.5rem !important;
    padding: 0.5rem 1rem !important;
    width: 100% !important;
}

.footer-nav-horizontal .nav-item {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.5rem !important;
    margin: 0 !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 0.5rem !important;
    gap: 0 !important;
}

.footer-nav-horizontal .nav-item span {
    display: none !important;
}

.footer-nav-horizontal .nav-item i {
    margin: 0 !important;
    width: 20px !important;
    text-align: center !important;
    font-size: 1.125rem !important;
}

/* ================================================= */
/* MAIN CONTENT */
/* ================================================= */
.main-content {
    margin-left: 260px;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* ================================================= */
/* TOPBAR */
/* ================================================= */
.topbar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.period-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-secondary);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

.period-selector i {
    color: var(--text-secondary);
}

.period-select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
}

.theme-toggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    transform: scale(1.05);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ================================================= */
/* DASHBOARD CONTAINER */
/* ================================================= */
.dashboard-container {
    padding: 2rem;
    max-width: 1600px;
}

/* ================================================= */
/* KPI CARDS */
/* ================================================= */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--bg-primary);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    gap: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.kpi-card-clickable {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.kpi-card-clickable:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.kpi-icon {
    width: 60px;
    height: 60px;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.kpi-icon.budget {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.kpi-icon.expenses {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

.kpi-icon.success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.kpi-icon.warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

/* KPI Petit Écran - Style compact */
.kpi-card-small {
    padding: 1rem;
    min-height: auto;
}

.kpi-card-small .kpi-icon {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
}

.kpi-card-small .kpi-label {
    font-size: 0.875rem;
}

.kpi-card-small .kpi-value {
    font-size: 1.75rem;
}

.kpi-card-small .kpi-trend {
    font-size: 0.8125rem;
}

/* Animation pulse pour le KPI des factures non payées */
@keyframes pulse-red {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
}

.kpi-card-small:hover {
    animation: pulse-red 2s infinite;
}
.kpi-icon.info {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
}

.kpi-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
}

.kpi-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.kpi-value.negative {
    color: var(--danger);
}

.kpi-trend {
    font-size: 0.8125rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 500;
}

.kpi-trend.positive {
    color: var(--success);
}

.kpi-trend.negative {
    color: var(--danger);
}

.kpi-trend i {
    font-size: 0.75rem;
}

/* ================================================= */
/* WIDGETS GRID */
/* ================================================= */
.widgets-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5rem;
}

.widget {
    background: var(--bg-primary);
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.budget-widget {
    grid-column: span 6;
}

.widget:nth-child(2) {
    grid-column: span 6;
}

.widget:nth-child(3) {
    grid-column: span 6;
}

.widget:nth-child(4) {
    grid-column: span 6;
}

.quick-actions-widget {
    grid-column: span 12;
}

.widget-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.widget-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.widget-header h3 i {
    color: var(--primary);
}

.widget-action {
    font-size: 0.875rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.widget-action:hover {
    color: var(--primary-dark);
}

.widget-body {
    padding: 1.5rem;
}

/* ================================================= */
/* BUDGET CHART */
/* ================================================= */
.budget-chart {
    width: 100%;
    height: 300px;
    margin: 0 auto 1.5rem;
    position: relative;
}

.budget-chart canvas {
    max-height: 300px !important;
    height: 300px !important;
}

.budget-details {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.budget-detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
}

.detail-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.detail-value.expenses-color {
    color: #3b82f6;
}

.detail-value.success-color {
    color: var(--success);
}

.detail-value.negative {
    color: var(--danger) !important;
    color: #ef4444 !important;
}

/* ================================================= */
/* CHART LEGEND */
/* ================================================= */
.chart-container {
    margin-bottom: 1.5rem;
    min-height: 300px;
    position: relative;
}

.chart-container canvas {
    max-height: 300px;
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

.legend-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.legend-label {
    flex: 1;
    color: var(--text-primary);
    font-weight: 500;
}

.legend-value {
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
}

/* ================================================= */
/* ACTIVITY LIST */
/* ================================================= */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    transition: all 0.2s ease;
}

.activity-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
}

.activity-item-clickable {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.activity-item-clickable:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.activity-arrow {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

.activity-item-clickable:hover .activity-arrow {
    transform: translateX(4px);
    background: var(--primary);
    color: white;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.activity-meta {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.activity-amount {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
}

/* ================================================= */
/* ÉCHÉANCES */
/* ================================================= */
.echeances-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.echeance-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    border-left: 3px solid var(--info);
}

.echeance-item.warning {
    border-left-color: var(--warning);
}

.echeance-item.urgent {
    border-left-color: var(--danger);
}

.echeance-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background: var(--bg-primary);
    border-radius: 0.5rem;
    flex-shrink: 0;
}

.date-day {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.date-month {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.echeance-content {
    flex: 1;
}

.echeance-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.echeance-meta {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.echeance-badge {
    padding: 0.375rem 0.75rem;
    background: var(--bg-primary);
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    color: var(--success);
    margin-bottom: 1rem;
}

/* ================================================= */
/* QUICK ACTIONS */
/* ================================================= */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.quick-action:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.quick-action i {
    font-size: 2rem;
    color: var(--primary);
}

.quick-action span {
    font-weight: 600;
    font-size: 0.9375rem;
    text-align: center;
}

/* ================================================= */
/* MEMBER VIEW */
/* ================================================= */
.member-welcome {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-primary);
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
}

.member-welcome i {
    font-size: 4rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.member-welcome h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.member-welcome p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.member-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ================================================= */
/* RESPONSIVE */
/* ================================================= */
@media (max-width: 1200px) {
    .budget-widget,
    .widget:nth-child(2),
    .widget:nth-child(3),
    .widget:nth-child(4) {
        grid-column: span 12;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .topbar {
        padding: 1rem;
    }
    
    .page-title {
        font-size: 1.25rem;
    }
    
    .user-info {
        display: none;
    }
    
    .dashboard-container {
        padding: 1rem;
    }
    
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    
    .period-selector {
        display: none;
    }
}

/* ================================================= */
/* ANIMATIONS */
/* ================================================= */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kpi-card,
.widget {
    animation: fadeIn 0.5s ease-out;
}

.kpi-card:nth-child(1) { animation-delay: 0.1s; }
.kpi-card:nth-child(2) { animation-delay: 0.2s; }
.kpi-card:nth-child(3) { animation-delay: 0.3s; }
.kpi-card:nth-child(4) { animation-delay: 0.4s; }
