/* ============================================
   FORMS.CSS - VERSION FINALE COMPLÈTE
   ============================================ */

/* ============================================
   AUTH CONTAINER (Login / Register)
   ============================================ */
.auth-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: radial-gradient(circle at top left, #ffe0d6, var(--bg-primary) 60%);
    z-index: 1;
    padding: 20px 10px;
    overflow-y: auto;
}

/* Dark mode background */
[data-theme="dark"] .auth-container {
    background: radial-gradient(circle at top left, #1e293b, var(--bg-primary) 60%);
}

/* Background blobs */
.auth-container::before, .auth-container::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    animation: pulseBlob 10s infinite alternate;
}

.auth-container::before {
    top: -50px;
    left: -50px;
    width: 400px;
    height: 400px;
    background: rgba(255, 87, 34, 0.15);
}

.auth-container::after {
    bottom: -50px;
    right: -50px;
    width: 300px;
    height: 300px;
    background: rgba(255, 167, 38, 0.15);
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    appearance: none;
}

@keyframes pulseBlob {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.1);
    }
}

/* ============================================
   GLASS CARD
   ============================================ */
.glass-card {
    display: flex;
    width: 1000px;
    max-width: 95%;
    height: auto;
    min-height: 650px;
    max-height: 90vh;
    background: var(--card-bg);
    backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* ============================================
   FORMULAIRE (Côté gauche ou droit)
   ============================================ */
.auth-side-form {
    flex: 1;
    padding: 40px 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow-y: auto;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 20px;
    align-self: flex-start;
    transition: color 0.3s ease, transform 0.3s ease;
}

.btn-back:hover {
    color: var(--main-color);
    transform: translateX(-5px);
}

.auth-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-dark);
    margin: 0 0 10px 0;
    line-height: 1.2;
}

.auth-subtitle {
    color: var(--text-muted);
    margin-bottom: 30px;
    font-size: 0.95rem;
}

/* ============================================
   VISUEL (Iframe/Lottie)
   ============================================ */
.auth-side-visual {
    flex: 1;
    position: relative;
    background: linear-gradient(135deg, #fff5f2 0%, #ffffff 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 40px;
    overflow: hidden;
}

[data-theme="dark"] .auth-side-visual {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.visual-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    z-index: 1;
    pointer-events: none;
    object-fit: cover;
}

.auth-marketing-text {
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    padding: 20px 25px;
    border-radius: 20px;
    margin-top: auto;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .auth-marketing-text {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(71, 85, 105, 0.8);
}

.auth-marketing-text h2 {
    margin: 0 0 5px 0;
    color: var(--main-color);
    font-size: 1.4rem;
}

.auth-marketing-text p {
    margin: 0;
    color: var(--text-dark);
    font-size: 0.95rem;
}

/* ============================================
   INPUTS & LABELS (Floating effect)
   ============================================ */
.input-group-custom {
    position: relative;
    margin-bottom: 25px;
}

.form-input {
    width: 100%;
    padding: 15px 15px;
    font-size: 15px;
    color: var(--text-dark);
    background: transparent;
    border: 2px solid var(--input-border);
    border-radius: 12px;
    outline: none;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.form-label {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 15px;
    pointer-events: none;
    transition: all 0.25s ease-out;
    padding: 0 5px;
    background: transparent;
    z-index: 10;
}

.form-input:focus, .form-input:not(:placeholder-shown) {
    border-color: var(--main-color);
}

.form-input:focus ~ .form-label, .form-input:not(:placeholder-shown) ~ .form-label {
    top: 0;
    transform: translateY(-50%) scale(0.9);
    color: var(--main-color);
    font-weight: 600;
    background: var(--card-bg);
    height: auto;
    line-height: 1;
}

/* ============================================
   PASSWORD TOGGLE (Œil)
   ============================================ */
.password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 15px;
    top: 10%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-muted);
    background: var(--card-bg);
    border: none;
    font-size: 1.1rem;
    padding: 5px;
    transition: color 0.3s;
    z-index: 20;
}

.password-toggle:hover {
    color: var(--main-color);
}

/* ============================================
   BOUTON SUBMIT
   ============================================ */
.btn-modern {
    width: 100%;
    padding: 16px;
    margin-top: 10px;
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-size: 200% auto;
    background-image: linear-gradient(to right, #ff5722 0%, #ff8a50 51%, #ff5722 100%);
    transition: 0.5s;
    box-shadow: 0 10px 20px rgba(255, 87, 34, 0.2);
}

.btn-modern:hover {
    background-position: right center;
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(255, 87, 34, 0.35);
}

/* ============================================
   LINKS & FOOTER
   ============================================ */
.auth-links {
    margin-top: 25px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-links a {
    color: var(--main-color);
    font-weight: 600;
    text-decoration: none;
}

.auth-links a:hover {
    text-decoration: underline;
}

.alert-box {
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 20px;
    background: #ffebee;
    color: #d52121;
    border: 1px solid #ffcdd2;
    display: flex;
    align-items: center;
    gap: 10px;
}

[data-theme="dark"] .alert-box {
    background: rgba(220, 38, 38, 0.2);
    border: 1px solid rgba(220, 38, 38, 0.4);
}

/* ============================================
   IN-APP FORM PAGE (Create/Edit)
   ============================================ */
.form-page-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - var(--header-height));
    padding: 20px;
}

.form-card-in-app {
    width: 700px;
    max-width: 100%;
    background: var(--card-bg);
    border-radius: 0 0 30px 30px;
    padding: 50px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: visible;
}

.form-card-in-app::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 8px;
    background: linear-gradient(to right, var(--main-color), #ffcc80);
}

/* ============================================
   ANIMATED CONTAINER (Pencil icon)
   ============================================ */
.animated-container {
    position: relative;
    overflow: visible;
}

.form-header-center {
    text-align: center;
    margin-bottom: 2rem;
}

.writing-pencil-icon {
    position: absolute;
    top: -25px;
    right: -15px;
    font-size: 2.5rem;
    color: var(--main-color);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    animation: writeMotion 2s infinite ease-in-out;
}

@keyframes writeMotion {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(-3px, 3px) rotate(-10deg);
    }
    50% {
        transform: translate(0, 0) rotate(0deg);
    }
    75% {
        transform: translate(3px, 3px) rotate(-5deg);
    }
}

