/* ================================================================
   CEZER STAFF — Système de design global v2
   Aligné avec le site principal Cezer (beige / dark / Poppins)
   Palette : #e4e2dd (beige) · #292929 (sombre)
   ================================================================ */

:root {
    /* ── Palette de marque ─────────────────────────────────── */
    --beige:            #e4e2dd;
    --beige-light:      #f0efec;
    --beige-dark:       #d4d1ca;
    --cream:            #faf9f6;
    --dark:             #292929;
    --dark-soft:        #333333;
    --dark-light:       #3a3a3a;
    --dark-lighter:     #4a4a4a;
    --dark-border:      #3d3d3d;
    --white:            #ffffff;
    --black:            #000000;

    /* ── Sémantique — Claire (zone de contenu) ────────────── */
    --bg-body:          #e4e2dd;
    --bg-surface:       #ffffff;
    --bg-elevated:      #faf9f6;
    --bg-muted:         #efede8;
    --text-primary:     #292929;
    --text-secondary:   #5a5a5a;
    --text-tertiary:    #8b8b88;
    --text-placeholder: #a7a4a0;
    --border:           #d9d6d0;
    --border-light:     #bfbcb5;  /* Plus contrasté — pour les hovers/focus (convention historique) */
    --border-dark:      #a8a49c;  /* Encore plus marqué */
    --border-subtle:    #e5e2dc;  /* Plus doux — pour les séparateurs internes */

    /* ── Sémantique — Sombre (barre latérale) ─────────────── */
    --sidebar-bg:       #1f1f1f;
    --sidebar-bg-soft:  #2a2a2a;
    --sidebar-border:   #353535;
    --sidebar-text:     #e4e2dd;
    --sidebar-text-muted: #9e9c98;
    --sidebar-text-dim: #6e6d6a;

    /* ── Couleurs d'accentuation ──────────────────────────── */
    --accent:           #292929;
    --accent-hover:     #3a3a3a;
    --accent-soft:      rgba(41, 41, 41, 0.06);
    --success:          #2e7d4f;
    --success-bg:       rgba(46, 125, 79, 0.1);
    --success-border:   rgba(46, 125, 79, 0.25);
    --error:            #c7433a;
    --error-bg:         rgba(199, 67, 58, 0.08);
    --error-border:     rgba(199, 67, 58, 0.22);
    --warning:          #d68b2e;
    --warning-bg:       rgba(214, 139, 46, 0.1);
    --warning-border:   rgba(214, 139, 46, 0.25);
    --info:             #2f6fb8;
    --info-bg:          rgba(47, 111, 184, 0.08);
    --info-border:      rgba(47, 111, 184, 0.22);

    /* ── Dimensions ───────────────────────────────────────── */
    --sidebar-width:     260px;
    --sidebar-collapsed: 72px;
    --topbar-height:     64px;
    --radius-sm:         4px;
    --radius:            8px;
    --radius-md:         10px;
    --radius-lg:         14px;
    --radius-xl:         18px;

    /* ── Ombres ───────────────────────────────────────────── */
    --shadow-xs: 0 1px 2px rgba(41, 41, 41, 0.04);
    --shadow-sm: 0 2px 6px rgba(41, 41, 41, 0.06);
    --shadow-md: 0 6px 16px rgba(41, 41, 41, 0.08);
    --shadow-lg: 0 16px 40px rgba(41, 41, 41, 0.12);
    --shadow-xl: 0 24px 64px rgba(41, 41, 41, 0.16);

    /* ── Typographie ──────────────────────────────────────── */
    --font:     'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono:'SF Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;

    /* ── Transitions ──────────────────────────────────────── */
    --transition:        .2s cubic-bezier(.4,0,.2,1);
    --transition-slow:   .35s cubic-bezier(.4,0,.2,1);
    --transition-bounce: .5s cubic-bezier(.34,1.56,.64,1);
}

/* ── Reset ─────────────────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14.5px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.65;
    min-height: 100vh;
    overflow-x: hidden;
}

::selection {
    background: var(--dark);
    color: var(--beige);
}

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

img {
    display: block;
    max-width: 100%;
    height: auto;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input, textarea, select {
    font-family: inherit;
}

/* ── Utilitaires ───────────────────────────────────────────── */
.text-muted {
    color: var(--text-secondary);
}

.text-small {
    font-size: 0.8rem;
}

/* ── Alerts — style cartonné sur fond clair ───────────────── */
.alert {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
}

