/*
 * Alpine Pro — interface de l'espace propriétaires.
 * Esprit Filament / shadcn / espace hôte Airbnb : coque d'application (barre latérale + barre du haut),
 * neutres zinc, une couleur d'action (vert Alpine), cartes à bordure fine, rayons doux, focus visibles.
 * Chargé après Bootstrap 4 : les pages gardent leur balisage.
 */
:root {
    --primary: #4B5C44;
    --primary-hover: #3E4C38;
    --primary-soft: #EEF2EC;
    --primary-ring: rgba(75, 92, 68, .35);
    --bg: #FAFAFA;
    --surface: #FFFFFF;
    --muted-bg: #F4F4F5;
    --border: #E4E4E7;
    --border-strong: #D4D4D8;
    --text: #18181B;
    --text-2: #3F3F46;
    --muted: #71717A;
    --danger: #DC2626;
    --warning: #D97706;
    --success: #16A34A;
    --info: #2563EB;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
    --sidebar-w: 264px;
    --sidebar-w-collapsed: 68px;
    --topbar-h: 64px;
    --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ================= Base ================= */
html, body { overflow-x: clip; }
body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "cv11", "ss01", "ss03";
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { font-family: var(--font); font-weight: 600; color: var(--text); letter-spacing: -.015em; }
h1, .h1 { font-size: 1.75rem; }
h2, .h2 { font-size: 1.4rem; }
h3, .h3 { font-size: 1.2rem; }
h4, .h4 { font-size: 1.05rem; }
h5, .h5, h6, .h6 { font-size: .95rem; }
small, .small { font-size: 13px; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
.text-alpine { color: var(--primary) !important; }
.text-muted { color: var(--muted) !important; }
hr { border-color: var(--border); }
::selection { background: var(--primary-soft); color: var(--text); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* ================= Coque d'application ================= */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.app-content { flex: 1 1 auto; padding: 1.5rem 0 3rem; }

.app-sidebar {
    position: sticky; top: 0; height: 100vh; flex: 0 0 var(--sidebar-w); width: var(--sidebar-w);
    display: flex; flex-direction: column;
    background: var(--surface); border-right: 1px solid var(--border);
    z-index: 1040;
}
.app-sidebar__brand { display: flex; align-items: center; justify-content: space-between; height: var(--topbar-h); padding: 0 1rem 0 1.25rem; border-bottom: 1px solid var(--border); }
.app-sidebar__logo { display: flex; align-items: center; gap: .75rem; color: var(--text); text-decoration: none !important; }
.app-sidebar__logo img { width: 32px; height: 32px; object-fit: contain; }
.app-sidebar__logo span { display: flex; flex-direction: column; line-height: 1.2; }
.app-sidebar__logo strong { font-size: 15px; font-weight: 600; }
.app-sidebar__logo small { font-size: 12px; color: var(--muted); }

.app-nav { flex: 1 1 auto; overflow-y: auto; padding: 1rem .75rem; }
.app-nav__group + .app-nav__group { margin-top: 1.25rem; }
.app-nav__label { margin: 0 0 .35rem; padding: 0 .75rem; font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.app-nav__item {
    display: flex; align-items: center; gap: .75rem;
    padding: .55rem .75rem; margin-bottom: 2px;
    border-radius: var(--radius); color: var(--text-2); font-size: 14px; font-weight: 500;
    text-decoration: none !important; transition: background-color .15s, color .15s;
}
.app-nav__item i { font-size: 17px; color: var(--muted); width: 18px; text-align: center; transition: color .15s; }
.app-nav__item:hover { background: var(--muted-bg); color: var(--text); }
.app-nav__item.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.app-nav__item.is-active i { color: var(--primary); }

.app-sidebar__user { display: flex; align-items: center; gap: .75rem; padding: .9rem 1rem; border-top: 1px solid var(--border); }
.app-sidebar__who { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; line-height: 1.25; }
.app-sidebar__who strong { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-sidebar__who small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-avatar {
    flex: none; display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 13px; font-weight: 600;
}
.app-icon-btn {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 36px; height: 36px; border: 0; border-radius: var(--radius); background: transparent; color: var(--muted);
    font-size: 18px; text-decoration: none !important; transition: background-color .15s, color .15s;
}
.app-icon-btn:hover { background: var(--muted-bg); color: var(--text); }

.app-topbar {
    position: sticky; top: 0; z-index: 1030; height: var(--topbar-h);
    display: flex; align-items: center; gap: .75rem; padding: 0 1.5rem;
    background: rgba(255, 255, 255, .85); backdrop-filter: saturate(180%) blur(10px); -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
}
/* bandeau affiché quand un admin navigue sous le compte d'un propriétaire */
.app-impersonate {
    display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; padding: .5rem 1.5rem;
    background: #FFFBEB; color: #92400E; border-bottom: 1px solid #FDE68A; font-size: 14px;
}
.app-impersonate .btn { margin-left: auto; background: #92400E; color: #fff; border: 0; }
.app-impersonate .btn:hover { background: #78350F; color: #fff; }
.app-topbar__title { margin: 0; font-size: 1.15rem; font-weight: 600; letter-spacing: -.01em; }
.app-topbar__actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
/* cloche de notifications (partiel existant) */
.app-notifications .nav-link { padding: 0 !important; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); }
.app-notifications .nav-link:hover { background: var(--muted-bg); }
.app-notifications .nav-link i { font-size: 19px !important; }
.app-notifications .nav-link::after { display: none; }
.app-notifications .dropdown-menu { right: 0; left: auto; margin-top: .5rem; }

/* barre latérale repliée (grand écran) : icônes seules, état posé sur <html> par le layout */
@media (min-width: 992px) {
    .app-sidebar { transition: width .2s ease, flex-basis .2s ease; overflow: hidden; }
    /* pas de retour à la ligne pendant que la largeur s'anime */
    .app-sidebar__logo span, .app-nav__item span, .app-nav__label { white-space: nowrap; }
    html.sidebar-expanding .app-sidebar__logo span,
    html.sidebar-expanding .app-nav__item span,
    html.sidebar-expanding .app-nav__label,
    html.sidebar-expanding .app-sidebar__who { animation: app-sidebar-fade .2s ease .15s both; }
    html.sidebar-collapsed .app-sidebar { flex-basis: var(--sidebar-w-collapsed); width: var(--sidebar-w-collapsed); }
    html.sidebar-collapsed .app-sidebar__brand { justify-content: center; padding: 0; }
    html.sidebar-collapsed .app-sidebar__logo span,
    html.sidebar-collapsed .app-nav__item span,
    html.sidebar-collapsed .app-sidebar__who { display: none; }
    html.sidebar-collapsed .app-nav { padding: 1rem .5rem; overflow-x: hidden; }
    html.sidebar-collapsed .app-nav__label { height: 1px; margin: 0 .5rem .75rem; padding: 0; overflow: hidden; font-size: 0; background: var(--border); }
    html.sidebar-collapsed .app-nav__item { justify-content: center; padding: .6rem 0; }
    html.sidebar-collapsed .app-sidebar__user { flex-direction: column; padding: .75rem 0; gap: .5rem; }
}
@keyframes app-sidebar-fade { from { opacity: 0; } to { opacity: 1; } }
.app-backdrop { display: none; }
@media (max-width: 991.98px) {
    .app-sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
    body.sidebar-open .app-sidebar { transform: none; }
    body.sidebar-open .app-backdrop { display: block; position: fixed; inset: 0; background: rgba(9, 9, 11, .4); z-index: 1035; }
    .app-topbar { padding: 0 1rem; }
    .app-content { padding-top: 1rem; }
}

/* Les pages d'origine ont souvent de grandes marges en ligne : on les ramène dans la coque */
.app-content > .container-fluid[style*="padding"],
.app-content > div > .container-fluid[style*="padding"] { padding: 0 1.5rem !important; }
.app-content > .container[style*="padding"] { padding-top: 2rem !important; }

/* ================= Surfaces ================= */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
}
.card-header { background: transparent; border-color: var(--border); font-weight: 600; padding: 1rem 1.25rem; }
.card-header:first-child { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.card-body { padding: 1.25rem; }
.card-footer { background: var(--bg); border-color: var(--border); }
.card-footer:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.shadow, .shadow-sm { box-shadow: var(--shadow) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }
.rounded { border-radius: var(--radius) !important; }
.bg-light { background-color: var(--muted-bg) !important; }
.border, .border-top, .border-bottom, .border-left, .border-right { border-color: var(--border) !important; }

/* ================= Boutons ================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: 40px; padding: .5rem 1rem;
    border-radius: var(--radius); font-size: 14px; font-weight: 500; letter-spacing: 0; text-transform: none;
    box-shadow: var(--shadow-sm);
    transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn-sm { min-height: 32px; padding: .3rem .7rem; font-size: 13px; }
.btn-lg { min-height: 48px; padding: .7rem 1.4rem; font-size: 15px; }
.btn:focus, .btn.focus { box-shadow: 0 0 0 3px var(--primary-ring) !important; }
.btn-primary, .btn-default:not([style*="background"]), .btn-success {
    background: var(--primary); border-color: var(--primary); color: #fff !important;
}
.btn-primary:hover, .btn-default:not([style*="background"]):hover, .btn-success:hover,
.btn-primary:not(:disabled):active { background: var(--primary-hover) !important; border-color: var(--primary-hover) !important; }
.btn-default[style*="background:#fff"] { color: var(--text) !important; border-color: var(--border); }
.btn-secondary, .btn-light, .btn-outline-primary, .btn-outline-secondary, .btn-outline-dark {
    background: var(--surface); border-color: var(--border); color: var(--text) !important;
}
.btn-secondary:hover, .btn-light:hover, .btn-outline-primary:hover, .btn-outline-secondary:hover, .btn-outline-dark:hover {
    background: var(--muted-bg); border-color: var(--border-strong);
}
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-link { box-shadow: none; color: var(--primary); }

/* ================= Formulaires ================= */
label { font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: .4rem; }
.form-control, .custom-select {
    height: 40px;
    font-size: 14px;
    border-radius: var(--radius);
    border-color: var(--border-strong);
    color: var(--text);
    background-color: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: border-color .15s, box-shadow .15s;
}
textarea.form-control { height: auto; }
.form-control-sm, .custom-select-sm { height: 34px; font-size: 13px; }
.form-control::placeholder { color: #A1A1AA; }
.form-control:focus, .custom-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.custom-control-input:checked ~ .custom-control-label::before { background-color: var(--primary); border-color: var(--primary); }
.input-group-text { background: var(--muted-bg); border-color: var(--border-strong); border-radius: var(--radius); }

/* ================= Tableaux ================= */
.table { color: var(--text); font-size: 14px; background: var(--surface); }
.table thead th {
    border-top: 0; border-bottom: 1px solid var(--border);
    font-size: 12px; font-weight: 600; color: var(--muted);
    background: var(--bg);
}
.table td, .table th { border-color: var(--border); vertical-align: middle; padding: .7rem .9rem; }
.table-sm td, .table-sm th { padding: .4rem .6rem; }
.table-hover tbody tr:hover { background-color: #F7F7F8; }
.table-striped tbody tr:nth-of-type(odd) { background-color: #FBFBFB; }

/* ================= Badges, alertes, modales ================= */
.badge { font-size: 12px; font-weight: 500; border-radius: 6px; padding: .25em .6em; }
.badge-pill { border-radius: 999px; }
.badge-info { background: #EFF6FF; color: #1D4ED8; box-shadow: inset 0 0 0 1px #BFDBFE; }
.badge-warning { background: #FFFBEB; color: #B45309; box-shadow: inset 0 0 0 1px #FDE68A; }
.badge-danger { background: #FEF2F2; color: #B91C1C; box-shadow: inset 0 0 0 1px #FECACA; }
.badge-success { background: #F0FDF4; color: #15803D; box-shadow: inset 0 0 0 1px #BBF7D0; }
.badge-light, .badge-secondary { background: var(--muted-bg); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--border); }
.badge-dark, .badge-primary { background: var(--primary); color: #fff; }
.alert { border-radius: var(--radius-lg); border: 1px solid var(--border); font-size: 14px; }
.alert-info { background: #EFF6FF; border-color: #BFDBFE; color: #1E3A8A; }
.alert-warning { background: #FFFBEB; border-color: #FDE68A; color: #78350F; }
.alert-danger { background: #FEF2F2; border-color: #FECACA; color: #7F1D1D; }
.alert-success { background: #F0FDF4; border-color: #BBF7D0; color: #14532D; }
.modal-content { border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-header { border-color: var(--border); padding: 1.1rem 1.5rem; }
.modal-header .modal-title { font-size: 1.1rem; font-weight: 600; }
.modal-body { padding: 1.5rem; }
.modal-footer { border-color: var(--border); padding: .9rem 1.5rem; background: var(--bg); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.modal-backdrop.show { opacity: .4; }
.dropdown-menu { border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); font-size: 14px; padding: .35rem; }
.dropdown-item { border-radius: 6px; padding: .5rem .75rem; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--muted-bg); color: var(--text); }
.dropdown-item.active, .dropdown-item:active { background: var(--primary-soft); color: var(--primary); }

/* Onglets : soulignés, comme Filament / Airbnb */
.nav-tabs { border-bottom: 1px solid var(--border); gap: 1.25rem; }
.nav-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: .65rem 0; margin-bottom: -1px; color: var(--muted); font-weight: 500; background: transparent !important; }
.nav-tabs .nav-link:hover { color: var(--text); border-bottom-color: var(--border-strong); }
.nav-tabs .nav-link.active { color: var(--text); border-bottom-color: var(--text); }
.nav-pills .nav-link { border-radius: var(--radius); color: var(--text-2); font-weight: 500; }
.nav-pills .nav-link.active { background: var(--primary-soft); color: var(--primary); }
.list-group-item { border-color: var(--border); }
.list-group-item.active { background: var(--primary-soft); border-color: var(--border); color: var(--primary); }
.page-link { color: var(--text-2); border-color: var(--border); }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* Messages flash du framework October */
.oc-flash-message, .flash-message { border-radius: var(--radius-lg) !important; box-shadow: var(--shadow-lg) !important; font-family: var(--font) !important; }

/* ================= Connexion ================= */
body.app-auth { background: var(--bg); }
.app-auth h1 { font-size: 1.5rem !important; letter-spacing: -.01em !important; text-transform: none !important; color: var(--text) !important; font-weight: 600 !important; }
.app-auth h1 small { display: block; margin-top: .25rem; font-size: 15px !important; text-transform: none !important; color: var(--muted) !important; font-weight: 400 !important; letter-spacing: 0 !important; }
.card-signin {
    background: var(--surface) !important; border: 1px solid var(--border) !important; border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow) !important; padding-top: 2.5rem !important; padding-bottom: 2.5rem !important;
}
.card-signin, .card-signin * { color: var(--text) !important; }
.card-signin h3 { font-size: 1.25rem; font-weight: 600; }
.card-signin h3 small { color: var(--muted) !important; font-size: 14px; }
.card-signin img[style*="position: absolute"] { filter: grayscale(1) !important; opacity: .35; }
.card-signin .btn { width: 100%; min-height: 44px; }
.card-signin .btn-default:not([style*="background"]) { color: #fff !important; }
.card-signin .btn-default[style*="background"] { background: var(--surface) !important; }
.card-signin a { color: var(--primary) !important; }

/* ================= Divers ================= */
* { scrollbar-width: thin; scrollbar-color: #D4D4D8 transparent; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media (max-width: 575.98px) {
    .app-content > .container-fluid[style*="padding"],
    .app-content > div > .container-fluid[style*="padding"] { padding: 0 .75rem !important; }
    img { max-width: 100%; height: auto; }
}

/* L'ancien thème met les boutons en capitales : on revient à la casse normale */
.btn, .btn-default, button.btn { text-transform: none !important; letter-spacing: 0 !important; }
/* Arborescence des dossiers (bootstrap-treeview) */
.treeview .list-group-item { border: 0; border-bottom: 1px solid var(--border); font-size: 14px; padding: .6rem .9rem; }
.treeview .list-group-item:hover { background: var(--muted-bg) !important; }

/* ================= Pages de gestion : panneaux et tableaux hérités ================= */
/* les anciens blocs .bg-light (filtres, formulaires) deviennent des panneaux blancs bordés */
.app-content .row.bg-light, .app-content .form-row.bg-light, .app-content [class*="col-"].bg-light {
    background: var(--surface) !important;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.app-content .row.bg-light { margin-left: 0; margin-right: 0; padding: .5rem 0; }
.app-content .row > [class*="col-"].bg-light + [class*="col-"].bg-light { margin-left: -1px; }
.table .thead-dark th, .thead-dark th {
    background: var(--bg) !important; color: var(--muted) !important;
    border-color: var(--border) !important;
}
.table .thead-dark th input { color: var(--text); }
/* saisie des prix : cellules sobres, champ vide signalé en ambre */
.app-content td.border input { border: 0 !important; height: 36px; text-align: center; border-radius: 0; }
.app-content td.border input:focus { outline: 2px solid var(--primary); outline-offset: -2px; }