.icon-anim-euro {
    font-size: 3.3rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* ============================================
   CORNER FLOATING ICON (Envelope)
   ============================================ */
.corner-floating-icon {
    position: absolute;
    top: -30px;
    right: -30px;
    width: 75px;
    height: 75px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(10deg);
    animation: cornerFloat 4s ease-in-out infinite;
    z-index: 10;
}

.corner-floating-icon i {
    font-size: 2.5rem;
    color: var(--main-color);
    filter: drop-shadow(0 4px 6px rgba(255, 87, 34, 0.2));
}

@keyframes cornerFloat {
    0%, 100% {
        transform: translateY(0) rotate(10deg);
    }
    50% {
        transform: translateY(-10px) rotate(5deg);
    }
}

/* ============================================
   FORM ACTIONS (Buttons side by side)
   ============================================ */
.form-actions-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-top: 2.5rem;
}

.form-actions-group > * {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.btn-cancel-outline {
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 600;
    text-decoration: none;
    border: 2px solid var(--main-color);
    color: var(--main-color);
    background: transparent;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-cancel-outline:hover {
    background: var(--main-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 87, 34, 0.2);
}

.form-actions-group .btn-modern {
    width: 100%;
    margin-top: 0;
    border-radius: 12px;
}

/* ============================================
   ERROR BLOCK (Single styled error)
   ============================================ */
.custom-error-block {
    margin-top: 10px;
    background: rgba(254, 202, 202, 0.25);
    border: 1px solid #ef4444;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.1);
    animation: slideDown 0.3s ease-out;
}

[data-theme="dark"] .custom-error-block {
    background: transparent;
}

.custom-error-block ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.custom-error-block li {
    margin: 0;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   GLOW CARD (Orange shadow)
   ============================================ */
.glow-card {
    box-shadow: 0 25px 60px -5px rgba(255, 87, 34, 0.4);
    transition: all 0.4s ease;
    border: 1px solid rgba(255, 255, 255, 0.9);
    position: relative;
    z-index: 10;
}

.glow-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 35px 70px -5px rgba(255, 87, 34, 0.5);
}

/* ============================================
   AMBIENT GLOW (Purple background)
   ============================================ */
.page-ambient-glow {
    position: fixed;
    top: 15vh;
    left: -15vw;
    width: 80vh;
    height: 80vh;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.35) 0%, rgba(139, 92, 246, 0) 70%);
    border-radius: 50%;
    z-index: 0;
    pointer-events: none;
    filter: blur(80px);
}

