:root {
    --teal: #006b5f;
    --teal-dark: #004f46;
    --mint: #62fae3;
    --ink: #0e1b1a;
    --muted: #6b7c7a;
    --line: #e3e9e8;
    --bg: #eef1f0;
    --field: #f6f8f8;
    --white: #ffffff;
    --danger: #c0392b;
    --danger-bg: #fde8e8;
    --radius: 18px;
    --radius-lg: 28px;
    --radius-pill: 999px;
    --shadow-card: 0 12px 30px rgba(0, 60, 54, 0.06);
    --shadow-btn: 0 14px 28px rgba(0, 107, 95, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* =========================================
   2. LAYOUT COMMUN
   ========================================= */
body {
    min-height: 100vh;
    min-height: 100dvh; /* hauteur réelle visible sur mobile (hors barres navigateur) */
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(1100px 520px at 50% -10%, #d8f7f1 0%, transparent 55%), var(--bg);
    overflow: hidden;
}

/* Coquille d'écran (app + auth) : plein écran, sans arrondi ni marge */
.container,
.auth-shell {
    position: relative;
    width: 100%;
    max-width: 412px;
    height: 100vh;
    height: 100dvh; /* iOS : exclut la barre d'adresse Safari */
    background: var(--white);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.container {
    padding: 28px 22px 0;
}

.auth-shell {
    padding: 0;
}

/* En-tête des pages de l'app (pas l'auth) */
.container > header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

main {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    overflow: hidden;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
}

/* =========================================
   3. COMPOSANTS COMMUNS
   ========================================= */

/* ---- Champs de formulaire ---- */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.input-group label {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--ink);
}

.input-group input,
.input-group select {
    width: 100%;
    height: 54px;
    background: var(--field);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    padding: 0 18px;
    font-size: 0.96rem;
    color: var(--ink);
    outline: none;
    transition:
        border-color 0.18s,
        box-shadow 0.18s,
        background 0.18s;
}

.input-group input::placeholder,
.input-group textarea::placeholder {
    color: #9aa8a6;
}

.input-group textarea {
    width: 100%;
    min-height: 90px;
    background: var(--field);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 18px;
    font-size: 0.96rem;
    font-family: inherit;
    color: var(--ink);
    outline: none;
    resize: vertical;
    transition:
        border-color 0.18s,
        box-shadow 0.18s,
        background 0.18s;
}

.input-group textarea:focus {
    border-color: var(--teal);
    background: var(--white);
    box-shadow: 0 0 0 4px rgba(0, 107, 95, 0.12);
}

.input-group input:focus,
.input-group select:focus {
    border-color: var(--teal);
    background: var(--white);
    box-shadow: 0 0 0 4px rgba(0, 107, 95, 0.12);
}

.input-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon-wrapper svg {
    position: absolute;
    left: 18px;
    pointer-events: none;
}

.input-icon-wrapper input {
    padding-left: 46px;
}

/* ---- Boutons ---- */
.submit-btn,
.btn-primary {
    width: 100%;
    height: 56px;
    border: none;
    border-radius: var(--radius-pill);
    background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
    color: #fff;
    font-size: 0.96rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: var(--shadow-btn);
    transition:
        transform 0.12s,
        box-shadow 0.18s,
        filter 0.18s;
}

.submit-btn:hover,
.btn-primary:hover {
    filter: brightness(1.06);
    box-shadow: 0 18px 34px rgba(0, 107, 95, 0.4);
}

.submit-btn:active,
.btn-primary:active {
    transform: translateY(1px) scale(0.995);
}

.submit-btn svg,
.btn-primary svg {
    width: 20px;
    height: 20px;
}

/* ---- Navigation basse ---- */
nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    /* hauteur de la barre + zone sûre du bas (barre/encoche iOS) */
    height: calc(78px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--white);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-left: 16px;
    padding-right: 16px;
    box-shadow: 0 -6px 24px rgba(0, 60, 54, 0.07);
    z-index: 10;
}

.nav-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--muted);
}

