/* Application de Gestion de Comptabilité Personnelle */
/* Theme: Emerald Green (Primary) & Silver (Secondary) */

:root {
    --bg-primary: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --bg-input: #0f172a;
    
    /* Emerald Green Primary Palette */
    --primary-emerald: #10b981;
    --primary-emerald-hover: #059669;
    --primary-emerald-dark: #047857;
    --primary-emerald-glow: rgba(16, 185, 129, 0.25);
    
    /* Silver Secondary Palette */
    --silver-light: #f1f5f9;
    --silver-main: #cbd5e1;
    --silver-muted: #94a3b8;
    --silver-dark: #64748b;
    --silver-border: #334155;
    
    /* Status colors */
    --danger-red: #f43f5e;
    --danger-red-hover: #e11d48;
    --warning-amber: #f59e0b;

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--silver-light);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

/* Layout Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
    flex: 1;
}

/* Navigation Header */
header.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--silver-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.logo-link {
    text-decoration: none;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary-emerald);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s ease;
}

.logo-link:hover {
    color: var(--silver-light);
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--primary-emerald);
    color: #042f2e;
}

.btn-primary:hover {
    background-color: var(--primary-emerald-hover);
    color: #ffffff;
    box-shadow: 0 0 12px var(--primary-emerald-glow);
}

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--silver-main);
    border-color: var(--silver-border);
}

.btn-secondary:hover {
    background-color: var(--bg-card-hover);
    color: var(--silver-light);
    border-color: var(--silver-muted);
}

.btn-admin {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(51, 65, 85, 0.5) 100%);
    color: var(--primary-emerald);
    border: 1px solid var(--primary-emerald);
    box-shadow: 0 0 8px var(--primary-emerald-glow);
}

.btn-admin:hover {
    background-color: var(--primary-emerald);
    color: #042f2e;
    box-shadow: 0 0 16px var(--primary-emerald-glow);
}

.btn-danger {
    background-color: rgba(244, 63, 94, 0.15);
    color: var(--danger-red);
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-danger:hover {
    background-color: var(--danger-red);
    color: #ffffff;
}

.btn-sm {
    padding: 0.25rem 0.625rem;
    font-size: 0.8125rem;
}

.btn-full {
    width: 100%;
    margin-top: 1rem;
    padding: 0.75rem;
}

/* User Badge */
.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--silver-border);
    border-radius: 9999px;
    font-size: 0.8125rem;
    color: var(--silver-main);
}

.user-badge .role-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--primary-emerald);
}

.user-badge-emerald {
    border-color: var(--primary-emerald);
    color: var(--primary-emerald);
    font-weight: 700;
}

/* Cards & Grid */
.card {
    background: var(--bg-card);
    border: 1px solid var(--silver-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15);
}

.card-flush {
    padding: 0;
    overflow: hidden;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

/* Dashboard 4 Indicator Stats Grid (Fits on single line on desktop) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--silver-border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15);
}

.stat-card-featured {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(30, 41, 59, 1) 100%);
    border-color: rgba(16, 185, 129, 0.4);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--silver-muted);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    margin-top: 0.5rem;
}

.stat-value-emerald { color: var(--primary-emerald); }
.stat-value-green { color: #10b981; }
.stat-value-rose { color: #f43f5e; }
.stat-value-sky { color: #38bdf8; }

.stat-subtext {
    font-size: 0.75rem;
    color: var(--silver-muted);
    margin-top: 0.25rem;
}

/* Resource Card for Admin Dashboard */
.resource-card {
    background: var(--bg-card);
    border: 1px solid var(--silver-border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.resource-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-emerald);
    box-shadow: 0 8px 16px -2px rgba(16, 185, 129, 0.15);
}

.resource-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.resource-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--silver-light);
}

.resource-count {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary-emerald);
}

.resource-desc {
    color: var(--silver-muted);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
}

/* Page Headers */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--silver-light);
}

.page-subtitle {
    color: var(--silver-muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background-color: var(--bg-card);
    border: 1px solid var(--silver-border);
    border-radius: 0.5rem;
    overflow: hidden;
}

.data-table th {
    background-color: #1a2332;
    color: var(--silver-main);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--silver-border);
}

.data-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--silver-border);
    color: var(--silver-light);
    font-size: 0.9rem;
}

.data-table tr:hover {
    background-color: var(--bg-card-hover);
}

.clickable-row {
    cursor: pointer;
}

