/* ============================================
   VARIABLES GLOBALES CENTRALISÉES
   ============================================ */
:root {
    /* Couleurs principales */
    --main-color: #ff5722;
    --main-dark: #e64a19;
    --main-hover: #f4511e;

    /* Couleurs de texte */
    --text-dark: #212020;
    --text-muted: #5d5f69;
    --text-light: #94a3b8;
    --text-gray: #64748b;

    /* Backgrounds */
    --bg-primary: #f0f2f5;
    --card-bg: rgba(255, 255, 255, 0.90);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-white: rgba(255, 255, 255, 0.7);

    /* Borders & Shadows */
    --glass-border: rgba(117, 109, 109, 0.6);
    --input-border: #565c60;
    --shadow-soft: 0 10px 30px -5px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 20px 40px -5px rgba(0, 0, 0, 0.12);
    --shadow-float: 0 15px 35px rgba(0, 0, 0, 0.1);

    /* Purple palette */
    --purple-deep: #382ead;
    --purple-mid: rgba(129, 140, 248, 0.73);

    /* Orange palette */
    --orange-accent: #ec6c15;
    --orange-vibrant: #ec6c15;
    --orange-dark: #ea580c;

    /* Utility colors */
    --danger: #ef4444;

    /* Layout */
    --header-height: 60px;
    --header-bg: rgba(255, 255, 255, 0.85);
    --radius-xl: 24px;

    /* Curves */
    --elastic: cubic-bezier(0.68, -0.55, 0.265, 1.55);

    /* Gradients */
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    --secondary-gradient: linear-gradient(135deg, rgba(241, 170, 99, 0.91) 0%, rgba(231, 122, 54, 0.93) 100%);
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

/* ============================================
   DARK MODE VARIABLES
   ============================================ */
[data-theme="dark"] {
    /* Couleurs inversées */
    --text-dark: #e2e8f0;
    --text-muted: #94a3b8;
    --text-light: #64748b;
    --text-gray: #cbd5e1;

    /* Backgrounds sombres */
    --bg-primary: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.95);
    --glass-bg: rgba(30, 41, 59, 0.8);
    --glass-white: rgba(30, 41, 59, 0.8);

    /* Borders adaptés */
    --glass-border: rgba(71, 85, 105, 0.6);
    --input-border: #475569;
    --shadow-soft: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 20px 40px -5px rgba(0, 0, 0, 0.6);

    /* Header sombre */
    --header-bg: rgba(30, 41, 59, 0.95);
}

/* ============================================
   BASE & RESET
   ============================================ */
* {
    box-sizing: border-box;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--bg-primary);
    font-family: 'Poppins', sans-serif;
    overflow-x: hidden;
    color: var(--text-dark);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ============================================
   HEADER GLOBAL
   ============================================ */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    background: var(--header-bg);
    backdrop-filter: blur(10px);
    z-index: 80;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
    transition: background-color 0.3s ease;
}

/* Logo */
.header-left .logo-wrapper {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo-svg {
    width: 45px;
    height: 45px;
    animation: spin-pause 5s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

.app-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-dark);
    margin-left: 5px;
    letter-spacing: -0.5px;
    transition: color 0.3s ease;
}

@keyframes spin-pause {
    0%, 20% {
        transform: rotate(0deg);
    }
    40%, 100% {
        transform: rotate(360deg);
    }
}

/* ============================================
   BOUTONS AUTH (Header)
   ============================================ */
.header-right {
    display: flex;
    gap: 30px;
}

.btn-auth {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 20px;
    border-radius: 18px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.3s ease;
}

.btn-content i {
    display: inline-block;
    transition: all 0.3s ease;
    width: 1rem;
}

.btn-auth::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translate(-50%, 100%);
    width: 150%;
    padding-top: 150%;
    border-radius: 50%;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

.btn-auth:hover::before {
    transform: translate(-50%, 10%) scale(1.5);
}

/* Bouton Login */
.btn-login {
    color: var(--main-color);
    border: 2px solid var(--main-color);
    background: transparent;
}

.btn-login::before {
    background: var(--main-color);
}

.btn-login:hover {
    color: white;
    border-color: var(--main-color);
    box-shadow: 0 8px 20px rgba(255, 87, 34, 0.5);
}

/* Bouton Signup */
.btn-signup {
    color: white;
    background: var(--main-color);
    border: 2px solid var(--main-color);
}

[data-theme="dark"] .btn-signup::before {
    background: rgba(45, 45, 45, 0.93);
}

.btn-signup::before {
    background: white;
}

