/*
 * ============================================================
 *  Y-Stand Site Modal System  –  site-modal.css
 *  Standard reusable modal framework for the whole website.
 *
 *  STRUCTURE:
 *    <div class="sm-backdrop" id="...Backdrop"></div>
 *    <div class="sm-wrap"     id="...Wrap" onclick="if(event.target===this)YModal.bounce('...')">
 *      <div class="sm-box [sm-sm|sm-md|sm-lg|sm-xl|sm-fullscreen]" id="...">
 *        <button class="sm-close-btn" onclick="YModal.close('...')">...</button>
 *        <div class="sm-header">
 *          <span class="sm-header-icon">...</span>
 *          <span class="sm-header-title">...</span>
 *        </div>
 *        <div class="sm-body"> ... scrollable content ... </div>
 *        <div class="sm-footer"> ... sticky footer ... </div>
 *      </div>
 *    </div>
 *
 *  OPENING / CLOSING:
 *    YModal.open(baseId)   –  adds .show to backdrop + wrap
 *    YModal.close(baseId)  –  removes .show
 *    YModal.bounce(baseId) –  bounces the box
 *
 *  SIZE MODIFIERS (on sm-box):
 *    sm-sm   → max-width: 380px
 *    sm-md   → max-width: 520px  (default, no modifier needed)
 *    sm-lg   → max-width: 680px
 *    sm-xl   → max-width: 860px
 *    sm-fullscreen → 100vw x 100vh (mobile sheet style)
 * ============================================================
 */

/* ── Backdrop ────────────────────────────────────────────── */
.sm-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10400;
    background: rgba(20, 0, 50, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.sm-backdrop.show { display: block; }

/* ── Centering wrap ──────────────────────────────────────── */
.sm-wrap {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10500;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.sm-wrap.show { display: flex; }

/* ── Box ─────────────────────────────────────────────────── */
.sm-box {
    position: relative;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 16px 60px rgba(74, 0, 114, 0.22), 0 4px 20px rgba(0,0,0,0.12);
    width: 100%;
    max-width: 520px;       /* default = sm-md */
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: smSlideIn 0.25s cubic-bezier(.22,.68,0,1.2);
}

/* Size modifiers */
.sm-box.sm-sm   { max-width: 380px; }
.sm-box.sm-md   { max-width: 520px; }
.sm-box.sm-lg   { max-width: 680px; }
.sm-box.sm-xl   { max-width: 860px; }
.sm-box.sm-fullscreen { max-width: 100vw; max-height: 100vh; border-radius: 0; width: 100vw; }

/* Entry animation */
@keyframes smSlideIn {
    from { transform: translateY(28px) scale(.97); opacity: 0; }
    to   { transform: translateY(0)     scale(1);   opacity: 1; }
}

/* Bounce effect when clicking outside */
@keyframes smBounce {
    0%   { transform: translateX(0); }
    20%  { transform: translateX(-6px); }
    40%  { transform: translateX(5px); }
    60%  { transform: translateX(-3px); }
    80%  { transform: translateX(2px); }
    100% { transform: translateX(0); }
}
.sm-box.sm-bounce {
    animation: smBounce 0.35s ease;
}

/* ── Close button ────────────────────────────────────────── */
.sm-close-btn {
    position: absolute;
    top: 10px; right: 12px;
    z-index: 30;
    background: rgba(255,255,255,0.18);
    border: none;
    color: #fff;
    border-radius: 50%;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
    line-height: 1;
}
.sm-close-btn:hover  { background: rgba(255,255,255,0.35); color: #fff; }
.sm-close-btn:focus  { outline: 2px solid rgba(255,255,255,0.6); outline-offset: 2px; }

/* ── Header ──────────────────────────────────────────────── */
.sm-header {
    background: linear-gradient(135deg, #4A0072, #7C3AED);
    color: #fff;
    padding: 16px 52px 14px 20px;   /* right-pad leaves space for close btn */
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    min-height: 56px;
}
.sm-header-icon  { font-size: 1.15rem; opacity: 0.85; flex-shrink: 0; }
.sm-header-title { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.01em; flex: 1; min-width: 0; }

/* ── Sub-header bar (optional breadcrumb / meta row) ──────── */
.sm-subheader {
    background: #f3ecff;
    border-bottom: 1px solid #e8deff;
    padding: 7px 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    font-size: 0.78rem;
}
.sm-subheader:empty { display: none; }

/* ── Body ────────────────────────────────────────────────── */
.sm-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 24px 0;
    display: flex;
    flex-direction: column;
}
/* Compact variant (no top-padding) */
.sm-body.sm-body-flush { padding: 0; }

/* ── Footer ──────────────────────────────────────────────── */
.sm-footer {
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid #eee;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.07);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
    z-index: 10;
}
.sm-footer.sm-footer-between { justify-content: space-between; }

/* ── Divider inside body ─────────────────────────────────── */
.sm-divider { height: 1px; background: #eee; margin: 14px -24px; flex-shrink: 0; }

/* ── Form label override inside sm-body ─────────────────── */
.sm-body label { font-size: 0.85rem; font-weight: 600; color: #444; margin-bottom: 4px; }

/* ═══════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 575px) {
    .sm-wrap { padding: 10px 6px; align-items: flex-end; }

    .sm-box {
        max-width: 100% !important;
        border-radius: 18px 18px 12px 12px;
        max-height: 96vh;
        animation: smSlideInMobile 0.3s cubic-bezier(.22,.68,0,1.1);
    }

    @keyframes smSlideInMobile {
        from { transform: translateY(60px); opacity: 0; }
        to   { transform: translateY(0);    opacity: 1; }
    }

    .sm-header { padding: 14px 48px 12px 16px; min-height: 50px; }
    .sm-header-title { font-size: 1rem; }
    .sm-body  { padding: 16px 16px 0; }
    .sm-footer { padding: 10px 16px; }
    .sm-divider { margin: 12px -16px; }
}

@media (max-width: 375px) {
    .sm-header-title { font-size: 0.92rem; }
}

/* ── Utility: prevent body scroll when modal open ─────────── */
body.sm-open { overflow: hidden !important; }