.nav-item img {
    width: 20px;
    height: 20px;
    opacity: 0.4;
}

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

.nav-item.active img {
    opacity: 1;
}

/* ---- Modales (feuille du bas) ---- */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(8, 30, 27, 0.5);
    display: flex;
    align-items: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    z-index: 30;
}

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

.popup {
    background: var(--white);
    width: 100%;
    border-radius: 36px 36px 0 0;
    padding: 16px 24px 36px;
    transform: translateY(100%);
    max-height: 90%;
    overflow-y: auto;
    position: relative;
    transition: transform 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

.overlay.open .popup {
    transform: translateY(0);
}

.popup-handle {
    width: 44px;
    height: 5px;
    background: var(--line);
    border-radius: 3px;
    margin: 0 auto 18px;
}

.popup-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--ink);
    margin-bottom: 20px;
}

.close-btn {
    position: absolute;
    top: 22px;
    right: 22px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--field);
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: var(--ink);
}

/* =========================================
   4. PAGE AUTH (login / register)
   ========================================= */

/* ---- Hero / marque ---- */
.auth-hero {
    position: relative;
    padding: 54px 30px 60px;
    color: #fff;
    background: linear-gradient(150deg, var(--teal) 0%, var(--teal-dark) 100%);
    overflow: hidden;
    border-bottom-left-radius: 40px;
    border-bottom-right-radius: 40px;
}

.auth-hero::before,
.auth-hero::after {
    content: '';
    position: absolute;
    border-radius: 50%;
}

.auth-hero::before {
    width: 220px;
    height: 220px;
    top: -90px;
    right: -60px;
    background: rgba(98, 250, 227, 0.18);
}

.auth-hero::after {
    width: 150px;
    height: 150px;
    bottom: -55px;
    left: -45px;
    background: rgba(255, 255, 255, 0.08);
}

.brand-mark {
    position: relative;
    z-index: 1;
    width: 60px;
    height: 60px;
    border-radius: 18px;
    background: var(--mint);
    color: var(--teal-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
    margin-bottom: 22px;
}

.brand-mark svg {
    width: 30px;
    height: 30px;
}

.auth-hero h1 {
    position: relative;
    z-index: 1;
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.auth-hero p {
    position: relative;
    z-index: 1;
    margin-top: 10px;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.82);
    line-height: 1.45;
    max-width: 280px;
}

/* ---- Formulaire ---- */
.auth-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 28px 26px 26px;
    overflow-y: auto;
    scrollbar-width: none;
}

.auth-form::-webkit-scrollbar {
    display: none;
}

/* Empêche les champs/boutons de se compresser : on scrolle plutôt */
.auth-form > * {
    flex-shrink: 0;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field > label {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--ink);
}

.field-control {
    position: relative;
    display: flex;
    align-items: center;
}

.field-control .lead-icon {
    position: absolute;
    left: 16px;
    width: 20px;
    height: 20px;
    color: var(--muted);
    pointer-events: none;
    transition: color 0.18s;
}

.field-control input {
    width: 100%;
    height: 56px;
    border: 1.5px solid var(--line);
    background: var(--field);
    border-radius: var(--radius);
    padding: 0 16px 0 46px;
    font-size: 0.98rem;
    color: var(--ink);
    outline: none;
    transition:
        border-color 0.18s,
        box-shadow 0.18s,
        background 0.18s;
}

.field-control input::placeholder {
    color: #9aa8a6;
}

.field-control input:focus {
    border-color: var(--teal);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(0, 107, 95, 0.12);
}

.field-control input:focus ~ .lead-icon {
    color: var(--teal);
}

/* select dans le formulaire auth (ex : métier) */
.field-control select {
    width: 100%;
    height: 56px;
    border: 1.5px solid var(--line);
    background: var(--field);
    border-radius: var(--radius);
    padding: 0 16px 0 46px;
    font-size: 0.98rem;
    color: var(--ink);
    outline: none;
    cursor: pointer;
    transition:
        border-color 0.18s,
        box-shadow 0.18s,
        background 0.18s;
}

