/* ==========================================================================
 *  Drawer — right-side slide-out panel (modal cousin)
 *
 *  Used for entity-detail and edit surfaces that don't warrant a full modal:
 *  user/role drawers (xorizo permissions), cart drawer (build catalogue),
 *  Xori FAB drawer (app-core), etc. Three width variants: md / lg (default) / xl.
 *
 *  Markup (emitted by drawer() PHP helper or hand-written):
 *
 *    <div class="drawer-overlay" id="x" aria-hidden="true">
 *      <aside class="drawer drawer-lg" role="dialog" aria-labelledby="xTitle">
 *        <header class="drawer-header">
 *          <div class="drawer-title">
 *            <div class="drawer-title-name" id="xTitle">…</div>
 *            <div class="drawer-title-sub">…</div>
 *          </div>
 *          <button class="drawer-close" data-close-drawer="x">…</button>
 *        </header>
 *        <div class="drawer-body">
 *          <section class="drawer-section">…</section>
 *          <section class="drawer-section drawer-danger">…</section>
 *        </div>
 *        <footer class="drawer-footer">…actions…</footer>
 *      </aside>
 *    </div>
 *
 *  Open/close via `window.drawers.open(id)` / `.close(id)` (core.js).
 * ========================================================================== */

.drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    justify-content: flex-end;
    background: rgba(15, 23, 42, 0);
    backdrop-filter: blur(0);
    transition: background .25s ease, backdrop-filter .25s ease;
    pointer-events: none;
}
.drawer-overlay.show {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    pointer-events: auto;
}

.drawer {
    width: 520px;
    max-width: 100vw;
    height: 100vh;
    background: var(--surface, #fff);
    box-shadow: -4px 0 24px -8px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .25s ease;
    overflow: hidden;
}
.drawer-overlay.show .drawer { transform: translateX(0); }

/* Width variants */
.drawer-md { width: 420px; }
.drawer-lg { width: 520px; }
.drawer-xl { width: 720px; }

@media (max-width: 600px) {
    .drawer,
    .drawer-md,
    .drawer-lg,
    .drawer-xl { width: 100vw; }
}

/* ── Header ─────────────────────────────────────────────────── */
.drawer-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4, 1rem);
    padding: var(--space-5, 1.25rem);
    border-bottom: 1px solid var(--border, #e5e7eb);
    background: var(--surface, #fff);
    flex-shrink: 0;
}
.drawer-title {
    flex: 1;
    min-width: 0;
}
.drawer-title-name {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 0.125rem;
    display: flex;
    align-items: center;
    gap: var(--space-2, 0.5rem);
    flex-wrap: wrap;
    color: var(--text, #1f2937);
}
.drawer-title-sub {
    font-size: 0.8125rem;
    color: var(--text-muted, #6b7280);
}
.drawer-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--text-muted, #6b7280);
    border-radius: var(--radius-sm, 0.25rem);
    line-height: 0;
    flex-shrink: 0;
}
.drawer-close:hover {
    background: var(--gray-100, #f3f4f6);
    color: var(--text, #1f2937);
}

/* ── Body ───────────────────────────────────────────────────── */
.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.drawer-section {
    padding: var(--space-4, 1.125rem) var(--space-5, 1.25rem);
    border-bottom: 1px solid var(--gray-100, #f3f4f6);
}
.drawer-section:last-child { border-bottom: none; }
.drawer-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #6b7280);
    margin: 0 0 var(--space-2, 0.625rem);
}

.drawer-danger {
    background: #fef2f2;
    border-top: 1px solid #fee2e2;
}
.drawer-danger .drawer-section-title { color: #991b1b; }

/* ── Footer (sticky actions) ───────────────────────────────── */
.drawer-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2, 0.5rem);
    padding: var(--space-3, 0.75rem) var(--space-5, 1.25rem);
    border-top: 1px solid var(--border, #e5e7eb);
    background: var(--surface, #fff);
    flex-shrink: 0;
}