.alert i {
    font-size: 1.1rem;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.alert-error {
    background: var(--error-bg);
    border-color: var(--error-border);
    color: #8f2e27;
}

.alert-success {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: #1e5938;
}

.alert-warning {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: #8a5614;
}

.alert-info {
    background: var(--info-bg);
    border-color: var(--info-border);
    color: #1f4d82;
}

/* ── Boutons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.35rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.005em;
    line-height: 1.4;
    transition: all var(--transition);
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}

.btn i,
.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-primary {
    background: var(--dark);
    color: var(--beige);
    border-color: var(--dark);
}

.btn-primary:hover {
    background: var(--dark-soft);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--bg-elevated);
    border-color: var(--border-dark);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--accent-soft);
    color: var(--text-primary);
    border-color: var(--border-dark);
}

.btn-danger {
    background: var(--error);
    color: #fff;
    border-color: var(--error);
}

.btn-danger:hover {
    background: #b03830;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 0.9rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.9rem 1.6rem;
    font-size: 0.95rem;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ── Formulaires ───────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.45rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="datetime-local"] {
    width: 100%;
    padding: 0.75rem 0.95rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: var(--font);
    transition: border-color var(--transition), box-shadow var(--transition);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
input[type="datetime-local"]:focus {
    outline: none;
    border-color: var(--dark);
    box-shadow: 0 0 0 3px rgba(41, 41, 41, 0.08);
}

input::placeholder {
    color: var(--text-placeholder);
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.4);
    cursor: pointer;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--dark);
    cursor: pointer;
    border-radius: 3px;
    flex-shrink: 0;
}

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

.input-icon {
    position: absolute;
    left: 0.95rem;
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    pointer-events: none;
    z-index: 1;
}

.input-wrapper input {
    width: 100%;
    padding: 0.75rem 0.95rem 0.75rem 2.7rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--dark);
    box-shadow: 0 0 0 3px rgba(41, 41, 41, 0.08);
}

.input-wrapper input::placeholder {
    color: var(--text-placeholder);
}

/* ── Sélecteurs ────────────────────────────────────────────── */
select {
    width: 100%;
    padding: 0.75rem 0.95rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: var(--font);
    transition: border-color var(--transition), box-shadow var(--transition);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b8b88' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    padding-right: 2.5rem;
}

select:focus {
    outline: none;
    border-color: var(--dark);
    box-shadow: 0 0 0 3px rgba(41, 41, 41, 0.08);
}

select option {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.input-wrapper select {
    width: 100%;
    padding: 0.75rem 0.95rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: var(--font);
    transition: border-color var(--transition), box-shadow var(--transition);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b8b88' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    padding-right: 2.5rem;
}

.input-wrapper select:focus {
    outline: none;
    border-color: var(--dark);
    box-shadow: 0 0 0 3px rgba(41, 41, 41, 0.08);
}

/* ── Zones de texte ────────────────────────────────────────── */
textarea {
    width: 100%;
    min-height: 92px;
    resize: vertical;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 0.95rem;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9375rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    line-height: 1.55;
}

textarea:focus {
    outline: none;
    border-color: var(--dark);
    box-shadow: 0 0 0 3px rgba(41, 41, 41, 0.08);
}

textarea::placeholder {
    color: var(--text-placeholder);
}

/* ── Cartes génériques (cascadent dans tout le panel) ─────── */
.card,
.db-card,
.ps-card,
.panel-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

/* ── Barre de défilement ─────────────────────────────────── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Scrollbar sombre dans la barre latérale */
.sidebar ::-webkit-scrollbar-thumb {
    background: var(--sidebar-border);
}

.sidebar ::-webkit-scrollbar-thumb:hover {
    background: var(--sidebar-text-dim);
}

/* ── Layout principal ────────────────────────────────────── */
.app-body {
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
}

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-slow);
}

.content-area {
    padding: 1.75rem 2rem 3rem;
    max-width: 1500px;
    margin: 0 auto;
}

/* ── Top bar (barre supérieure de chaque page) ──────────── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: saturate(1.1) blur(6px);
    -webkit-backdrop-filter: saturate(1.1) blur(6px);
    background: rgba(255, 255, 255, 0.86);
    /* Safe-area : compense la zone de la status bar / encoche sur mobile */
    padding-top: env(safe-area-inset-top, 0);
    padding-left: max(2rem, env(safe-area-inset-left));
    padding-right: max(2rem, env(safe-area-inset-right));
    height: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
    flex: 1;
}

.topbar-menu-btn {
    display: none;
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition), transform var(--transition);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.topbar-menu-btn:hover {
    background: var(--accent-soft);
    color: var(--text-primary);
    border-color: var(--border-dark);
}

.topbar-menu-btn:active {
    transform: scale(0.94);
    background: var(--bg-muted);
}

.topbar-menu-btn i,
.topbar-menu-btn svg {
    width: 20px;
    height: 20px;
}

.topbar-title {
    min-width: 0;
    flex: 1;
}

.topbar-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-breadcrumb {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 100%;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.topbar-date {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
}

.topbar-date i,
.topbar-date svg {
    width: 14px;
    height: 14px;
    color: var(--text-tertiary);
}

.topbar-send-notif {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 1rem;
    border-radius: var(--radius);
    background: var(--dark);
    color: var(--beige);
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid var(--dark);
    cursor: pointer;
    transition: all var(--transition);
}

.topbar-send-notif:hover {
    background: var(--dark-soft);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.topbar-send-notif i,
.topbar-send-notif svg {
    width: 14px;
    height: 14px;
}

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE GLOBAL
   ════════════════════════════════════════════════════════════════ */

/* ── Tablette (≤1024px) ──────────────────────────────────── */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }
    .content-area {
        padding: 1.5rem 1.5rem 2.5rem;
    }
    .topbar {
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
    }
}

