/*
 * src/public/css/material.css
 * Design System — Réseau Social Syndical
 * Inspiré des maquettes Stitch (Material Design 3)
 * Font: Plus Jakarta Sans | Theme: Light, Luminous, Warm
 */

/* ====== GOOGLE FONTS ====== */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* ====== MATERIAL SYMBOLS (icons) ====== */
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,400,1,0&display=swap');

:root {
    /* ===== Couleurs Stitch ===== */
    --primary: #D33131;
    --primary-light: #FFEBEE;
    --primary-dark: #B71C1C;

    --blue: #197FE6;
    --blue-light: #E3F2FD;
    --blue-dark: #1565C0;

    --green: #388E3C;
    --green-light: #E8F5E9;
    --green-dark: #2E7D32;

    --purple: #7B1FA2;
    --purple-light: #F3E5F5;
    --purple-dark: #6A1B9A;

    --orange: #E65100;
    --orange-light: #FFF3E0;

    /* ===== Surfaces ===== */
    --bg: #F5F5F7;
    --surface: #FFFFFF;
    --surface-variant: #FAFAFA;

    /* ===== Textes ===== */
    --text-primary: #1A1A2E;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;

    /* ===== Layout ===== */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-full: 9999px;

    /* ===== Layout Heights (Modular) ===== */
    --app-bar-height: 56px;
    --bottom-nav-height: 64px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);

    /* ===== Shadows Premium ===== */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.12);

    /* ===== Typographie ===== */
    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* ===== Transitions ===== */
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

    /* ===== Borders ===== */
    --border-color: #E0E0E0;
    --border-light: #F0F0F0;
}