.btn-signup:hover {
    color: var(--main-color);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* ============================================
   LAYOUT IN-APP
   ============================================ */
.main-content {
    padding: calc(var(--header-height) + 20px) 20px 60px 120px;
    max-width: 1600px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    transition: padding 0.3s ease;
    /* Animation corrigée - pas de transform initial */
    animation: fadeInUpFixed 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}

/* Animation sans "jump" */
@keyframes fadeInUpFixed {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.main-content::before {
    content: '';
    position: fixed;
    left: 60px;
    top: var(--header-height);
    bottom: 0;
    width: 1px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(255, 87, 34, 0.2), rgba(0, 0, 0, 0));
    z-index: -1;
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.page-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-dark);
    position: relative;
    display: inline-block;
    transition: color 0.3s ease;
}

.page-title::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 40%;
    height: 4px;
    background: var(--main-color);
    border-radius: 2px;
}

/* ============================================
   PROFIL UTILISATEUR
   ============================================ */
.user-profile {
    display: flex;
    align-items: center;
    gap: 50px;
    cursor: pointer;
    padding: 25px;
    border-radius: 50px;
    transition: background 0.3s ease;
}

.user-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
    line-height: 1;
    white-space: nowrap;
    transition: color 0.3s ease;
}

.user-name .initial {
    color: var(--main-color);
    font-size: 1.4em;
    vertical-align: -2px;
}

.user-name .initial:nth-child(2) {
    margin-left: 20px;
}

.avatar-wrapper {
    position: relative;
    width: 45px;
    height: 45px;
    background: var(--bg-primary);
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.user-profile:hover .avatar-wrapper {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 15px rgba(255, 87, 34, 0.2);
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #4caf50;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* ============================================
   FAB MENU (Floating Action Button)
   ============================================ */
.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
    z-index: 90;
    backdrop-filter: blur(2px);
}

.menu-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.fab-wrapper {
    position: fixed;
    top: 50%;
    left: 20px;
    z-index: 100;
}

.fab-main-btn {
    width: 70px;
    height: 70px;
    background: var(--main-color);
    border-radius: 50%;
    border: none;
    box-shadow: 0 8px 20px rgba(255, 87, 34, 0.4);
    cursor: pointer;
    position: relative;
    top: 25px;
    z-index: 102;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-50%);
    transition: transform 0.5s var(--elastic), background 0.3s;
}

.fab-main-btn i {
    font-size: 26px;
    color: white;
    transition: opacity 0.3s;
}

.fab-list {
    position: absolute;
    top: 50%;
    left: 0;
    padding: 0;
    margin: 0;
    list-style: none;
    width: 0;
    height: 0;
    z-index: 99;
}

.fab-list li {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotate(0deg) translateX(0) rotate(0deg);
    transition: transform 0.5s var(--elastic), opacity 0.3s;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.fab-wrapper.open .fab-list li {
    opacity: 1;
    pointer-events: auto;
    transform: rotate(calc(var(--i) * 35deg)) translateX(150px) rotate(calc(var(--i) * -35deg));
}

.fab-list li a {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-decoration: none;
    width: 50px;
    height: 50px;
    margin-top: -25px;
    margin-left: -25px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    color: var(--text-dark);
    overflow: hidden;
    transition: width 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), background 0.3s;
    transform: none;
}

.fab-list li a i {
    width: 50px;
    min-width: 50px;
    height: 50px;
    line-height: 50px;
    text-align: center;
    font-size: 18px;
    z-index: 2;
}

.fab-list li a .label {
    opacity: 0;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 600;
    padding-right: 20px;
    transform: translateX(-10px);
    transition: opacity 0.3s ease 0.1s, transform 0.3s ease 0.1s;
}

.fab-list li a:hover {
    width: 140px;
    background: var(--card-bg);
    z-index: 10;
}

.fab-list li a:hover .label {
    opacity: 1;
    transform: translateX(0);
}

.fab-list li a.active {
    background: var(--main-color);
    color: white;
    box-shadow: 0 0 0 4px rgba(255, 87, 34, 0.2);
    cursor: default;
}

/* ============================================
   MODAL LOGOUT
   ============================================ */
