@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-page: #f8fafc;
    --surface: #ffffff;
    
    /* Couleurs de marque */
    --primary-dark: #0f172a;  /* Bleu nuit */
    --primary: #3b82f6;       /* Bleu vif */
    --shared-bg: #4f46e5;     /* Indigo pour les comptes partagés */
    
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    margin: 0;
    line-height: 1.5;
}

/* --- TOP BAR --- */
.top-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar h1 {
    font-size: 1.25rem;
    margin: 0;
    color: var(--primary-dark);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.btn-logout {
    text-decoration: none;
    color: #ef4444;
    padding: 0.4rem 0.8rem;
    border: 1px solid #fecaca;
    border-radius: 6px;
    transition: all 0.2s;
}
.btn-logout:hover { background: #fef2f2; }

/* --- LAYOUT PRINCIPAL --- */
main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

h2 {
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0; /* Margin géré par le conteneur parent */
}

/* Header de section avec boutons alignés */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* --- CARTES BANCAIRES --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    padding: 0;
    list-style: none;
}

.card {
    border-radius: 16px;
    padding: 1.5rem;
    color: white;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 200px;
    position: relative; /* Important pour le bouton de suppression */
    overflow: visible; /* Changé de hidden à visible pour la croix qui dépasse */
    transition: transform 0.2s;
}

.card:hover { transform: translateY(-4px); }

/* Style Comptes Personnels */
.account-card.personal {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

/* Style Comptes Partagés */
.account-card.shared {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
}

/* --- MODE SUPPRESSION (NOUVEAU) --- */
.delete-account-btn {
    display: none; /* Masqué par défaut */
    position: absolute;
    top: -12px;
    right: -10px;
    z-index: 50;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.delete-cross {
    background: #ef4444; /* Rouge vif */
    color: white;
    border: 3px solid var(--bg-page); /* Bordure couleur de fond pour découper */
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.delete-cross:hover {
    background: #dc2626;
    transform: scale(1.1) rotate(90deg); /* Petite rotation sympa */
}

@keyframes popIn {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* --- CONTENU CARTE --- */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
}

.acc-type {
    font-size: 0.85rem;
    text-transform: uppercase;
    opacity: 0.8;
    letter-spacing: 1px;
}

.acc-amount {
    font-size: 1.5rem;
    font-weight: 600;
}

.card-body {
    margin-top: auto;
}

.iban {
    font-family: monospace;
    opacity: 0.7;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Users tags inside card */
.shared-users {
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.user-tag {
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-icon {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    opacity: 0.7;
}
.btn-icon:hover { opacity: 1; color: #fca5a5; }

/* Formulaire partage dans la carte */
.share-form {
    display: flex;
    gap: 0.5rem;
    background: none;
    padding: 0;
    box-shadow: none;
    border: none;
}
.share-form input {
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    font-size: 0.8rem;
    padding: 6px 10px;
    border-radius: 6px;
    width: 100%;
}
.share-form input::placeholder { color: rgba(255,255,255,0.5); }

.btn-share {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 10px 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    backdrop-filter: blur(4px);
}

.btn-share:hover {
    background: #ffffff;
    color: var(--primary-dark);
    border-color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-share:active { transform: translateY(0); }

/* Bouton Quitter (Shared) */
.btn-danger-outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 10px 16px;
    width: 100%;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #fca5a5;
    color: #fca5a5;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.2);
}

.btn-danger-outline:active { background: rgba(239, 68, 68, 0.3); }

/* --- SECTION PANELS (Virement & Benef) --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.full-width { grid-column: 1 / -1; }

/* Formulaires Généraux */
form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.row { display: flex; gap: 1rem; }
.col { flex: 1; }

label { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.25rem; display: block;}

input:not([type="radio"]), select {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
}

.radio-group {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 0.5rem;
}
.radio-group label { font-weight: 400; display: flex; align-items: center; gap: 0.5rem;}

.btn-primary {
    background: var(--primary-dark);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
}
.btn-primary:hover { background: black; }

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-small {
    font-size: 0.8rem;
    padding: 0.6rem 1rem;
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}
.btn-small:hover { background: var(--primary); color: white; }


/* Liste bénéficiaires */
.benef-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 250px;
    overflow-y: auto;
}
.benef-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: #f8fafc;
    border-radius: 6px;
}
.benef-info { display: flex; flex-direction: column; }
.benef-info small { color: var(--text-muted); font-size: 0.75rem; }
.benef-list button.delete { color: #ef4444; opacity: 1; font-size: 1.2rem;}

/* Table Historique */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead { background: #f8fafc; }
th { text-align: left; padding: 0.75rem; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase;}
td { padding: 0.75rem; border-bottom: 1px solid var(--border); }
td.amount { font-weight: 600; color: var(--text-main); }

/* Messages Flash */
.alert { padding: 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem;}
.alert.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert.success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* Modal */
dialog {
    border: none;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}
dialog::backdrop { background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);}
.modal-actions { display: flex; gap: 1rem; margin-top: 1.5rem; }

/* Responsive */
@media (max-width: 768px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .top-bar { flex-direction: column; gap: 1rem; }
    .section-header { flex-direction: column; gap: 1rem; align-items: flex-start; }
    .header-actions { width: 100%; }
    .header-actions button { flex: 1; }
}