/* wpDataTables Master-Detail (self-built) — buttons, modal, detail layout, child table */

/* ---- per-row details button ---------------------------------------------- */
.wpdt-md-btn {
    display: inline-block;
    background: #2563eb;
    color: #fff;
    border: 1px solid #2563eb;
    border-radius: 999px;
    padding: 5px 16px;
    font-size: 13px;
    line-height: 1.4;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .15s ease, box-shadow .15s ease;
}
.wpdt-md-btn:hover { background: #1d4fd7; box-shadow: 0 2px 8px rgba(37,99,235,.3); }
.wpdt-md-btn:active { transform: translateY(1px); }

/* ---- row-click affordance ------------------------------------------------- */
table.wpDataTable.wpdt-md-rowmode tbody tr { cursor: pointer; }
table.wpDataTable.wpdt-md-rowmode tbody tr:hover > td { background: #eef4ff !important; }

/* ---- mode switcher (demo affordance) ------------------------------------- */
.wpdt-md-switcher {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 22px;
    padding: 10px 14px;
    margin: 0 0 14px;
    background: #f3f6fb;
    border: 1px solid #dde6f1;
    border-radius: 6px;
    font-size: 13px;
}
.wpdt-md-sw-group { display: inline-flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; }
.wpdt-md-sw-label { font-weight: 600; color: #344050; }
.wpdt-md-sw-opt { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; color: #28456f; }
.wpdt-md-sw-opt input { margin: 0; cursor: pointer; }
.wpdt-md-sw-hint { color: #6b7785; font-size: 12px; flex-basis: 100%; }

/* ---- shared modal --------------------------------------------------------- */
.wpdt-md-modal {
    position: fixed;
    inset: 0;
    z-index: 100050;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 4vh 16px;
    overflow-y: auto;
}
.wpdt-md-modal[hidden] { display: none; }
.wpdt-md-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); animation: wpdtmdFade .15s ease; }
@keyframes wpdtmdFade { from { opacity: 0 } to { opacity: 1 } }
@keyframes wpdtmdPop { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: none } }

.wpdt-md-dialog {
    position: relative;
    background: #fff;
    border-radius: 10px;
    width: 100%;
    max-width: 760px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .35);
    animation: wpdtmdPop .18s ease;
    margin: auto 0;
}

/* ---- detail header (shared by modal + page) ------------------------------ */
.wpdt-md-head,
.wpdt-md-page-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #e9edf2;
}
.wpdt-md-title { margin: 0; font-size: 19px; font-weight: 700; color: #1f2d3d; flex: 1 1 auto; line-height: 1.3; }
.wpdt-md-head-actions { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.wpdt-md-counter { font-size: 12px; color: #6b7785; padding: 0 4px; white-space: nowrap; }

.wpdt-md-nav,
.wpdt-md-copy,
.wpdt-md-print,
.wpdt-md-back {
    background: #f1f4f8;
    border: 1px solid #d7dee7;
    color: #34506f;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .15s ease;
}
.wpdt-md-nav:hover,
.wpdt-md-copy:hover,
.wpdt-md-print:hover,
.wpdt-md-back:hover { background: #e4eaf2; }
.wpdt-md-disabled, .wpdt-md-nav:disabled { opacity: .4; cursor: not-allowed; }
.wpdt-md-copy.wpdt-md-done { background: #2f9e58; border-color: #2f9e58; color: #fff; }
.wpdt-md-close {
    background: transparent;
    border: 0;
    font-size: 26px;
    line-height: 1;
    color: #8a96a3;
    cursor: pointer;
    padding: 0 4px;
}
.wpdt-md-close:hover { color: #1f2d3d; }

/* ---- detail body / field rows -------------------------------------------- */
.wpdt-md-body { padding: 18px 22px 22px; }
.wpdt-md-fields { display: block; }
.wpdt-md-field {
    display: grid;
    grid-template-columns: 132px 1fr;
    gap: 10px 18px;
    align-items: start;
    padding: 11px 0;
    border-bottom: 1px solid #f0f2f5;
}
.wpdt-md-field:last-child { border-bottom: 0; }
.wpdt-md-flabel { color: #6b7785; font-size: 13px; padding-top: 2px; }
.wpdt-md-fvalue { color: #1f2d3d; font-size: 15px; word-break: break-word; }
.wpdt-md-emph .wpdt-md-fvalue { font-size: 18px; font-weight: 700; }

.wpdt-md-img { max-width: 100%; width: 480px; max-height: 320px; object-fit: cover; border-radius: 8px; display: block; background: #f3f5f8; }
.wpdt-md-money { font-weight: 600; color: #d4380d; }
.wpdt-md-strike { color: #98a2b3; font-weight: 400; text-decoration: line-through; }
.wpdt-md-pct { font-weight: 600; color: #2563eb; }
.wpdt-md-link {
    display: inline-block; background: #2563eb; color: #fff !important; text-decoration: none;
    border-radius: 6px; padding: 6px 14px; font-size: 14px;
}
.wpdt-md-link:hover { background: #1d4fd7; }

.wpdt-md-stars { position: relative; display: inline-block; vertical-align: middle; }
.wpdt-md-stars-bg { position: relative; display: inline-block; color: #d7dde5; letter-spacing: 2px; font-size: 16px; }
.wpdt-md-stars-fg { position: absolute; left: 0; top: 0; overflow: hidden; white-space: nowrap; color: #f5a623; }
.wpdt-md-stars-num { margin-left: 8px; color: #6b7785; font-size: 13px; vertical-align: middle; }

.wpdt-md-badge {
    display: inline-block; border-radius: 999px; padding: 2px 11px; font-size: 13px; line-height: 1.5;
    background: #eef4ff; color: #28456f; border: 1px solid #cfe0ff;
}
.wpdt-md-badge-ok   { background: #e7f7ed; color: #1d6f3e; border-color: #b6e6c8; }
.wpdt-md-badge-bad  { background: #fdeceb; color: #b42318; border-color: #f6cdc9; }
.wpdt-md-badge-warn { background: #fff6e6; color: #8a5a00; border-color: #ffe0a6; }
.wpdt-md-badge-info { background: #eef4ff; color: #28456f; border-color: #cfe0ff; }

.wpdt-md-bool { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.wpdt-md-bool::before { content: ''; width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.wpdt-md-bool-on  { color: #1d6f3e; }
.wpdt-md-bool-on::before  { background: #2f9e58; }
.wpdt-md-bool-off { color: #98a2b3; }
.wpdt-md-bool-off::before { background: #c4ccd6; }

/* ---- embedded child table ------------------------------------------------ */
.wpdt-md-child { margin-top: 20px; border-top: 2px solid #eef0f3; padding-top: 14px; }
.wpdt-md-child-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.wpdt-md-child-title { font-size: 15px; font-weight: 700; color: #1f2d3d; flex: 1 1 auto; }
.wpdt-md-child-tools { display: inline-flex; gap: 8px; align-items: center; }
.wpdt-md-child-search { border: 1px solid #d7dee7; border-radius: 6px; padding: 5px 10px; font-size: 13px; min-width: 150px; }
.wpdt-md-child-csv {
    background: transparent; border: 1px solid #b6bec8; color: #4f6781;
    border-radius: 6px; padding: 5px 11px; font-size: 12px; cursor: pointer;
}
.wpdt-md-child-csv:hover { background: #eef2f6; }
.wpdt-md-child-note {
    color: #8a5a00;
    background: #fff8ec;
    border: 1px solid #ffe0a6;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12.5px;
    line-height: 1.5;
    margin: 0 0 10px;
}
.wpdt-md-child-empty { color: #6b7785; font-size: 14px; padding: 16px; background: #f7f9fb; border-radius: 6px; text-align: center; }
.wpdt-md-child-scroll { overflow-x: auto; border: 1px solid #e9edf2; border-radius: 8px; }
.wpdt-md-child-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.wpdt-md-child-table th {
    background: #2563eb; color: #fff; text-align: left; padding: 9px 12px; font-weight: 600; white-space: nowrap;
}
.wpdt-md-child-table td { padding: 8px 12px; border-top: 1px solid #eef0f3; color: #2b3949; }
.wpdt-md-child-table tbody tr:nth-child(even) td { background: #f8fafc; }
.wpdt-md-child-table tbody tr:hover td { background: #eef4ff; }
.wpdt-md-child-table .wpdt-md-col-money,
.wpdt-md-child-table .wpdt-md-col-num { text-align: right; white-space: nowrap; }
.wpdt-md-child-table tfoot td { padding: 9px 12px; border-top: 2px solid #d7dee7; background: #f3f6fb; color: #1f2d3d; }
.wpdt-md-child-table tfoot .wpdt-md-col-money,
.wpdt-md-child-table tfoot .wpdt-md-col-num { text-align: right; }
.wpdt-md-child-total-label { font-weight: 700; }

/* ---- page (full-panel) display mode -------------------------------------- */
.wpdt-md-page {
    background: #fff;
    border: 1px solid #e9edf2;
    border-radius: 10px;
    box-shadow: 0 4px 18px rgba(15, 23, 42, .08);
    margin: 0 0 18px;
    animation: wpdtmdPop .18s ease;
    scroll-margin-top: 90px;   /* clear the theme's sticky header when scrollIntoView aligns the panel */
}
.wpdt-md-page[hidden] { display: none; }
.wpdt-md-page-bar { border-bottom: 1px solid #e9edf2; }
.wpdt-md-page-counter { font-size: 12px; color: #6b7785; }
.wpdt-md-page-title { margin: 0; padding: 14px 22px 0; font-size: 21px; font-weight: 700; color: #1f2d3d; }
.wpdt-md-page .wpdt-md-back { font-weight: 600; flex: 0 0 auto; }
.wpdt-md-page .wpdt-md-page-bar { justify-content: space-between; }

/* ---- responsive ----------------------------------------------------------- */
@media (max-width: 600px) {
    .wpdt-md-field { grid-template-columns: 1fr; gap: 3px; padding: 9px 0; }
    .wpdt-md-flabel { font-size: 12px; }
    .wpdt-md-head, .wpdt-md-page-bar { flex-wrap: wrap; }
    .wpdt-md-head-actions { flex-wrap: wrap; }
    .wpdt-md-img { width: 100%; }
}

/* ---- custom template mode (display='template') --------------------------- */
.wpdt-md-template { display: block; }

/* product-card layout (table 18) */
.wpdt-md-card { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.wpdt-md-card-media { flex: 0 0 auto; }
.wpdt-md-card-media .wpdt-md-img { width: 360px; max-width: 100%; }
.wpdt-md-card-info { flex: 1 1 320px; min-width: 280px; }
.wpdt-md-card-cat { margin-bottom: 6px; }
.wpdt-md-card-name { margin: 0 0 12px; font-size: 22px; font-weight: 700; color: #1f2d3d; }
.wpdt-md-card-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.wpdt-md-card-price .wpdt-md-money { font-size: 24px; }
.wpdt-md-card-old { color: #98a2b3; text-decoration: line-through; }
.wpdt-md-card-old .wpdt-md-money { color: #98a2b3; font-weight: 400; font-size: 16px; }
.wpdt-md-card-save { background: #fff1f0; color: #d4380d; border: 1px solid #ffd5cd; border-radius: 4px; padding: 1px 8px; font-size: 13px; font-weight: 600; }
.wpdt-md-card-rating { margin-bottom: 16px; }
.wpdt-md-card-spec { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.wpdt-md-card-spec th, .wpdt-md-card-spec td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #f0f2f5; font-size: 14px; }
.wpdt-md-card-spec th { color: #6b7785; font-weight: 500; width: 120px; white-space: nowrap; }
.wpdt-md-card-spec td { color: #1f2d3d; }
.wpdt-md-card-actions { margin-top: 4px; }

/* region template with embedded child table (table 19) */
.wpdt-md-tpl-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.wpdt-md-tpl-kpi { background: #f7f9fc; border: 1px solid #e7edf5; border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.wpdt-md-tpl-kpi-label { color: #6b7785; font-size: 12px; }
.wpdt-md-tpl-kpi-val { color: #1f2d3d; font-size: 19px; font-weight: 700; }
.wpdt-md-tpl-kpi-val .wpdt-md-money, .wpdt-md-tpl-kpi-val .wpdt-md-pct { font-size: 19px; }
.wpdt-md-tpl-h { margin: 0 0 12px; font-size: 16px; font-weight: 700; color: #1f2d3d; }

/* ---- copy button feedback (success / failure) ---------------------------- */
.wpdt-md-copy.wpdt-md-fail { background: #fff1f0; border-color: #ffccc7; color: #cf1322; }

/* ---- transient toast (failed deep-link restore) -------------------------- */
.wpdt-md-toast {
    position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px);
    background: #1f2d3d; color: #fff; padding: 10px 18px; border-radius: 8px;
    font-size: 14px; line-height: 1.4; max-width: 80vw; box-shadow: 0 6px 24px rgba(0,0,0,.25);
    opacity: 0; transition: opacity .25s ease, transform .25s ease; z-index: 100001; pointer-events: none;
}
.wpdt-md-toast.wpdt-md-toast-in { opacity: 1; transform: translate(-50%, 0); }

/* ---- body scroll lock while modal open ----------------------------------- */
body.wpdt-md-open { overflow: hidden; }

/* ---- print: isolate the open detail (works for BOTH popup and page mode) --- */
/* The JS clones the open detail into #wpdt-md-print-host (a direct <body> child) so a single
   display rule isolates it from page 1 — robust even though the page-mode panel is nested deep
   in the content, where a position-based approach would render onto a later/blank sheet. */
#wpdt-md-print-host { display: none; }
@media print {
    html.wpdt-md-printing body > *:not(#wpdt-md-print-host) { display: none !important; }
    html.wpdt-md-printing #wpdt-md-print-host { display: block !important; }
    #wpdt-md-print-host .wpdt-md-head-actions,
    #wpdt-md-print-host .wpdt-md-page-bar,
    #wpdt-md-print-host .wpdt-md-back,
    #wpdt-md-print-host .wpdt-md-child-tools,
    #wpdt-md-print-host .wpdt-md-backdrop { display: none !important; }
    #wpdt-md-print-host .wpdt-md-dialog,
    #wpdt-md-print-host .wpdt-md-page { box-shadow: none !important; max-width: none !important; border: 0 !important; }
}