.logout-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.logout-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.logout-card {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 24px;
    width: 500px;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.logout-modal-overlay.active .logout-card {
    transform: scale(1);
}

.logout-icon-box {
    width: 60px;
    height: 60px;
    background: #fee2e2;
    color: var(--main-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 24px;
}

.logout-card h3 {
    margin: 0 0 10px;
    font-size: 1.4rem;
    color: var(--text-dark);
    font-weight: 700;
}

.logout-card p {
    margin: 0 0 25px;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.logout-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-cancel, .btn-confirm {
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    flex: 1;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-cancel {
    background: var(--card-bg);
    color: var(--text-dark);
    border: 2px solid var(--main-color);
}

.btn-cancel:hover {
    background: var(--glass-bg);
}

.btn-confirm {
    background: var(--main-color);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-confirm:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(239, 68, 68, 0.4);
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.badge-admin {
    background-color: #fff7ed;
    color: #c2410c;
    border: 1px solid #ffedd5;
}

.badge-member {
    background-color: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #dbeafe;
}

.card-header-w {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.wallet-name {
    margin-bottom: 0;
    line-height: 1.2;
}

/* ============================================
   FLASH MESSAGES
   ============================================ */
.flash-toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 90%;
    max-width: 550px;
    pointer-events: none;
}

.flash-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    background: var(--card-bg);
    padding: 12px 16px;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    animation: blopEnter 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    opacity: 0;
    transform-origin: top center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.flash-success {
    background: #e8f5e9;
    color: #1b5e20;
    border: 2px solid #4caf50;
}

[data-theme="dark"] .flash-success {
    background: var(--card-bg);
    color: #5bbe5f;
}

.flash-success .flash-icon svg {
    stroke: #2e7d32;
}

[data-theme="dark"] .flash-success .flash-icon svg {
    stroke: #5bbe5f;
}

.flash-danger {
    background: #ffebee;
    color: #c62828;
    border: 2px solid #ef5350;
}

[data-theme="dark"] .flash-danger {
    background: var(--card-bg);
    color: #ec3636;
}

.flash-danger .flash-icon svg {
    stroke: #c62828;
}

[data-theme="dark"] .flash-danger .flash-icon svg {
    stroke: #ec3636;
}

.flash-warning {
    background: #fff3e0;
    color: #e65100;
    border: 2px solid #ff9800;
}

[data-theme="dark"] .flash-warning {
    background: var(--card-bg);
    color: #f85a03;
}

.flash-warning .flash-icon svg {
    stroke: #ef6c00;
}

[data-theme="dark"] .flash-warning .flash-icon svg {
    stroke: #ef6c00;
}

.flash-info {
    background: #e3f2fd;
    color: #0d47a1;
    border: 2px solid #2196f3;
}

[data-theme="dark"] .flash-info {
    background: var(--card-bg);
    color: #3382ff;
}

.flash-info .flash-icon svg {
    stroke: #3682ff;
}

[data-theme="dark"] .flash-info .flash-icon svg {
    stroke: #0e58d0;
}

.flash-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.flash-content {
    flex-grow: 1;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.4;
}

.flash-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    margin-left: 8px;
    opacity: 0.5;
    transition: opacity 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
}

[data-theme="dark"] .flash-close {
    color: white;
}

.flash-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

@keyframes blopEnter {
    0% {
        opacity: 0;
        transform: translateY(-50px) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.flash-toast.hiding {
    animation: blopExit 0.4s cubic-bezier(0.55, -0.04, 0.91, 0.94) forwards;
}

@keyframes blopExit {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px) scale(0.5);
    }
}

/* ============================================
   RESPONSIVE MOBILE
   ============================================ */
@media (max-width: 1024px) {
    .main-content {
        padding-left: 20px;
        padding-right: 20px;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: 0 15px;
        height: 60px;
    }

    .logo-svg {
        width: 35px;
        height: 35px;
    }

    .app-title {
        font-size: 20px;
    }

    .header-right {
        gap: 10px;
    }

    .btn-auth {
        padding: 0;
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }

    .btn-content {
        font-size: 0;
        gap: 0;
    }

    .btn-content i {
        width: auto;
        opacity: 1;
        transform: none;
        font-size: 16px;
    }

    .btn-login {
        border-width: 1px;
    }

    .btn-login:hover {
        box-shadow: none;
        color: var(--main-color);
    }

    .btn-login:hover::before {
        display: none;
    }

    .btn-signup:hover {
        color: white;
    }

    .btn-signup:hover::before {
        display: none;
    }

    .user-name {
        display: none;
    }

    .user-profile {
        gap: 0;
        padding: 0;
    }

    .avatar-wrapper {
        width: 40px;
        height: 40px;
    }

    .fab-wrapper {
        left: 15px;
    }

    .fab-wrapper.open .fab-list li {
        transform: rotate(calc(var(--i) * 35deg)) translateX(110px) rotate(calc(var(--i) * -35deg));
    }

    .fab-main-btn {
        width: 60px;
        height: 60px;
        top: 20px;
    }

    .fab-list li a {
        width: 45px;
        height: 45px;
        margin-top: -22.5px;
        margin-left: -22.5px;
    }

    .fab-list li a i {
        width: 45px;
        min-width: 45px;
        height: 45px;
        line-height: 45px;
    }

    .fab-list li a:not(.active):hover {
        width: 130px;
    }
}

/* Responsive extrême (320px) */
@media (max-width: 320px) {
    .app-header {
        padding: 0 10px;
    }

    .app-title {
        font-size: 18px;
    }

    .btn-auth {
        width: 36px;
        height: 36px;
    }

    .main-content {
        padding-left: 10px;
        padding-right: 10px;
    }

    .fab-wrapper {
        left: 10px;
    }
}
