/* Kuyumcu Panelim — panelin telefondaki uygulama görünümü (mobile.js ile birlikte) */
/* Açılış ekranı: panel tamamen hazır olana kadar yalnızca logo görünür */
#kpm-boot { position: fixed; inset: 0; z-index: 2147483000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; background: #070b13; transition: opacity .3s ease; }
html.theme-light #kpm-boot { background: #f2f4f8; }
#kpm-boot.is-done { opacity: 0; pointer-events: none; }
#kpm-boot img { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 14px 40px rgba(219,156,33,.28); animation: kpmBreath 1.6s ease-in-out infinite; }
#kpm-boot i { position: relative; display: block; width: 92px; height: 3px; border-radius: 3px; overflow: hidden; background: rgba(240,173,43,.18); }
#kpm-boot i::after { content: ''; position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; border-radius: 3px; background: #f0ad2b; animation: kpmBar 1.1s ease-in-out infinite; }
@keyframes kpmBreath { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes kpmBar { to { left: 100%; } }
.kpm-appbar, .kpm-tabbar, .kpm-sheet { display: none; }

@media (max-width: 768px) {
    :root {
        --kpm-bg: #070b13;
        --kpm-surface: #0f1625;
        --kpm-surface-2: #151e30;
        --kpm-line: rgba(255, 255, 255, .07);
        --kpm-text: #f1f5f9;
        --kpm-muted: #8b98ad;
        --kpm-gold: #f0ad2b;
        --kpm-gold-ink: #1a1405;
        --kpm-bar: rgba(10, 15, 25, .86);
        --kpm-tabbar-h: 64px;
        --kpm-safe-b: env(safe-area-inset-bottom, 0px);
    }
    body.theme-light {
        --kpm-bg: #f2f4f8;
        --kpm-surface: #ffffff;
        --kpm-surface-2: #f6f7fa;
        --kpm-line: rgba(15, 23, 42, .08);
        --kpm-text: #0f172a;
        --kpm-muted: #64748b;
        --kpm-gold: #db9c21;
        --kpm-bar: rgba(255, 255, 255, .9);
    }
    html.kpm-lock, html.kpm-lock body { overflow: hidden; }
    /* Uygulama gibi: iki parmakla yakınlaştırma ve yana kayma yok (yatay taşma kırpılır, yapışık üst çubuk bozulmaz) */
    html:has(body.kp-m), body.kp-m { overflow: hidden; height: var(--kpm-app-h, 100%); min-height: var(--kpm-app-h, 100dvh); max-height: var(--kpm-app-h, 100dvh); max-width: 100%; touch-action: pan-x pan-y; }
    body.kp-m .db-tab-content { max-width: 100vw; overflow-x: clip; }
    body.kp-m { background: var(--kpm-bg) !important; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }

    /* Sayfanın kendisi kaymaz, yalnızca içerik alanı kayar (yerel uygulama gibi; iOS ana ekran uygulamasında
       saat satırının altındaki kenar bulanıklığı da böylece oluşmaz) */
    body.kp-m #dashboard-page, body.kp-m #demo-page { display: block; position: fixed; top: 0; left: 0; right: 0; height: var(--kpm-app-h, 100%); min-height: var(--kpm-app-h, 100dvh); max-height: var(--kpm-app-h, 100dvh); overflow: hidden; background: var(--kpm-bg) !important; }
    body.kp-m .db-main { display: block; position: absolute; top: 0; left: 0; right: 0; height: 100%; min-height: 0; padding-top: var(--kpm-appbar-h, 72px); overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; background: var(--kpm-bg) !important; padding-bottom: calc(var(--kpm-tabbar-h) + var(--kpm-safe-b) + 16px); }
    body.kp-m .db-sidebar, body.kp-m .db-header, body.kp-m .floating-theme-switch, body.kp-m .scroll-to-top { display: none !important; }
    /* Açılışta: üst ve alt çubuk kurulana kadar içerik gizli, sonra tek seferde belirir */
    body.kp-m #dashboard-page, body.kp-m #demo-page { transition: opacity .2s ease; }
    body.kp-m:not(.kpm-ready) #dashboard-page, body.kp-m:not(.kpm-ready) #demo-page { opacity: 0; }
    body.kp-m:not(.kpm-ready) .kpm-tabbar, body.kp-m:not(.kpm-ready) .kpm-appbar { visibility: hidden; }

    /* Üst çubuk */
    body.kp-m .kpm-appbar {
        display: flex; align-items: center; gap: 10px;
        position: absolute; top: 0; left: 0; right: 0; z-index: 900;
        padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
        background: var(--kpm-bg);
        border-bottom: 1px solid var(--kpm-line);
    }
    /* Ana ekran uygulamasında iOS saat satırının hemen altını yumuşak bulanıklaştırıyor; yazılar bu şeridin altında başlar */
    @media (display-mode: standalone) { body.kp-m .kpm-appbar { padding-top: calc(env(safe-area-inset-top, 0px) + 26px); } }
    .kpm-appbar__title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
    .kpm-appbar__store { font-size: 11.5px; font-weight: 600; color: var(--kpm-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .kpm-appbar__title strong { font-size: 21px; font-weight: 800; letter-spacing: -.02em; color: var(--kpm-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .kpm-live { width: 30px; height: 30px; display: grid; place-items: center; }
    .kpm-live i { width: 9px; height: 9px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 0 rgba(16,185,129,.55); animation: kpmPulse 2s infinite; }
    .kpm-live.is-stale i { background: #f43f5e; animation: none; }
    @keyframes kpmPulse { 0% { box-shadow: 0 0 0 0 rgba(16,185,129,.5); } 70% { box-shadow: 0 0 0 9px rgba(16,185,129,0); } 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); } }
    .kpm-icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--kpm-text); background: var(--kpm-surface-2); border: 1px solid var(--kpm-line); }
    .kpm-icon-btn svg { width: 20px; height: 20px; }
    .kpm-avatar { width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center; font: inherit; font-size: 14px; font-weight: 800; color: var(--kpm-gold-ink); background: linear-gradient(135deg, #f0ad2b, #db9c21); cursor: pointer; flex: 0 0 auto; }
    .kpm-avatar--lg { width: 54px; height: 54px; font-size: 18px; }

    /* Alt sekme çubuğu */
    body.kp-m .kpm-tabbar {
        display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: stretch;
        position: absolute; left: 0; right: 0; bottom: 0; z-index: 990;
        height: calc(var(--kpm-tabbar-h) + var(--kpm-safe-b)); padding-bottom: var(--kpm-safe-b);
        background: var(--kpm-bar); backdrop-filter: saturate(160%) blur(18px); -webkit-backdrop-filter: saturate(160%) blur(18px);
        border-top: 1px solid var(--kpm-line);
    }
    .kpm-tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px 2px 4px; border: 0; background: none; color: var(--kpm-muted); font: inherit; font-size: 10.5px; font-weight: 700; letter-spacing: .01em; cursor: pointer; }
    .kpm-tab svg { width: 23px; height: 23px; margin: 0 !important; }
    .kpm-tab span { white-space: nowrap; }
    .kpm-tab.is-active { color: var(--kpm-gold); }
    .kpm-tab.is-active::before { content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--kpm-gold); }
    .kpm-tab--scan { color: var(--kpm-text); }
    .kpm-scan-ring { width: 52px; height: 52px; margin-top: -24px; display: grid; place-items: center; border-radius: 18px; background: linear-gradient(135deg, #f0ad2b, #db9c21); color: var(--kpm-gold-ink); box-shadow: 0 8px 22px rgba(219,156,33,.45), 0 0 0 5px var(--kpm-bg); }
    .kpm-scan-ring svg { width: 26px; height: 26px; }
    .kpm-tab:active { transform: scale(.94); }
    .kpm-tab:focus, .kpm-tile:focus, .kpm-row:focus, .kpm-seg:focus { outline: none; }

    /* Alttan açılan sayfa (menü, hesap) */
    body.kp-m .kpm-sheet { display: block; position: absolute; inset: 0; z-index: 980; pointer-events: none; }
    .kpm-sheet__backdrop { position: absolute; inset: 0; background: rgba(2, 6, 14, .55); opacity: 0; transition: opacity .25s ease; }
    .kpm-sheet__panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 86vh; overflow-y: auto; padding: 8px 18px calc(var(--kpm-tabbar-h) + var(--kpm-safe-b) + 18px); background: var(--kpm-surface); border-radius: 24px 24px 0 0; box-shadow: 0 -16px 40px rgba(0,0,0,.3); transform: translateY(100%); transition: transform .3s cubic-bezier(.2, .9, .3, 1); }
    body.kp-m .kpm-sheet.is-open { pointer-events: auto; }
    .kpm-sheet.is-open .kpm-sheet__backdrop { opacity: 1; }
    .kpm-sheet.is-open .kpm-sheet__panel { transform: none; }
    .kpm-sheet__grip { width: 40px; height: 5px; margin: 4px auto 14px; border-radius: 3px; background: var(--kpm-line); background: rgba(148,163,184,.4); }
    .kpm-sheet__title { margin: 0 4px 14px; font-size: 18px; font-weight: 800; color: var(--kpm-text); }
    .kpm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .kpm-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 92px; padding: 12px 6px; border-radius: 18px; border: 1px solid var(--kpm-line); background: var(--kpm-surface-2); color: var(--kpm-text); font: inherit; font-size: 12.5px; font-weight: 700; text-align: center; cursor: pointer; }
    .kpm-tile svg { width: 26px; height: 26px; margin: 0 !important; color: var(--kpm-gold); }
    .kpm-tile.is-active { border-color: var(--kpm-gold); background: rgba(240,173,43,.1); }
    .kpm-tile:active, .kpm-row:active { transform: scale(.97); }
    .kpm-theme { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; padding: 14px 4px 0; border-top: 1px solid var(--kpm-line); color: var(--kpm-muted); font-size: 13.5px; font-weight: 700; }
    .kpm-segs { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--kpm-surface-2); border: 1px solid var(--kpm-line); }
    .kpm-seg { display: inline-flex; align-items: center; gap: 6px; padding: 8px 11px; border: 0; border-radius: 9px; background: none; color: var(--kpm-muted); font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; }
    .kpm-seg svg { width: 15px; height: 15px; }
    .kpm-seg.is-active { background: var(--kpm-surface); color: var(--kpm-text); box-shadow: 0 1px 4px rgba(0,0,0,.18); }
    .kpm-account { display: flex; align-items: center; gap: 14px; padding: 4px 4px 18px; }
    .kpm-account strong { display: block; font-size: 17px; color: var(--kpm-text); }
    .kpm-account small { display: block; margin-top: 2px; font-size: 13px; color: var(--kpm-muted); word-break: break-all; }
    .kpm-list { display: flex; flex-direction: column; gap: 8px; }
    .kpm-row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--kpm-line); background: var(--kpm-surface-2); color: var(--kpm-text); font: inherit; font-size: 15px; font-weight: 700; text-align: left; cursor: pointer; }
    a.kpm-row { text-decoration: none; }
    .kpm-row svg { width: 20px; height: 20px; margin: 0 !important; color: var(--kpm-gold); }
    .kpm-row.is-danger, .kpm-row.is-danger svg { color: #f43f5e; }

    /* İçerik: kenar boşlukları, kartlar, başlıklar */
    body.kp-m .db-tab-content { padding: 16px 14px 8px; animation: kpmIn .22s ease-out; }
    @keyframes kpmIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
    body.kp-m .db-card { border-radius: 18px; padding: 0; }
    body.kp-m .db-card__header { padding: 16px 16px 0; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
    body.kp-m .db-card__body { padding: 0 16px 16px; }
    body.kp-m .db-card__body.no-padding { padding: 0 12px 12px; }
    body.kp-m .db-card__title { font-size: 16.5px; }
    body.kp-m .db-dashboard-grid, body.kp-m .db-grid-2, body.kp-m .db-settings-grid { gap: 14px; }
    body.kp-m .db-prices-grid { gap: 12px; }
    body.kp-m .db-price-card { border-radius: 18px; padding: 16px; }
    body.kp-m .db-stats-grid, body.kp-m .kp-mini-stats { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
    body.kp-m .db-stat-card { padding: 14px !important; border-radius: 16px; min-width: 0; }
    body.kp-m .db-stat-card__icon { display: none; }
    body.kp-m .db-stat-card__val { font-size: 18px !important; word-break: break-word; }
    body.kp-m .db-stat-card__label { font-size: 11.5px; }
    body.kp-m .kp-trial-banner { padding: 10px 14px; font-size: 12.5px; flex-direction: row; align-items: center; }
    body.kp-m .kp-trial-banner__cta { padding: 8px 12px; }
    body.kp-m #db-broadcast-banner { padding: 10px 14px !important; }

    /* Arama ve işlem çubukları */
    body.kp-m .db-action-bar { gap: 10px; margin-bottom: 14px; }
    body.kp-m .db-search-wrapper input, body.kp-m .db-action-bar input { min-height: 46px; border-radius: 14px; }
    body.kp-m .db-search-wrapper, body.kp-m .db-search-wrapper input, body.kp-m .db-action-bar > input, body.kp-m .db-action-bar > select { width: 100% !important; max-width: none !important; flex: 1 1 100%; }
    body.kp-m .kp-btn-row { gap: 8px; }
    body.kp-m .kp-btn-row .lp-btn { flex: 1 1 calc(50% - 8px); min-height: 46px; justify-content: center; border-radius: 14px; font-size: 13.5px; }

    /* Dokunma alanları ve form alanları (iOS yakınlaştırmasın diye 16px) */
    body.kp-m .lp-btn { min-height: 46px; border-radius: 14px; }
    body.kp-m input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), body.kp-m select, body.kp-m textarea { font-size: 16px !important; min-height: 46px; border-radius: 12px; }
    body.kp-m textarea { min-height: 90px; }
    body.kp-m .btn-table-action { min-height: 38px; padding: 8px 12px !important; font-size: 12.5px !important; border-radius: 10px; }

    /* Tablolar → kartlar */
    /* Kart listesi olan bölümlerde dış çerçeve kalkar, satırlar kendi kartı olur */
    body.kp-m .db-card:has(table.kpm-cards) { background: none !important; border: 0 !important; box-shadow: none !important; backdrop-filter: none; }
    body.kp-m .db-card:has(table.kpm-cards) > .db-card__header { padding: 4px 2px 0; }
    body.kp-m .db-card:has(table.kpm-cards) .db-card__body, body.kp-m .db-card:has(table.kpm-cards) .db-card__body.no-padding { padding: 0; }
    body.kp-m .db-table-wrapper, body.kp-m .overflow-x { overflow: visible; margin: 0; padding: 0; width: auto; }
    body.kp-m table.kpm-cards { min-width: 0 !important; width: 100%; border-collapse: separate; border-spacing: 0; background: none !important; }
    body.kp-m table.kpm-cards thead { display: none; }
    body.kp-m table.kpm-cards tbody { display: flex; flex-direction: column; gap: 10px; }
    body.kp-m table.kpm-cards tr { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; padding: 14px 16px; border-radius: 16px; background: var(--kpm-surface-2) !important; border: 1px solid var(--kpm-line); }
    body.kp-m table.kpm-cards td { display: flex; flex-direction: column; gap: 2px; padding: 6px 0 !important; border: 0 !important; background: none !important; text-align: left !important; font-size: 14px !important; min-width: 0; word-break: break-word; }
    body.kp-m table.kpm-cards td::before { content: attr(data-label); font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--kpm-muted); }
    body.kp-m table.kpm-cards td[data-label=""]::before { display: none; }
    body.kp-m table.kpm-cards td.kpm-cell-title { grid-column: 1 / -1; padding-top: 0 !important; font-size: 16px !important; font-weight: 700; }
    body.kp-m table.kpm-cards td.kpm-cell-title::before { display: none; }
    body.kp-m table.kpm-cards td.kpm-cell-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; gap: 8px; padding-top: 10px !important; margin-top: 4px; border-top: 1px solid var(--kpm-line) !important; }
    body.kp-m table.kpm-cards td.kpm-cell-actions::before { display: none; }
    body.kp-m table.kpm-cards td.kpm-cell-actions .cell-action { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
    body.kp-m table.kpm-cards td.kpm-cell-actions .btn-table-action, body.kp-m table.kpm-cards td.kpm-cell-actions .lp-btn { flex: 1 1 auto; justify-content: center; }
    body.kp-m table.kpm-cards td.kpm-cell-blank { display: none; }
    body.kp-m table.kpm-cards td.kp-col-check { grid-column: 1 / -1; flex-direction: row; align-items: center; padding: 0 !important; width: auto; }
    body.kp-m table.kpm-cards td.kp-col-check::before { display: none; }
    body.kp-m table.kpm-cards tr.kpm-empty { display: block; text-align: center; }
    body.kp-m table.kpm-cards tr.kpm-empty td { display: block; text-align: center !important; color: var(--kpm-muted); }
    body.kp-m table.kpm-cards tr.kpm-empty td::before { display: none; }
    body.kp-m table.kpm-cards tr:hover td { background: none !important; }
    body.kp-m.theme-light table.kpm-cards td { color: #334155 !important; }
    body.kp-m.theme-light table.kpm-cards td.kpm-cell-title { color: #0f172a !important; }

    /* Pencereler alttan açılan sayfa gibi */
    body.kp-m .kpd-overlay { align-items: flex-end !important; padding: 0 !important; }
    body.kp-m .kpd-overlay.is-form { overflow-y: auto; }
    body.kp-m .kpd-box { width: 100% !important; max-width: none !important; margin: auto 0 0 !important; border-radius: 24px 24px 0 0 !important; padding-bottom: 0 !important; transform: translateY(40px); max-height: none; }
    body.kp-m .kpd-box::before { content: ''; display: block; width: 40px; height: 5px; margin: -6px auto 12px; border-radius: 3px; background: rgba(148,163,184,.45); }
    body.kp-m .kpd-overlay.is-open .kpd-box { transform: none; }
    body.kp-m .kpd-actions { position: sticky; bottom: 0; z-index: 2; flex-direction: row; padding: 14px 18px calc(14px + var(--kpm-safe-b)); background: var(--kpd-bg); border-top: 1px solid var(--kpd-line); }
    body.kp-m .kpd-actions .kpd-btn { width: auto; }
    body.kp-m .kpd-actions .kpd-btn { flex: 1 1 0; min-height: 50px; font-size: 15px; border-radius: 14px; }
    body.kp-m .db-modal-overlay { align-items: flex-end; padding: 0; }
    body.kp-m .db-modal { max-width: none; border-radius: 24px 24px 0 0; max-height: 92vh; overflow-y: auto; transform: translateY(40px); }
    body.kp-m .db-modal-overlay.active .db-modal { transform: none; }
    body.kp-m .db-modal__footer { position: sticky; bottom: 0; padding-bottom: calc(16px + var(--kpm-safe-b)); background: inherit; }

    /* Bildirimler alt çubuğun üstünde */
    body.kp-m .toast-container { left: 12px; right: 12px; bottom: calc(var(--kpm-tabbar-h) + var(--kpm-safe-b) + 12px); align-items: stretch; }
    body.kp-m .toast { width: 100%; max-width: none; border-radius: 14px; }

    /* Demo şeridi ve çerez penceresi alt çubukla çakışmasın */
    body.kp-m .db-demo-banner { margin: 0; border-radius: 0; position: static; }
    body.kp-m #kp-cookie-consent, body.kp-m .cookie-consent { bottom: calc(var(--kpm-tabbar-h) + var(--kpm-safe-b) + 10px) !important; }
}
