@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&family=Space+Mono:wght@400;700&display=swap');

:root {
    --bg-app: #0f172a;
    --bg-glass: rgba(30, 41, 59, 0.7);
    --bg-glass-heavy: rgba(15, 23, 42, 0.85);
    --bg-glass-hover: rgba(51, 65, 85, 0.8);

    --primary: #c4b903;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --secondary: #64748b;

    --success: #10b981;
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --warning: #f59e0b;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --border-glass: 1px solid rgba(255, 255, 255, 0.08);
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.3);

    --header-height: 70px;
    --footer-height: 80px;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
    --container-width: 600px;
}

/* --- Reset & Base --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    /* Fond abstrait */
    background-image: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 20%),
    radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.15) 0%, transparent 20%);
    padding-top: var(--header-height);
    padding-bottom: var(--footer-height);
}

a {
    color: inherit;
    text-decoration: none;
    transition: 0.2s;
}

ul {
    list-style: none;
}

button, input, select, textarea {
    font-family: inherit;
}

/* --- Layout System --- */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

/* Utilities (remplacement du inline style) */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

.gap-4 {
    gap: 2rem;
}

.w-full {
    width: 100%;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 2rem;
}

.mt-6 {
    margin-top: 3rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-4 {
    margin-bottom: 2rem;
}

/* Typography Helpers */
.font-mono {
    font-family: 'Space Mono', monospace;
}

.text-sm {
    font-size: 0.875rem;
}

.text-lg {
    font-size: 1.25rem;
}

.text-xl {
    font-size: 2.5rem;
}

.font-bold {
    font-weight: 700;
}

.text-primary {
    color: var(--primary);
}

.text-muted {
    color: var(--text-muted);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

h1, h2, h3 {
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

h1 {
    font-size: 2rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-glass-heavy);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: var(--border-glass);
    z-index: 100;
    padding: 0 20px;
}

nav {
    max-width: var(--container-width);
    margin: 0 auto;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#header-title {
    margin-top: 20px;
    margin-bottom: 15px;
}

.logo h1 {
    margin: 0;
    font-size: 1.5rem;
}

.page-title {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 10px;
    display: none;
}

@media (min-width: 600px) {
    .page-title {
        display: inline-block;
    }

    .user-nav h3 {
        display: none;
    }
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--border-glass);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 50px;
    font-size: 0.8rem;
    cursor: pointer;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

#create-bank:hover {
    background: var(--primary);
    color: var(--bg-app);
}

footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-height);
    background: var(--bg-glass-heavy);
    backdrop-filter: blur(12px);
    border-top: var(--border-glass);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

footer > nav {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: var(--container-width);
}

.nav-link-back {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 10px 20px;
    border-radius: 50px;
    transition: all 0.2s;
}

.nav-link-back:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

/* --- Components: Cards --- */
.card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: var(--border-glass);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-glass);
    transition: transform 0.2s, background 0.2s;
}

.card-hoverable:hover {
    transform: translateY(-2px);
    background: var(--bg-glass-hover);
}

/* --- Components: Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: var(--radius-lg);
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: 1rem;
    width: 100%;
    text-align: center;
    transition: all 0.2s;
}

.btn-auto {
    width: auto;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: scale(1.02);
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--secondary);
    color: var(--text-muted);
}

.btn-ghost:hover {
    border-color: var(--text-main);
    color: var(--text-main);
}

/* Bouton spécifique pour la suppression */
.btn-danger-outline {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-danger-outline:hover {
    background: var(--danger);
    color: white;
}

/* Zone de danger souvent en bas de page */
.danger-zone {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: center;
}

/* --- Components: Forms --- */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

input[type="text"], input[type="number"], input[type="date"], input[type="email"], input[type="password"], select {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid #334155;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Checkbox wrapper personnalisé */
.participation-wrapper {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid transparent;
    padding: 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: 0.2s;
}

.participation-wrapper.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.participation-input {
    width: 100%;
    background: transparent;
    border: none;
    text-align: center;
    color: white;
}

/* --- Badges --- */
.badge {
    background: var(--secondary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: white;
}

.auth-wrapper {
    max-width: 400px;
    margin: auto;
    width: 100%;
}

.flash-container {
    position: fixed;
    top: 90px; /* Juste sous le header */
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 300px;
}

.flash {
    padding: 15px 20px;
    border-radius: var(--radius-sm);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-glass);
    animation: slideIn 0.3s ease-out;
    border: 1px solid rgba(255,255,255,0.1);
}

.flash-notice {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--success);
    color: #a7f3d0;
}

.flash-alert {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
    color: #fecaca;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* --- Specific: Balance Component --- */
.balance-hero {
    text-align: center;
    border: 1px solid transparent;
    transition: all 0.3s;
}
.balance-hero.positive { border-color: var(--success); }
.balance-hero.negative { border-color: var(--danger); }

.balance-amount {
    font-size: 2.5rem;
    margin: 10px 0;
}

.balance-scroll-container {
    overflow-x: auto;
    padding-bottom: 10px;
    margin-top: 20px;
    /* Masquer la scrollbar tout en gardant le scroll */
    scrollbar-width: thin;
    scrollbar-color: var(--secondary) transparent;
}

.balance-mini-card {
    min-width: 120px;
    padding: 12px;
    margin: 0;
    flex-shrink: 0; /* Empêche l'écrasement */
}

.participation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.participation-wrapper {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid transparent;
    padding: 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

/* État actif géré par le JS */
.participation-wrapper.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.sticky-bottom-action {
    margin-top: 30px;
    position: sticky;
    bottom: 20px;
    z-index: 50;
    padding-bottom: 10px; /* Petit padding pour décoller du bord */
}

/* --- Specific: Algorithm --- */
.algo-step-list {
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 8px;
    margin: 10px 0;
}