[data-theme="dark"] .page-ambient-glow {
    background: radial-gradient(circle, rgba(139, 92, 246, 0.2) 0%, rgba(139, 92, 246, 0) 70%);
}

.form-page-container {
    position: relative;
    z-index: 1;
}

/* ============================================
   ROLE SELECTION (Radio cards)
   ============================================ */
.role-selection-group {
    margin-top: 25px;
    margin-bottom: 10px;
}

.section-title-sm {
    display: block;
    font-size: 0.85rem;
    color: var(--text-gray);
    margin-bottom: 10px;
    font-weight: 500;
}

.radio-cards-row {
    display: flex;
    gap: 15px;
    margin-top: 8px;
}

.radio-card-item {
    flex: 1;
    position: relative;
    cursor: pointer;
}

.radio-card-item input {
    position: absolute;
    opacity: 0;
}

.radio-content-box {
    display: block;
    padding: 12px;
    text-align: center;
    background: var(--card-bg);
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s;
}

.radio-card-item input:checked + .radio-content-box {
    background: #fff5f2;
    border-color: #ff5722;
    color: #c0392b;
}

[data-theme="dark"] .radio-card-item input:checked + .radio-content-box {
    background: rgba(255, 87, 34, 0.2);
    color: var(--main-color);
}

.check-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    color: #ff5722;
    background: var(--card-bg);
    border-radius: 50%;
    font-size: 1.2rem;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s cubic-bezier(0.5, 1.6, 0.4, 0.7);
}

.radio-card-item input:checked ~ .check-badge {
    opacity: 1;
    transform: scale(1);
}

/* ============================================
   CUSTOM SELECT
   ============================================ */
.hidden-native-select {
    display: none;
}

.custom-select-wrapper {
    position: relative;
    width: 100%;
    user-select: none;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 90%;
    padding: 12px 15px 12px 45px;
    font-size: 0.95rem;
    color: var(--text-dark);
    background: var(--card-bg);
    border: 1px solid #636365;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    height: 3rem;
}

.custom-select-wrapper.open .custom-select-trigger {
    border-color: var(--main-color);
    box-shadow: 0 0 0 3px rgba(255, 87, 34, 0.1);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.custom-select-trigger::after {
    content: '\f078';
    font-family: "Font Awesome 6 Free", serif;
    font-weight: 900;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform 0.3s;
    position: absolute;
    right: 1rem;
}

.custom-select-wrapper.open .custom-select-trigger::after {
    transform: rotate(180deg);
    color: var(--main-color);
}

.custom-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--main-color);
    border-top: none;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    z-index: 99;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 250px;
    overflow-y: auto;
}

.custom-select-wrapper.open .custom-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-option {
    padding: 12px 15px;
    cursor: pointer;
    transition: background 0.2s;
    color: rgba(45, 45, 45, 0.94);
    border: 1px solid var(--main-color);
    font-weight: 400;
}

[data-theme="dark"] .custom-option {
    color: white;
}

.custom-option:hover {
    background: #fff5f2;
    color: var(--main-color);
}

[data-theme="dark"] .custom-option:hover {
    background: rgba(255, 87, 34, 0.2);
}

.custom-option.selected {
    background: var(--main-color);
    color: white;
}

.custom-options::-webkit-scrollbar {
    width: 6px;
}

.custom-options::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-bottom-right-radius: 10px;
}

[data-theme="dark"] .custom-options::-webkit-scrollbar-track {
    background: rgba(71, 85, 105, 0.5);
}

.custom-options::-webkit-scrollbar-thumb {
    background: #ffccbc;
    border-radius: 10px;
}

.custom-options::-webkit-scrollbar-thumb:hover {
    background: var(--main-color);
}

/* ============================================
   LABEL MANAGEMENT (Floating with custom select)
   ============================================ */
.input-group-custom .form-label {
    position: absolute;
    left: 15px;
    top: 60%;
    transform: translateY(-50%);
    background-color: transparent;
    padding: 0 5px;
    color: var(--text-muted);
    font-size: 0.95rem;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 10;
}