.table-row-link {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
}

/* Form Layout (Label/Help left column, Input right column) */
.form-row {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.5rem;
    align-items: start;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

.form-label-col {
    display: flex;
    flex-direction: column;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--silver-main);
}

.form-help {
    font-size: 0.75rem;
    color: var(--silver-muted);
    line-height: 1.35;
}

.required-asterisk {
    color: var(--danger-red);
    font-weight: bold;
    margin-left: 0.2rem;
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background-color: var(--bg-input);
    border: 1px solid var(--silver-border);
    border-radius: 0.375rem;
    color: var(--silver-light);
    font-size: 0.9375rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-emerald);
    box-shadow: 0 0 0 3px var(--primary-emerald-glow);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.form-check-input {
    width: 1.125rem;
    height: 1.125rem;
    accent-color: var(--primary-emerald);
    cursor: pointer;
}

.checkbox-label {
    margin-bottom: 0;
    cursor: pointer;
}

.select-multiple {
    height: 120px;
}

/* Custom Autocomplete Dropdown Menu (Design System Theme) */
.custom-autocomplete-container {
    position: relative;
    width: 100%;
}

.custom-autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background-color: var(--bg-card);
    border: 1px solid var(--primary-emerald);
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 0 15px var(--primary-emerald-glow);
    max-height: 220px;
    overflow-y: auto;
    z-index: 1000;
    margin: 0;
    padding: 0.25rem 0;
    list-style: none;
}

.custom-autocomplete-item {
    padding: 0.625rem 0.875rem;
    color: var(--silver-light);
    font-size: 0.9375rem;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.custom-autocomplete-item:hover,
.custom-autocomplete-item.active {
    background-color: var(--primary-emerald);
    color: #042f2e;
    font-weight: 600;
}

.custom-autocomplete-item-matched {
    color: var(--silver-muted);
    font-size: 0.8rem;
}

.custom-autocomplete-item:hover .custom-autocomplete-item-matched,
.custom-autocomplete-item.active .custom-autocomplete-item-matched {
    color: #042f2e;
}

/* Login Page Specific Layout */
.login-body {
    justify-content: center;
    align-items: center;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 1.5rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-title {
    font-size: 2rem;
    color: var(--primary-emerald);
}

.login-subtitle {
    color: var(--silver-muted);
    margin-top: 0.5rem;
}

/* Chart Component */
.chart-container {
    position: relative;
    width: 100%;
    height: 260px;
    background-color: #0b1120;
    border-radius: 0.5rem;
    padding: 1rem;
    border: 1px solid var(--silver-border);
}

.chart-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.chart-axis-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    padding: 0 0.5rem;
    font-size: 0.75rem;
    color: var(--silver-muted);
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--silver-border);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.legend-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-name {
    font-weight: 600;
    color: var(--silver-light);
}

.legend-balance {
    color: var(--silver-muted);
}

/* Flash Messages */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--primary-emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.alert-error {
    background: rgba(244, 63, 94, 0.15);
    color: var(--danger-red);
    border: 1px solid rgba(244, 63, 94, 0.3);
}

/* Generic Utility Classes */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-bold { font-weight: 700; }
.text-medium { font-weight: 600; }
.text-emerald { color: var(--primary-emerald); }
.text-danger { color: var(--danger-red); }
.text-muted { color: var(--silver-muted); }
.nowrap { white-space: nowrap; }
.flex-row { display: flex; flex-direction: row; }
.flex-gap-sm { display: flex; gap: 0.75rem; }
.flex-gap-md { display: flex; gap: 1rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: 0.5rem; }
.mb-md { margin-bottom: 1rem; }
.mb-lg { margin-bottom: 1.5rem; }
.mt-sm { margin-top: 0.75rem; }
.mt-md { margin-top: 1.5rem; }
.mt-lg { margin-top: 2rem; }
.p-sm { padding: 0.75rem; }
.p-md { padding: 1.5rem; }
.w-full { width: 100%; }
.account-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.5rem;
}
.role-badge-admin {
    color: var(--primary-emerald);
    font-weight: 700;
}
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--silver-muted);
}

.hidden-inactive {
    display: none !important;
}

.inactive-account-row {
    opacity: 0.75;
}

.toggle-inactive-row {
    cursor: pointer;
    background: var(--bg-card);
    transition: background-color 0.2s ease;
}

.toggle-inactive-row:hover {
    background: var(--bg-card-hover);
}