.field-control select:focus {
    border-color: var(--teal);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(0, 107, 95, 0.12);
}

/* bouton oeil (afficher / masquer) */
.toggle-pass {
    position: absolute;
    right: 10px;
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 12px;
}

.toggle-pass:hover {
    background: #eef3f2;
    color: var(--teal);
}

.toggle-pass svg {
    width: 20px;
    height: 20px;
}

.toggle-pass .eye-off {
    display: none;
}

.toggle-pass.is-visible .eye-on {
    display: none;
}

.toggle-pass.is-visible .eye-off {
    display: block;
}

.pass-hint {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 2px;
}

/* message d'erreur */
.auth-error {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--danger-bg);
    color: var(--danger);
    padding: 13px 16px;
    border-radius: 14px;
    font-size: 0.85rem;
    font-weight: 600;
}

.auth-error svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* bascule login <-> register */
.auth-switch {
    margin-top: auto;
    padding-top: 8px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--muted);
}

.auth-switch a {
    font-weight: 700;
    color: var(--teal);
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* =========================================
   5. PAGE ACCUEIL
   ========================================= */
.container-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 14px;
    width: 100%;
}

.container-header h1 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--ink);
}

.logout-link {
    margin-left: auto;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--teal);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    background: #e6f4f2;
}

.stats {
    display: flex;
    gap: 12px;
    width: 100%;
}

.stat {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 4px;
    border-radius: var(--radius-lg);
    padding: 38px 18px 18px;
    background: var(--white);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-card);
    flex: 1;
}

.stat h6 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--ink);
    line-height: 1;
}

.stat p {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.5px;
}

.stat img {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 24px;
    height: 24px;
    opacity: 0.25;
}

.photo {
    margin-top: 46px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(150deg, var(--mint) 0%, #2fe9cd 100%);
    width: 210px;
    height: 210px;
    gap: 14px;
    border-radius: 52px;
    color: var(--teal-dark);
    text-align: center;
    font-size: 1.3rem;
    font-weight: 800;
    box-shadow: 0 18px 38px rgba(47, 233, 205, 0.4);
    border: none;
    outline: none;
    cursor: pointer;
    transition:
        transform 0.14s,
        box-shadow 0.18s;
}

.photo:hover {
    transform: translateY(-2px);
    box-shadow: 0 24px 46px rgba(47, 233, 205, 0.5);
}

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

main > p {
    margin-top: 18px;
    margin-bottom: auto;
    font-size: 0.85rem;
    color: var(--muted);
    text-align: center;
    font-weight: 500;
    max-width: 240px;
    line-height: 1.4;
}

/* Formulaire "Nouveau chantier" (dans la modale) */
.modal-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.dropzone {
    border: 2px dashed #bfe7e0;
    background: #eefaf7;
    border-radius: var(--radius-lg);
    padding: 26px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-align: center;
    transition:
        border-color 0.18s,
        background 0.18s;
}

.dropzone:hover {
    border-color: var(--teal);
    background: #e6f6f3;
}

.icon-camera {
    width: 48px;
    height: 48px;
    background: var(--mint);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.dropzone h3 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--ink);
    margin-bottom: 4px;
}

.dropzone p {
    font-size: 0.8rem;
    color: var(--muted);
}

/* =========================================
   6. PAGE CHANTIERS
   ========================================= */
.container-header-project {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.brand-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.5px;
}

.project-main {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    flex: 1;
    overflow: hidden;
}

.title-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
}

.title-section h2 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.5px;
}

.filter-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #e6f4f2;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    outline: none;
}

.projects-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 18px;
    flex: 1;
    overflow-y: auto;
    padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    scrollbar-width: none;
}

.projects-list::-webkit-scrollbar {
    display: none;
}