.input-group-custom.filled .form-label,
.input-group-custom:focus-within .form-label,
.custom-select-wrapper.open + .form-label {
    top: 0;
    left: 12px;
    font-size: 0.8rem;
    color: var(--main-color);
    background-color: var(--card-bg);
    padding: 0 6px;
    z-index: 20;
    font-weight: 500;
}

.custom-select-trigger {
    background: transparent;
    z-index: 5;
}

/* ============================================
   SCROLLABLE VIEW (For forms with overflow)
   ============================================ */
.scrollable-view {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 80px 20px;
    min-height: 100vh;
    overflow-y: auto;
}

.form-card-wide {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 700px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.form-body-content {
    margin-bottom: 1.5rem;
}

/* ============================================
   HERO AMOUNT SECTION (Expense form)
   ============================================ */
.hero-amount-section {
    text-align: center;
    margin-bottom: 40px;
}

.amount-input-wrapper {
    display: flex;
    align-items: baseline;
    justify-content: center;
}

.input-hero-display {
    font-size: 4rem;
    font-weight: 800;
    color: var(--text-dark);
    border: none;
    background: transparent;
    width: 300px;
    text-align: center;
    outline: none;
    font-family: 'Poppins', sans-serif;
}

.amount-underline {
    height: 3px;
    width: 500px;
    background: linear-gradient(90deg, transparent, var(--main-color), transparent);
    margin: -5px auto 0;
    opacity: 0.4;
}

/* ============================================
   CATEGORY GRID (Icon tiles)
   ============================================ */
.category-section {
    margin-top: 2rem;
}

.modern-grid-layout {
    display: grid;
    grid-template-columns: repeat(7, .5fr);
    gap: 15px;
    margin: 15px 0 40px 0;
}

.category-tile-item {
    position: relative;
}

.hidden-check {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tile-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    border-radius: 16px;
    font-size: 1.3rem;
    color: rgba(67, 56, 213, 0.8);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: solid 1px rgba(71, 61, 199, 0.88);
}

[data-theme="dark"] .tile-label {
    color: var(--purple-mid);
    border: solid 1px var(--purple-mid);
}

.tile-label:hover {
    background: var(--main-color);
    color: white;
    transform: translateY(-3px);
    border: solid 1px var(--main-color);
}

.hidden-check:checked + .tile-label {
    background: var(--main-color);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 10px 20px rgba(255, 87, 34, 0.3);
    border: solid 1px var(--main-color);
}

/* ============================================
   RESPONSIVE - FORMS
   ============================================ */
@media (max-width: 900px) {
    .glass-card {
        flex-direction: column;
        width: 500px;
        height: auto;
        max-height: none;
        overflow-y: auto;
    }

    .auth-side-visual {
        flex: 0 0 200px;
        order: -1 !important;
        padding: 20px;
    }

    .auth-marketing-text {
        display: none;
    }

    .visual-frame {
        height: 120%;
        top: -10%;
    }
}

@media (max-width: 480px) {
    body {
        overflow: auto;
        height: auto;
    }

    .auth-container {
        display: block;
        padding: 20px 10px;
        height: auto;
        min-height: 100vh;
    }

    .glass-card {
        width: 100%;
        border-radius: 20px;
        max-height: none;
    }

    .auth-side-visual {
        height: 160px;
    }

    .auth-side-form {
        padding: 30px 20px;
    }

    .form-card-in-app {
        padding: 20px;
        width: 100%;
        margin: 10px;
    }

    .form-actions-group {
        flex-direction: column-reverse;
        gap: 15px;
    }

    .btn-cancel-outline,
    .form-actions-group .btn-modern {
        width: 100%;
        padding: 14px;
    }

    .writing-pencil-icon,
    .corner-floating-icon {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
        top: -20px;
        right: -10px;
    }

    .modern-grid-layout {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }

    .input-hero-display {
        font-size: 3rem;
        width: 250px;
    }

    .amount-underline {
        width: 100%;
        max-width: 350px;
    }
}

@media (max-width: 320px) {
    .auth-side-form {
        padding: 20px 15px;
    }

    .auth-title {
        font-size: 1.5rem;
    }

    .form-card-in-app {
        padding: 15px;
    }

    .modern-grid-layout {
        grid-template-columns: repeat(3, 1fr);
    }

    .input-hero-display {
        font-size: 2.5rem;
        width: 200px;
    }
}
