/* ============================================================
   PARAMETER DRAWER — Premium right-side slide-out panel
   ============================================================ */

/* ---- Overlay ---- */
.pd-overlay {
    position: fixed; inset: 0; z-index: 9998;
    background: rgba(15,23,42,.45);
    backdrop-filter: blur(2px);
    opacity: 0; visibility: hidden;
    transition: opacity .3s ease, visibility .3s ease;
}
.pd-overlay.active { opacity: 1; visibility: visible; }

/* ---- Drawer Shell ---- */
.pd-drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    z-index: 9999;
    width: 440px; max-width: 100%;
    background: #fff;
    box-shadow: -8px 0 30px rgba(0,0,0,.12);
    display: flex; flex-direction: column;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.32,.72,.24,1);
}
.pd-drawer.open { transform: translateX(0); }

/* ---- Sticky Header ---- */
.pd-header {
    padding: 20px 24px 0;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
    background: #fff;
    position: sticky; top: 0; z-index: 2;
}
.pd-header-row {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 14px;
}
.pd-title {
    font-size: 20px; font-weight: 700; color: #0f172a;
    line-height: 1.3; margin: 0;
}
.pd-subtitle {
    font-size: 13px; color: #64748b; margin: 2px 0 0; font-weight: 400;
}
.pd-close {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: #f1f5f9; border: none; cursor: pointer;
    color: #475569; font-size: 20px;
    transition: background .15s, color .15s;
    flex-shrink: 0; margin-left: 12px;
}
.pd-close:hover { background: #e2e8f0; color: #0f172a; }

/* ---- Search ---- */
.pd-search-wrap {
    position: relative;
    padding: 12px 24px 14px;
    background: #fff;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}
.pd-search-wrap i {
    position: absolute; left: 38px; top: 50%; transform: translateY(-50%);
    color: #94a3b8; font-size: 18px; pointer-events: none;
}
.pd-search {
    width: 100%; height: 42px;
    border: 1.5px solid #e2e8f0; border-radius: 10px;
    padding: 0 14px 0 40px;
    font-size: 14px; color: #1e293b;
    background: #f8fafc;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.pd-search:focus {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13,148,136,.1);
    background: #fff;
}
.pd-search::placeholder { color: #94a3b8; }
.pd-search-clear {
    position: absolute; right: 38px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer;
    color: #94a3b8; font-size: 17px; display: none; padding: 4px;
}
.pd-search-clear.show { display: block; }

/* Match count */
.pd-match-count {
    font-size: 12px; color: #64748b;
    padding: 6px 24px 0; display: none;
}
.pd-match-count.show { display: block; }

/* ---- Scrollable Body ---- */
.pd-body {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    padding: 8px 0;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}
.pd-body::-webkit-scrollbar { width: 5px; }
.pd-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* ---- Accordion Group ---- */
.pd-group { border-bottom: 1px solid #f1f5f9; }
.pd-group:last-child { border-bottom: none; }

.pd-group-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px;
    cursor: pointer;
    user-select: none;
    transition: background .15s;
}
.pd-group-header:hover { background: #f8fafc; }

.pd-group-name {
    font-size: 15px; font-weight: 600; color: #1e293b;
    display: flex; align-items: center; gap: 8px;
}
.pd-group-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 26px; height: 22px; padding: 0 7px;
    border-radius: 11px;
    background: #f0fdfa; color: #0d9488;
    font-size: 12px; font-weight: 600;
}
.pd-group-chevron {
    font-size: 20px; color: #94a3b8;
    transition: transform .25s ease;
    flex-shrink: 0;
}
.pd-group.open .pd-group-chevron { transform: rotate(180deg); }

/* ---- Parameter List ---- */
.pd-params {
    max-height: 0; overflow: hidden;
    transition: max-height .3s ease;
}
.pd-group.open .pd-params { max-height: 4000px; }

.pd-param {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 24px 10px 36px;
    transition: background .12s;
}
.pd-param:hover { background: #f8fafc; }

.pd-param-left {
    display: flex; align-items: center; gap: 10px;
    flex: 1; min-width: 0;
}
.pd-param-check {
    width: 22px; height: 22px; border-radius: 50%;
    background: #f0fdfa; color: #0d9488;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; flex-shrink: 0;
}
.pd-param-name {
    font-size: 14px; color: #334155; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pd-param-range {
    font-size: 12px; color: #94a3b8; font-weight: 400;
    white-space: nowrap; margin-left: 12px; flex-shrink: 0;
}

/* Highlight match */
.pd-param-name mark, .pd-group-name mark {
    background: #fef08a; color: #1e293b;
    border-radius: 2px; padding: 0 1px;
}

/* Separator between groups in list mode */
.pd-param + .pd-param { border-top: 1px solid #f8fafc; }

/* ---- Empty / No results ---- */
.pd-empty {
    text-align: center; padding: 48px 24px;
    color: #94a3b8;
}
.pd-empty i { font-size: 48px; margin-bottom: 12px; display: block; color: #cbd5e1; }
.pd-empty-title { font-size: 16px; font-weight: 600; color: #64748b; margin-bottom: 4px; }
.pd-empty-msg { font-size: 13px; }

/* ---- Sticky Footer CTA ---- */
.pd-footer {
    padding: 14px 24px;
    border-top: 1px solid #f1f5f9;
    background: #fff;
    flex-shrink: 0;
    display: flex; gap: 10px;
}
.pd-footer-btn {
    flex: 1; height: 46px;
    border: none; border-radius: 10px;
    font-size: 15px; font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    transition: background .15s, transform .1s;
}
.pd-footer-btn:active { transform: scale(.98); }
.pd-footer-btn.primary {
    background: #0d9488; color: #fff;
}
.pd-footer-btn.primary:hover { background: #0f766e; }
.pd-footer-btn.secondary {
    background: #f0fdfa; color: #0d9488; border: 1.5px solid #0d9488;
}
.pd-footer-btn.secondary:hover { background: #ccfbf1; }

/* ---- Skeleton Loader ---- */
.pd-skeleton { padding: 20px 24px; }
.pd-skel-row {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 16px;
}
.pd-skel-circle {
    width: 22px; height: 22px; border-radius: 50%;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: pdShimmer 1.5s infinite;
}
.pd-skel-line {
    height: 14px; border-radius: 7px; flex: 1;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: pdShimmer 1.5s infinite;
}
.pd-skel-line.short { max-width: 60%; }
@keyframes pdShimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ============ MOBILE (Bottom Sheet) ============ */
@media (max-width: 640px) {
    .pd-drawer {
        width: 100%; top: auto; bottom: 0;
        max-height: 92vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
    }
    .pd-drawer.open { transform: translateY(0); }

    /* Drag handle */
    .pd-drag-handle {
        display: flex !important;
        justify-content: center;
        padding: 10px 0 4px;
    }
    .pd-drag-handle span {
        width: 40px; height: 5px;
        background: #cbd5e1; border-radius: 3px;
    }

    .pd-header { padding: 12px 20px 0; }
    .pd-title { font-size: 18px; }
    .pd-search-wrap { padding: 10px 20px 12px; }
    .pd-group-header { padding: 12px 20px; }
    .pd-param { padding: 10px 20px 10px 30px; }
    .pd-footer { padding: 12px 20px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
@media (min-width: 641px) {
    .pd-drag-handle { display: none; }
}

/* ---- Body scroll lock ---- */
body.pd-open { overflow: hidden; }

/* ---- "View all parameters" button upgrade ---- */
.td-view-params-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 20px;
    border: 1.5px solid #0d9488; border-radius: 10px;
    background: #f0fdfa; color: #0d9488;
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    margin-top: 12px;
}
.td-view-params-btn:hover {
    background: #0d9488; color: #fff;
}
.td-view-params-btn i { font-size: 18px; }
