/* Custom flex layout — narrower sidebar than Bootstrap col-lg-3 so region
   rows fit on one line, but wide enough that "REGION FILTER" + "Map" button
   stay on a single row. */
.mk-shop-layout { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.mk-shop-sidebar-col { flex: 0 0 262px; max-width: 262px; }
.mk-shop-main-col    { flex: 1 1 0; min-width: 0; }
@media (max-width: 991.98px) {
    .mk-shop-sidebar-col, .mk-shop-main-col { flex: 1 1 100%; max-width: 100%; }
}
.mk-shop-side {
    position: sticky; top: 76px;
    border: 1px solid var(--mk-border); border-radius: var(--mk-radius);
    background: var(--mk-bg-card); overflow: hidden;
}
.mk-shop-side-head {
    display:flex; justify-content:space-between; align-items:center;
    padding: 10px 12px; border-bottom: 1px solid var(--mk-border); background: var(--mk-bg-soft);
    gap: 8px;
}
.mk-shop-side-head h6 { white-space: nowrap; flex: 1 1 auto; min-width: 0; }
.mk-shop-side-head .btn { flex: 0 0 auto; white-space: nowrap; }
.mk-shop-side-body { padding: 6px; max-height: 420px; overflow-y: auto; }
.mk-region-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 10px; border-radius: 4px; font-size: 13px; color: var(--mk-ink-2);
    text-decoration: none; transition: background .12s;
    white-space: nowrap; gap: 8px;
}
.mk-region-label { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mk-region-label small { font-size: 10.5px; }
.mk-region-row:hover { background: var(--mk-bg-soft); }
.mk-region-row.active { background: var(--mk-accent-soft); color: var(--mk-accent-deep); font-weight: 500; }
.mk-region-badge {
    background: var(--mk-ink); color: #fff; font-size: 11px;
    border-radius: 999px; padding: 2px 8px; font-weight: 500; min-width: 28px; text-align: center;
}
.mk-region-row.active .mk-region-badge { background: var(--mk-accent-deep); }

.mk-shop-toolbar {
    display:flex; justify-content:space-between; align-items:center;
    flex-wrap: wrap; gap: 8px; margin-bottom: 14px;
    padding: 0 4px;
}
.mk-sort-wrap { display:flex; align-items:center; }
.mk-sort-wrap .btn-group .btn { font-size: 12px; padding: 4px 10px; white-space: nowrap; }
.mk-shop-toolbar-left { display:flex; align-items:center; gap: 10px; flex-wrap: wrap; }

@media (max-width: 767.98px) {
    .mk-shop-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
    .mk-sort-wrap { width: 100%; align-items: stretch; gap: 6px; }
    .mk-sort-wrap > label { display: none; }
    .mk-sort-wrap .btn-group { width: 100%; display: flex; }
    .mk-sort-wrap .btn-group .btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 8px 4px;
        font-size: 11px;
        line-height: 1.25;
        white-space: normal;
        word-break: keep-all;
        overflow-wrap: break-word;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .mk-sort-wrap .btn-group .btn i { display: none; }
}

/* Grid / list view toggle (icon pair) */
.mk-view-toggle {
    display: inline-flex; border: 1px solid var(--mk-border); border-radius: 4px;
    overflow: hidden; margin-left: 4px;
}
.mk-view-btn {
    background: var(--mk-card); border: 0; padding: 4px 10px;
    font-size: 13px; color: var(--mk-muted); cursor: pointer;
    line-height: 1; transition: background .1s, color .1s;
}
.mk-view-btn + .mk-view-btn { border-left: 1px solid var(--mk-border); }
.mk-view-btn:hover { color: var(--mk-ink); background: var(--mk-bg-soft); }
.mk-view-btn.active { background: var(--mk-ink); color: #fff; }

/* One-per-row list layout — overrides the grid when active. */
#mkStoreGrid.mk-view-list > .mk-store-item { flex: 0 0 100% !important; max-width: 100% !important; }

/* List-view card layout
   ─────────────────────────────────────────────────────────────
   Row 1:  [THUMB 28%] │ [INFO 1fr]              │ [QR panel 180px]
   Row 2:  [======== BUTTONS — full card width ==============]
   QR panel has a soft background + left border so it reads as a
   distinct area and fills the empty space beside the info block. */
/* List-view layout — info stretches full-width to the right edge,
   QR sits inline at the right end of the info row, buttons full-width below.
   ───────────────────────────────────────
   Row 1: [ THUMB ]  [ HAI CHAU · 1 ORDERS          ─── ← 우측 창 끝 ]
                    [ MISO Da Nang                                    ]
                    [ 주소 / 전화 / 인원 수                              ]
   Row 2: [ THUMB ]  [ ================ 버튼 2개 ======================]
   - QR 은 row 1 의 우측 상단에 inline float 로 배치 (정보 텍스트와 같은 행).
   - 버튼은 정보 열 하단 full-width, 썸네일 밑은 침범하지 않음.
   ─────────────────────────────────────── */
#mkStoreGrid.mk-view-list .mk-store-card {
    display: grid;
    grid-template-columns: 240px minmax(0,1fr);
    align-items: stretch;
}
#mkStoreGrid.mk-view-list .mk-store-card .row.g-0 { display: contents !important; }
#mkStoreGrid.mk-view-list .mk-store-card .row.g-0 > .col-md-5 {
    grid-column: 1;
    flex: unset !important; max-width: unset !important; width: auto !important;
}
#mkStoreGrid.mk-view-list .mk-store-card .row.g-0 > .col-md-7 {
    grid-column: 2;
    flex: unset !important; max-width: unset !important; width: auto !important;
}
#mkStoreGrid.mk-view-list .mk-store-thumb { min-height: 220px; height: 100%; }