/* ====== RESET & BASE ====== */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ====== APP SHELL — Modular Layout ====== */
body.app-shell {
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    /* flex child shrink fix */
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    margin-top: 0;
    letter-spacing: -0.01em;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ====== MATERIAL ICON HELPER ====== */
.material-symbols-rounded {
    font-family: 'Material Symbols Rounded';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    vertical-align: middle;
}

/* ====== VIEW TRANSITIONS API (Cross-Document) ====== */
@view-transition {
    navigation: auto;
}

::view-transition-old(root) {
    animation: 0.2s cubic-bezier(0.4, 0, 0.2, 1) both fade-out;
}

::view-transition-new(root) {
    animation: 0.25s cubic-bezier(0.4, 0, 0.2, 1) both fade-in,
        0.25s cubic-bezier(0.4, 0, 0.2, 1) both slide-in-from-right;
}

@keyframes fade-out {
    to {
        opacity: 0;
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }
}

@keyframes slide-in-from-right {
    from {
        transform: translateX(10px);
    }
}

/* ====== APP BAR ====== */
.app-bar {
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-primary);
    padding: 0 1.25rem;
    height: var(--app-bar-height);
    min-height: var(--app-bar-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.app-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.admin-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--font);
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.admin-link .material-symbols-rounded {
    font-size: 18px;
}

.admin-link:hover {
    background: var(--primary);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.app-bar h1 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

/* ====== BOUTONS ====== */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    filter: brightness(1.05);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
    box-shadow: var(--shadow-sm);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid var(--border-color);
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-outline:hover {
    background: var(--surface-variant);
    color: var(--text-primary);
    border-color: #BDBDBD;
}

.btn-outline:active {
    transform: scale(0.98);
}

.btn-green {
    background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-green:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-green:active {
    transform: scale(0.98);
}

/* ====== CARTES ====== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.1rem;
    margin-bottom: 0.85rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card:active {
    transform: scale(0.98);
}

/* ====== FORMULAIRES ====== */
.form-group {
    margin-bottom: 1.2rem;
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 0.4rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.form-control {
    padding: 12px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: var(--font);
    transition: border-color var(--transition), box-shadow var(--transition);
    background: var(--surface-variant);
    color: var(--text-primary);
}

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

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

/* ====== LAYOUT MOBILE FIRST ====== */
.container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
    padding-bottom: 1rem;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .container {
        padding: 1.5rem 1rem;
    }

    .bottom-nav {
        max-width: 600px;
        margin: 0 auto;
        left: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
        border: 1px solid #E0E0E0;
        border-bottom: none;
    }
}

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

/* ====== MESSAGES D'ERREUR ====== */
.error-message {
    color: var(--primary);
    font-size: 0.875rem;
    margin-top: 5px;
    background: var(--primary-light);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
    font-weight: 500;
}

/* ====== LOADER ====== */
.loader {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ====== BOTTOM NAVIGATION ====== */
.bottom-nav {
    width: 100%;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
    min-height: var(--bottom-nav-height);
    padding-bottom: var(--safe-area-bottom);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.04);
    z-index: 2000;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    box-sizing: border-box;
    flex-shrink: 0;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 600;
    transition: color var(--transition);
    gap: 2px;
    padding: 4px 16px;
    border-radius: var(--radius-sm);
}

.nav-item .material-symbols-rounded {
    font-size: 26px;
    transition: color var(--transition);
}

.nav-item.active {
    color: var(--primary);
}

.nav-item:hover {
    color: var(--text-primary);
    text-decoration: none;
}

/* ====== CHIPS / BADGES ====== */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.chip-red {
    background: var(--primary-light);
    color: var(--primary);
}

.chip-blue {
    background: var(--blue-light);
    color: var(--blue-dark);
}

.chip-green {
    background: var(--green-light);
    color: var(--green-dark);
}

.chip-purple {
    background: var(--purple-light);
    color: var(--purple);
}

.chip-orange {
    background: var(--orange-light);
    color: var(--orange);
}

/* Legacy chip (backward compat) */
.chip:not([class*="chip-"]) {
    background: var(--primary-light);
    color: var(--primary);
}

/* ====== AVATARS ====== */
.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.05rem;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary-light) 0%, #FFD6D6 100%);
    color: var(--primary);
}

.avatar-blue {
    background: linear-gradient(135deg, var(--blue-light) 0%, #BBDEFB 100%);
    color: var(--blue);
}

.avatar-green {
    background: linear-gradient(135deg, var(--green-light) 0%, #C8E6C9 100%);
    color: var(--green);
}

.avatar-purple {
    background: linear-gradient(135deg, var(--purple-light) 0%, #E1BEE7 100%);
    color: var(--purple);
}

/* ====== POST CARDS ====== */
.post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.author-info {
    display: flex;
    flex-direction: column;
}

.post-meta {
    font-size: 0.78rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.post-content {
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 12px;
    white-space: pre-wrap;
    color: var(--text-primary);
}

.post-actions {
    display: flex;
    gap: 15px;
    border-top: 1px solid var(--border-light);
    padding-top: 10px;
    margin-top: 10px;
}

/* ====== SCOPE BADGES (inline dans les posts) ====== */
.scope-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

/* Bordure gauche colorée par scope sur les cartes */
.card[data-scope="NATIONAL"] {
    border-left: 3px solid var(--primary);
}

.card[data-scope="REGIONAL"] {
    border-left: 3px solid var(--blue);
}

.card[data-scope="SECTOR"] {
    border-left: 3px solid var(--purple);
}

.card[data-scope="GROUP"] {
    border-left: 3px solid var(--green);
}

.scope-national {
    background: var(--primary-light);
    color: var(--primary);
}

.scope-regional {
    background: var(--blue-light);
    color: var(--blue);
}

.scope-sector {
    background: var(--purple-light);
    color: var(--purple);
}

.scope-group {
    background: var(--green-light);
    color: var(--green);
}

/* ====== SECTION HEADERS ====== */
.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
    margin-top: 20px;
}

/* ====== SPACE CARDS (Groupes page) ====== */
.space-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 14px;
    transition: box-shadow var(--transition);
}

.space-card:hover {
    box-shadow: var(--shadow-md);
}

.space-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.space-icon-red {
    background: var(--primary-light);
    color: var(--primary);
}

.space-icon-blue {
    background: var(--blue-light);
    color: var(--blue);
}

.space-icon-purple {
    background: var(--purple-light);
    color: var(--purple);
}

.space-icon-green {
    background: var(--green-light);
    color: var(--green);
}

.space-info {
    flex: 1;
    min-width: 0;
}

.space-info h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.space-info p {
    margin: 2px 0 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.member-count {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ====== LOGIN HERO ====== */
.login-hero {
    background: linear-gradient(135deg, var(--primary) 0%, #E74C3C 50%, #FF6B6B 100%);
    color: white;
    padding: 3rem 1.5rem 2.5rem;
    text-align: center;
    border-radius: 0 0 28px 28px;
    margin-bottom: -20px;
}

.login-hero h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -0.02em;
}

.login-hero p {
    font-size: 0.9rem;
    opacity: 0.9;
    margin: 0;
    font-weight: 400;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin: 0 1rem 1rem;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 2;
}

.login-footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ====== PUBLISH BOX (Feed) ====== */
.publish-box textarea {
    width: 100%;
    border: none;
    resize: none;
    font-size: 0.95rem;
    outline: none;
    box-sizing: border-box;
    background: transparent;
    font-family: var(--font);
    color: var(--text-primary);
    line-height: 1.5;
}

.publish-box textarea::placeholder {
    color: var(--text-muted);
}

.publish-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    border-top: 1px solid var(--border-light);
    padding-top: 10px;
}

.scope-select {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    background: var(--surface-variant);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color var(--transition);
}

.scope-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ====== FILTER CHIPS ROW ====== */
.filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

/* ====== CHIP TABS (Filtre du flux — Material 3) ====== */
.chip-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px 0 14px;
    margin: 0 -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
}

.chip-tabs::-webkit-scrollbar {
    display: none;
}

.chip-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    border: 1.5px solid var(--border-color);
    background: var(--surface);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
    flex-shrink: 0;
}

.chip-tab .material-symbols-rounded {
    font-size: 18px;
}

.chip-tab:hover {
    border-color: var(--text-muted);
    background: var(--surface-variant);
}

.chip-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.chip-tab.active .material-symbols-rounded {
    color: white;
}

/* ====== PUBLISH LABEL ====== */
.publish-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.filter-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    border: 1.5px solid transparent;
}

.filter-chip:hover {
    transform: translateY(-1px);
}

.filter-chip-blue {
    background: var(--blue-light);
    color: var(--blue);
    border-color: var(--blue-light);
}

.filter-chip-purple {
    background: var(--purple-light);
    color: var(--purple);
    border-color: var(--purple-light);
}

/* ====== ANIMATIONS MICRO ====== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card,
.space-card {
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.animation-spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* ====== SKELETON LOADING ====== */
.skeleton {
    background: #eeeeee;
    background: linear-gradient(110deg, #ececec 8%, #f5f5f5 18%, #ececec 33%);
    border-radius: 8px;
    background-size: 200% 100%;
    animation: shine 1.5s linear infinite;
    border: none !important;
    color: transparent !important;
}

.skeleton * {
    visibility: hidden;
}

@keyframes shine {
    to {
        background-position-x: -200%;
    }
}

/* Helper for better touch targets */
.touch-target {
    min-height: 48px;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ====== TOAST / SNACKBAR ====== */
.toast {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom) + 16px);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #323232;
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: var(--font);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
    max-width: calc(100% - 32px);
    text-align: center;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.toast-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-success {
    background: var(--green-dark);
}

.toast-error {
    background: var(--primary);
}

.toast-info {
    background: var(--blue);
}

/* ====== CONFIRM MODAL ====== */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9998;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.confirm-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.confirm-sheet {
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    padding: 24px;
    width: 100%;
    max-width: 500px;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.confirm-overlay.visible .confirm-sheet {
    transform: translateY(0);
}

.confirm-sheet h3 {
    margin: 0 0 8px;
    font-size: 1.1rem;
}

.confirm-sheet p {
    margin: 0 0 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ====== PUBLISH BOX ENHANCED ====== */
.publish-box-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.publish-box-row .avatar {
    margin-top: 2px;
}

/* ====== PREMIUM PROFILE MODAL (Bottom Sheet / Modal Hybrid) ====== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal-sheet {
    background: var(--surface);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    border-radius: 28px 28px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1);
}

.modal-overlay.visible .modal-sheet {
    transform: translateY(0);
}

.modal-cover {
    height: 100px;
    background: linear-gradient(135deg, var(--primary-light) 0%, #FFD6D6 100%);
    position: relative;
    flex-shrink: 0;
}

.modal-close-fab {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    z-index: 10;
}

.modal-close-fab:hover {
    background: white;
    transform: scale(1.05);
    color: var(--text-primary);
}

.modal-avatar-wrapper {
    position: absolute;
    bottom: -36px;
    left: 24px;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: white;
    padding: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.modal-avatar-wrapper .avatar {
    width: 100%;
    height: 100%;
    font-size: 1.8rem;
}

.modal-body {
    padding: 48px 24px 24px 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-name {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 12px 0;
    letter-spacing: -0.02em;
}

.modal-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 20px 0 10px 0;
}

.modal-tinted-box {
    background: var(--surface-variant);
    border-left: 4px solid var(--primary);
    padding: 16px;
    border-radius: 0 12px 12px 0;
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-top: 8px;
}

.modal-footer {
    padding: 16px 24px;
    background: var(--surface);
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    display: flex;
    flex-shrink: 0;
}

.modal-footer .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 14px;
    font-size: 1rem;
    border-radius: 100px;
    /* Full rounded pill */
}

@media (min-width: 768px) {
    .modal-overlay {
        align-items: center;
        /* Center on desktop */
    }

    .modal-sheet {
        border-radius: 24px;
        transform: translateY(20px) scale(0.95);
    }

    /* ====== AVATAR SELECTION GRID ====== */
    .avatar-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 16px;
        padding: 10px 0;
    }

    .avatar-option {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--surface-variant);
        color: var(--text-secondary);
        font-size: 1.8rem;
        cursor: pointer;
        transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
        border: 2px solid transparent;
    }

    .avatar-option:hover {
        transform: scale(1.1);
        background: var(--primary-light);
        color: var(--primary);
    }

    .avatar-option.selected {
        border-color: var(--primary);
        background: var(--primary-light);
        color: var(--primary);
        transform: scale(1.05);
    }

    .avatar-option-initials {
        font-weight: 700;
        font-family: var(--font);
        font-size: 1.2rem;
    }

    .modal-overlay.visible .modal-sheet {
        transform: translateY(0) scale(1);
    }
}