/* ── Mobile (≤768px) ─────────────────────────────────────── */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
        --topbar-height: 60px;
    }

    html {
        font-size: 14px;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    body {
        /* L'app gère elle-même les safe-areas par section pour éviter les zones blanches */
        padding-left: 0;
        padding-right: 0;
        padding-bottom: 0;
        overscroll-behavior-y: contain;
    }

    .main-content {
        margin-left: 0;
        min-height: 100vh;
        min-height: 100dvh;
    }

    /* ── Topbar mobile : compacte, posée en dessous de l'encoche ── */
    .topbar {
        padding-left: max(0.85rem, env(safe-area-inset-left));
        padding-right: max(0.85rem, env(safe-area-inset-right));
        gap: 0.6rem;
    }

    .topbar-menu-btn {
        display: inline-flex;
        width: 40px;
        height: 40px;
    }

    .topbar-left {
        gap: 0.65rem;
    }

    .topbar-right {
        gap: 0.45rem;
    }

    .topbar-title h1 {
        font-size: 1.1rem;
    }

    .topbar-breadcrumb {
        font-size: 0.7rem;
        letter-spacing: 0.06em;
    }

    .topbar-date {
        padding: 0.4rem 0.65rem;
        font-size: 0.74rem;
    }

    /* Sur mobile, on cache le libellé "Envoyer une notification" et on ne garde que l'icône */
    .topbar-send-notif {
        font-size: 0;
        gap: 0;
        padding: 0.55rem;
        width: 40px;
        height: 40px;
        justify-content: center;
        flex-shrink: 0;
    }

    .topbar-send-notif i,
    .topbar-send-notif svg {
        width: 16px;
        height: 16px;
    }

    .content-area {
        padding: 1.1rem 0.95rem 3rem;
        padding-left: max(0.95rem, env(safe-area-inset-left));
        padding-right: max(0.95rem, env(safe-area-inset-right));
        padding-bottom: max(3rem, calc(1rem + env(safe-area-inset-bottom)));
    }

    /* Cibles tactiles minimales (Apple HIG = 44pt) */
    .btn,
    a.nav-item,
    select {
        min-height: 44px;
    }

    .topbar-menu-btn,
    button[type="button"]:not(.btn-sm):not(.ch-msg-action):not(.tk-icon-btn):not(.notif-bell-btn):not(.user-logout) {
        min-height: 40px;
    }

    input[type="checkbox"],
    input[type="radio"] {
        width: 20px;
        height: 20px;
        min-height: unset;
    }

    /* Empêcher le zoom iOS sur focus : iOS ne zoome jamais quand font-size ≥ 16px */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="search"],
    input[type="datetime-local"],
    input[type="time"],
    select,
    textarea {
        font-size: 16px;
        padding: 0.8rem 0.95rem;
        max-width: 100%;
    }

    .input-wrapper input {
        font-size: 16px;
        padding-top: 0.8rem;
        padding-bottom: 0.8rem;
    }

    .btn {
        padding: 0.8rem 1.25rem;
    }

    * {
        -webkit-overflow-scrolling: touch;
    }

    /* Empêcher le pinch-zoom sur les cibles tactiles courantes */
    button, a, .btn, .nav-item, .panel-tab, input, select, textarea {
        touch-action: manipulation;
    }
}

/* ── Petits écrans (≤480px) ─────────────────────────────── */
@media (max-width: 480px) {
    html {
        font-size: 13.5px;
    }

    .topbar {
        gap: 0.5rem;
    }

    .topbar-left {
        gap: 0.55rem;
    }

    .btn {
        padding: 0.75rem 1.1rem;
        font-size: 0.82rem;
    }

    .btn-block {
        width: 100%;
    }

    .form-group label {
        font-size: 0.74rem;
    }

    .alert {
        font-size: 0.82rem;
        padding: 0.7rem 0.9rem;
    }

    .topbar-title h1 {
        font-size: 1rem;
    }

    .topbar-breadcrumb {
        display: none;
    }

    .topbar-date {
        display: none;
    }
}

/* ── Très petits écrans (≤360px) ───────────────────────── */
@media (max-width: 360px) {
    .content-area {
        padding: 0.9rem 0.75rem 2.5rem;
    }
    .topbar {
        padding-left: 0.65rem;
        padding-right: 0.65rem;
    }
    .topbar-title h1 {
        font-size: 0.95rem;
    }
}

/* ── Mode paysage mobile : réduire la hauteur des hero ──── */
@media (max-width: 920px) and (orientation: landscape) and (max-height: 500px) {
    :root {
        --topbar-height: 52px;
    }
}

/* ── Préférences utilisateur : moins de mouvement ───────── */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