/* Content column : info text on top (full width to right edge), buttons below. */
#mkStoreGrid.mk-view-list .mk-store-card .card-body {
    display: flex; flex-direction: column;
    padding: 0;
    min-height: 220px;
    position: relative;
}
#mkStoreGrid.mk-view-list .mk-store-card .card-body > .mb-3 {
    margin: 0 !important;
    padding: 18px 22px;
    /* Leave space on the right so the QR never overlaps text, and reserve
       enough vertical room that the QR sits above the buttons. */
    padding-right: 160px;
    min-height: 160px;
    flex: 1 1 auto;
}

/* The original wrapper collapses — children are hoisted. */
#mkStoreGrid.mk-view-list .mk-store-card .card-body > .d-flex { display: contents !important; }

/* QR — pinned to the top-right corner of the info row (창 끝).
   Sized so it sits inside the info block and never overlaps the buttons bar. */
#mkStoreGrid.mk-view-list .mk-store-card .mk-store-qr {
    position: absolute;
    top: 14px; right: 14px;
    width: 124px !important; flex: unset !important;
    margin: 0 !important;
    padding: 6px;
    background: var(--mk-card);
    border: 1px solid var(--mk-border);
    border-radius: 4px;
    z-index: 1;
}
#mkStoreGrid.mk-view-list .mk-store-card .mk-store-qr img { max-width: 100%; }
#mkStoreGrid.mk-view-list .mk-store-card .mk-store-qr small { font-size: 9.5px; margin-top: 2px !important; }

/* Buttons row — full width of content column, across the bottom. */
#mkStoreGrid.mk-view-list .mk-store-card .card-body > .d-flex > .flex-grow-1 {
    display: flex !important; gap: 10px;
    padding: 12px 22px 16px;
    margin: 0;
    border-top: 1px solid var(--mk-border);
    background: var(--mk-bg-soft);
}
#mkStoreGrid.mk-view-list .mk-store-card .card-body > .d-flex > .flex-grow-1 > a {
    flex: 1 1 0; width: auto !important; margin-bottom: 0 !important;
}

@media (max-width: 767.98px) {
    #mkStoreGrid.mk-view-list .mk-store-card { grid-template-columns: 1fr; }
    #mkStoreGrid.mk-view-list .mk-store-card .row.g-0 > .col-md-5,
    #mkStoreGrid.mk-view-list .mk-store-card .row.g-0 > .col-md-7 { grid-column: 1; }
    #mkStoreGrid.mk-view-list .mk-store-card .card-body > .mb-3 { padding-right: 22px; }
    #mkStoreGrid.mk-view-list .mk-store-card .mk-store-qr { position: static; width: 130px !important; margin: 10px auto !important; }
}