.project-card {
    width: 100%;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    flex-shrink: 0;
}

.project-image-wrapper {
    width: 100%;
    height: 160px;
    overflow: hidden;
    background: var(--field);
}

.project-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.project-info {
    padding: 16px 20px 20px;
}

.project-info h3 {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--ink);
    margin-bottom: 12px;
}

.project-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.project-location {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.details-link {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--teal);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 700;
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.filter-option {
    width: 100%;
    height: 54px;
    background: var(--field);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    padding: 0 20px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    outline: none;
    transition:
        background 0.18s,
        color 0.18s,
        border-color 0.18s;
}

.filter-option.active {
    background: var(--teal);
    color: #fff;
    border-color: var(--teal);
}

/* =========================================
   7. PAGE CONTACT
   ========================================= */
.container-contact {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.container-contact .title-section {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.container-contact .title-section h2 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--ink);
}

.container-contact > .title-section p,
.container-contact .title-section p {
    font-size: 0.95rem;
    color: var(--muted);
    line-height: 1.4;
}

.search-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 22px;
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    pointer-events: none;
    opacity: 0.6;
}

.container-contact .input-group input {
    background: var(--white);
    padding-left: 46px;
}

.messages-title {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-bottom: 16px;
}

.messages-title img {
    width: 20px;
    height: 20px;
}

.messages-title h3 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--ink);
}

.messages-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    flex: 1;
    padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    scrollbar-width: none;
}

.messages-list::-webkit-scrollbar {
    display: none;
}

.message-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    box-shadow: var(--shadow-card);
    width: 100%;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    position: relative;
}

.user-avatar-text {
    width: 42px;
    height: 42px;
    background: #e6f4f2;
    color: var(--teal-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.message-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.message-meta h4 {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--ink);
}

.project-tag {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
}

.message-preview {
    font-size: 0.85rem;
    color: #8a9b99;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.message-preview strong {
    color: var(--muted);
    font-weight: 600;
}

/* =========================================
   8. RESPONSIVE (petits écrans)
   ========================================= */

/* Téléphones : on remplit tout l'écran (supprime les bandes gauche/droite) */
@media (max-width: 600px) {
    .container,
    .auth-shell {
        max-width: 100%;
    }

    /* respecte l'encoche en mode paysage (zones sûres latérales) */
    .container {
        padding-left: calc(22px + env(safe-area-inset-left, 0px));
        padding-right: calc(22px + env(safe-area-inset-right, 0px));
    }
}

@media (max-width: 360px) {
    .container {
        padding: 24px 16px 0;
    }

    .auth-hero {
        padding: 44px 22px 52px;
    }

    .auth-form {
        padding: 24px 18px 22px;
    }

    .input-group input,
    .input-group select,
    .filter-option {
        padding: 0 16px;
    }

    .field-control input {
        padding-left: 44px;
    }

    .input-icon-wrapper input,
    .container-contact .input-group input {
        padding-left: 44px;
    }
}

.btn-containers {
    display: flex;
    gap: 12px;
    width: 100%;
    margin-top: 8px;
}

.btn-publier,
.btn-supprimer {
    flex: 1;
    height: 52px;
    border: none;
    border-radius: var(--radius-pill);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition:
        transform 0.12s,
        box-shadow 0.18s,
        filter 0.18s,
        background 0.18s;
}

/* Action principale : publier */
.btn-publier {
    background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
    color: #fff;
    box-shadow: var(--shadow-btn);
}

.btn-publier:hover {
    filter: brightness(1.06);
    box-shadow: 0 18px 34px rgba(0, 107, 95, 0.4);
}

.btn-publier:active {
    transform: translateY(1px) scale(0.995);
}

/* Action destructrice : supprimer (rouge doux) */
.btn-supprimer {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1.5px solid #f3c9c9;
}

.btn-supprimer:hover {
    background: #f9d5d5;
}

.btn-supprimer:active {
    transform: translateY(1px) scale(0.995);
}