/* "Nearest to me" status bar — shown under the toolbar when sort=nearby. */
.mk-nearby-status {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; margin-bottom: 14px; border-radius: 6px;
    font-size: 12.8px; line-height: 1.45;
    border: 1px solid var(--mk-border); background: var(--mk-bg-soft); color: var(--mk-ink-2);
}
.mk-nearby-status > i.fa-location-arrow { color: var(--mk-accent-deep); }
.mk-nearby-status[data-kind="loading"] { background: #fff8ec; border-color: #f3dfa9; color: #7a5b00; }
.mk-nearby-status[data-kind="ok"]      { background: #e9f6ec; border-color: #b5d7c0; color: #2e5b3d; }
.mk-nearby-status[data-kind="denied"],
.mk-nearby-status[data-kind="error"]   { background: #fdecec; border-color: #f0c0c0; color: #8a2a2a; }

.mk-store-card { overflow: hidden; transition: box-shadow .2s ease, transform .2s ease; }
.mk-store-card:hover { box-shadow: 0 8px 24px rgba(42,35,39,0.09); transform: translateY(-2px); }
.mk-store-thumb {
    min-height: 220px; background-size: cover; background-position: center;
    position: relative; display: flex; align-items: flex-end;
}
/* Graceful placeholder — shown when no admin-uploaded thumbnail exists. */
.mk-store-thumb--ph {
    background: linear-gradient(135deg, var(--mk-accent-soft) 0%, #fdfbfa 55%, var(--mk-bg-soft) 100%);
}
.mk-store-thumb-mono {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 44px; color: rgba(176,132,143,0.35); pointer-events: none;
}
.mk-store-thumb--ph .mk-store-thumb-overlay {
    background: linear-gradient(to top, rgba(42,35,39,0.35), transparent);
}
.mk-store-badge-new {
    position: absolute; top: 8px; left: 8px;
    background: var(--mk-accent-deep); color: #fff;
    font-size: 10px; font-weight: 600; padding: 3px 9px; border-radius: 3px;
    letter-spacing: 0.15em;
}
.mk-store-thumb-overlay {
    padding: 14px 16px; color: #fff; width: 100%;
    background: linear-gradient(to top, rgba(42,35,39,0.55), transparent);
}
.mk-store-region { font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; opacity: 0.9; }
.mk-store-city   { margin: 2px 0 0; font-size: 1.15rem; font-weight: 500; }

.mk-store-qr {
    background: var(--mk-card); border: 1px solid var(--mk-border); border-radius: 4px;
    padding: 6px; flex: 0 0 92px; width: 92px;
    cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease;
    display: block;
}
.mk-store-qr:hover { border-color: var(--mk-accent); box-shadow: 0 4px 12px rgba(176,132,143,0.18); }
.mk-store-qr img { width: 100%; height: auto; display: block; }

/* ===== QR Modal (wide with staff pane) ===== */
.mk-qr-modal, .mk-map-modal {
    position: fixed; inset: 0; z-index: 1200;
    display: none; align-items: center; justify-content: center; padding: 20px;
}
.mk-qr-modal.open, .mk-map-modal.open { display: flex; }
.mk-qr-modal-backdrop {
    position: absolute; inset: 0; background: rgba(42,35,39,0.55);
    backdrop-filter: blur(3px);
}
.mk-qr-modal-dialog {
    position: relative; background: var(--mk-card); border-radius: var(--mk-radius);
    max-width: 440px; width: 100%; max-height: calc(100vh - 40px); overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    animation: mkQrIn .25s ease;
}
.mk-qr-modal-wide { max-width: 900px; }
.mk-map-dialog { max-width: 980px; width: 100%; padding: 0; }
.mk-map-header { display:flex; justify-content:space-between; align-items:center; padding: 14px 20px; border-bottom: 1px solid var(--mk-border); }
.mk-map-frame { height: 72vh; width: 100%; }

@keyframes mkQrIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.mk-qr-modal-close {
    position: absolute; top: 10px; right: 10px;
    background: none; border: 0; padding: 8px 12px;
    cursor: pointer; color: var(--mk-muted); font-size: 18px; z-index: 2;
}
.mk-qr-modal-close:hover { color: var(--mk-ink); }
.mk-qr-modal-body { padding: 0; }
.mk-qr-main-pane   { padding: 28px 24px 24px; }
.mk-qr-staff-pane  { padding: 20px 20px 20px; padding-right: 44px; background: var(--mk-bg-soft); border-left: 1px solid var(--mk-border); }
@media (max-width: 767px) {
    .mk-qr-staff-pane { border-left: 0; border-top: 1px solid var(--mk-border); }
    .mk-qr-main-pane  { padding: 22px 18px 12px; }
}
.mk-qr-big-wrap {
    background: var(--mk-card); border: 1px solid var(--mk-border); border-radius: 4px;
    padding: 14px; margin: 0 auto; max-width: 300px;
}
.mk-qr-big-wrap img { width: 100%; height: auto; display: block; }
.mk-qr-subhead { font-size: 12.5px; color: var(--mk-muted); }

.mk-qr-meta { border-top: 1px solid var(--mk-border); padding-top: 12px; font-size: 13px; }
.mk-qr-meta-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.mk-qr-meta-label { color: var(--mk-accent); width: 18px; flex: 0 0 18px; text-align: center; }
.mk-qr-url-input {
    flex: 1 1 auto; border: 1px solid var(--mk-border); border-radius: 3px;
    padding: 4px 8px; font-size: 11.5px; font-family: monospace;
    color: var(--mk-ink-2); background: var(--mk-bg-soft); min-width: 0;
}

/* Staff thumbnails */
.mk-staff-thumb {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 6px 8px; border: 1px solid var(--mk-border);
    background: var(--mk-card); border-radius: 6px; cursor: pointer; text-align: left;
    transition: border-color .12s, box-shadow .12s;
    margin-bottom: 6px;
}
.mk-staff-thumb:hover { border-color: var(--mk-accent); }
.mk-staff-thumb.active { border-color: var(--mk-accent-deep); box-shadow: 0 0 0 2px var(--mk-accent-soft); }
.mk-staff-thumb-main  { background: var(--mk-accent-soft); border-color: var(--mk-accent); }
.mk-staff-thumb-qr {
    flex: 0 0 46px; width: 46px; height: 46px; background: var(--mk-card);
    border: 1px solid var(--mk-border); border-radius: 3px; padding: 2px;
}
.mk-staff-thumb-qr img { width: 100%; height: 100%; object-fit: contain; display: block; }
.mk-staff-thumb-info { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.mk-staff-thumb-info strong { font-size: 12.5px; color: var(--mk-ink); font-weight: 600; }
.mk-staff-thumb-info small { font-size: 10.5px; color: var(--mk-muted); }

.mk-staff-thumb-list { max-height: 380px; overflow-y: auto; padding-right: 2px; }

@media (max-width: 991.98px) {
    .mk-shop-side { position: static; margin-bottom: 14px; }
    .mk-shop-side-body { max-height: 260px; }
    .mk-store-thumb { min-height: 160px; }
}

/* ─── DARK MODE overrides for shop page ─── */
:root[data-theme="dark"] .mk-region-row.active { background: var(--mk-accent-soft); color: var(--mk-accent-deep); }
:root[data-theme="dark"] .mk-region-badge { background: var(--mk-accent); color: #0a0807; }
:root[data-theme="dark"] .mk-region-row.active .mk-region-badge { background: var(--mk-accent-deep); color: #0a0807; }
:root[data-theme="dark"] .mk-view-btn { background: var(--mk-card); color: var(--mk-muted); }
:root[data-theme="dark"] .mk-view-btn:hover { color: var(--mk-ink); background: var(--mk-paper-2); }
:root[data-theme="dark"] .mk-view-btn.active { background: var(--mk-accent); color: #0a0807; }
:root[data-theme="dark"] .mk-store-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
:root[data-theme="dark"] .mk-store-thumb--ph {
    background: linear-gradient(135deg, var(--mk-accent-soft) 0%, var(--mk-paper-2) 55%, var(--mk-paper) 100%);
}
:root[data-theme="dark"] .mk-store-badge-new { background: var(--mk-accent); color: #0a0807; }
:root[data-theme="dark"] .mk-nearby-status[data-kind="loading"] {
    background: #2a210f; border-color: #4a3c1d; color: #d7b67a;
}
:root[data-theme="dark"] .mk-nearby-status[data-kind="ok"] {
    background: #14241a; border-color: #2e4d35; color: #9ec79a;
}
:root[data-theme="dark"] .mk-nearby-status[data-kind="denied"],
:root[data-theme="dark"] .mk-nearby-status[data-kind="error"] {
    background: #2a1614; border-color: #4a2624; color: #e3aaa0;
}
:root[data-theme="dark"] .mk-qr-modal-backdrop, :root[data-theme="dark"] .mk-map-modal { background: transparent; }
:root[data-theme="dark"] .mk-qr-modal-backdrop { background: rgba(0,0,0,0.65); }
:root[data-theme="dark"] .mk-qr-modal-dialog { box-shadow: 0 20px 60px rgba(0,0,0,0.7); }
:root[data-theme="dark"] .mk-qr-modal-close { color: var(--mk-muted); }
:root[data-theme="dark"] .mk-qr-modal-close:hover { color: var(--mk-accent-deep); }
:root[data-theme="dark"] .mk-qr-url-input { background: var(--mk-paper-2); color: var(--mk-ink-2); border-color: var(--mk-line); }
:root[data-theme="dark"] .mk-staff-thumb-info strong { color: var(--mk-ink); }
:root[data-theme="dark"] .mk-staff-thumb-main { background: var(--mk-accent-soft); border-color: var(--mk-accent); }
