/* Playbooks list + detail pages. Functional, clean styling reusing the app's
   blue (#006dae) / orange (#e8762c) palette and card patterns. Visual polish
   comes in a later stage. */

#pbroot{ margin: 6px 0 60px; }

.pb-btn{
    border: 1px solid #c8cfd9;
    background: #fff;
    color: #1f5fa8;
    border-radius: 6px;
    padding: 7px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.pb-btn:hover{ background: #f0f3f8; }
.pb-btn-primary{ background: #006dae; border-color: #006dae; color: #fff; }
.pb-btn-primary:hover{ background: #045c92; }
.pbx-cancel{ border-color: transparent; background: none; color: #5b6470; }
.pbx-cancel:hover{ background: #f0f3f8; }

.pb-empty{
    background: #fff;
    border: 1px dashed #c8cfd9;
    border-radius: 10px;
    padding: 28px;
    text-align: center;
    color: #566;
    margin: 14px 0;
}

/* ---- list ---- */
.pb-listhead{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.pb-page-title{ font-size: 24px; font-weight: 700; color: #22303c; margin: 0; }

.pb-grid{
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.pb-card{
    position: relative;
    background: #fff;
    border: 1px solid #dfe4ea;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow .12s, border-color .12s;
    display: flex;
    flex-direction: column;
}
.pb-card:hover{ box-shadow: 0 4px 14px rgba(0,0,0,.10); border-color: #c3ccd6; }
.pb-card-saved{ border-color: #f0c9a8; }
.pb-card-thumb{
    aspect-ratio: 16 / 9;
    background: #f4f6f9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.pb-card-thumb .pbthumb, .pb-card-thumb img{ width: 100%; height: 100%; }
.pbthumb img{ width: 100%; height: 100%; object-fit: contain; display: block; }
.pbthumb-ph{ width: 100%; height: 100%; min-height: 90px; background: #eef1f5; }
.pb-card-body{ padding: 10px 12px 12px; }
.pb-card-name{ font-size: 16px; font-weight: 600; color: #22303c; display: flex; align-items: center; gap: 5px; }
.pb-card-name span{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-savedstar{ color: #e8762c; }
.pb-card-meta{ font-size: 13px; color: #6a7683; margin-top: 3px; }
.pb-card-tags{ margin-top: 8px; display: flex; gap: 6px; }
.pb-tag{ font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; letter-spacing: .02em; }
.pb-tag-play{ background: #e9f0f9; color: #26507e; border: 1px solid #d5e2f2; }
.pb-tag-drill{ background: #fdf0e6; color: #b25a1e; border: 1px solid #f4d6ba; }

.pb-kebab{
    position: absolute;
    top: 6px; right: 6px;
    width: 30px; height: 30px;
    border: none;
    border-radius: 6px;
    background: rgba(255,255,255,.85);
    color: #45525e;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.pb-kebab:hover{ background: #eef1f5; }

.pb-card-new{
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 150px;
    border: 2px dashed #c3ccd6;
    background: #fafbfc;
    color: #1f5fa8;
    font-weight: 600;
}
.pb-card-new:hover{ background: #f0f4f9; }
.pb-newic{ font-size: 26px; line-height: 1; }
.pb-card-placeholder{
    border: 2px dashed #9ab6d6;
    border-radius: 10px;
    background: #eef5fc;
}

#pbcardmenu{
    position: fixed;
    z-index: 1002;
    background: #fff;
    border: 1px solid #d3d9e0;
    border-radius: 8px;
    box-shadow: 0 6px 22px rgba(0,0,0,.16);
    min-width: 150px;
    padding: 4px;
}
.pb-menuitem{ padding: 8px 12px; border-radius: 5px; cursor: pointer; font-size: 14px; }
.pb-menuitem:hover{ background: #f0f3f8; }

/* ---- detail ---- */
.pb-back{
    display: inline-block;
    margin-bottom: 8px;
    color: #006dae;
    font-weight: 600;
    text-decoration: none;
}
.pb-back:hover{ text-decoration: underline; }
.pb-detailhead{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg, #f4f6f9);
    padding: 6px 0;
}
.pb-titlewrap{ display: flex; align-items: center; gap: 8px; min-width: 0; }
.pb-detail-title{ font-size: 24px; font-weight: 700; color: #22303c; cursor: text; }
.pb-editicon{
    border: none; background: none; cursor: pointer;
    color: #6a7683; font-size: 16px; padding: 4px;
}
.pb-editicon:hover{ color: #1f5fa8; }
.pb-title-input{
    font-size: 22px; font-weight: 700;
    border: 1px solid #c8cfd9; border-radius: 5px; padding: 3px 8px;
}
.pb-detail-actions{ display: flex; gap: 8px; flex-wrap: wrap; }
.pb-detail-meta{ color: #6a7683; font-size: 13px; margin: 6px 0 14px; }

.pb-sections{ display: flex; flex-direction: column; gap: 16px; }
.pb-section{
    background: #fff;
    border: 1px solid #dfe4ea;
    border-radius: 10px;
    overflow: hidden;
}
.pb-section-head{
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f4f6f9;
    border-bottom: 1px solid #e4e8ee;
}
.pb-section-name{ font-size: 16px; font-weight: 700; color: #22303c; cursor: text; }
.pb-section-count{
    font-size: 12px; font-weight: 600; color: #6a7683;
    background: #e7ebf0; border-radius: 999px; padding: 1px 8px;
}
.pb-section-btn{
    border: none; background: none; cursor: pointer;
    color: #1f5fa8; font-size: 13px; font-weight: 600; padding: 4px 6px;
}
.pb-section-btn:last-child{ margin-left: auto; color: #b3261e; }
.pb-section-btn:hover{ text-decoration: underline; }
.pb-section-input{
    font-size: 15px; font-weight: 700;
    border: 1px solid #c8cfd9; border-radius: 4px; padding: 2px 6px;
}

.pb-rows{ padding: 6px; min-height: 44px; }
.pb-rows-empty{ padding: 14px; color: #94a0ac; font-size: 13px; text-align: center; }
.pb-row{
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 8px;
    background: #fff;
}
.pb-row:hover{ background: #f6f8fb; }
.pb-row + .pb-row{ border-top: 1px solid #eef1f4; }
.pb-row-locked{ opacity: .85; }
.pb-grip{
    cursor: grab;
    color: #aab4bf;
    font-size: 18px;
    min-width: 32px; min-height: 40px;
    display: flex; align-items: center; justify-content: center;
    touch-action: none;
    flex: 0 0 auto;
}
.pb-grip:hover{ color: #7a8593; }
.pb-grip:active{ cursor: grabbing; }
.pb-row-thumb{
    flex: 0 0 auto;
    width: 64px; height: 40px;
    border-radius: 5px; overflow: hidden;
    background: #f4f6f9;
    display: flex; align-items: center; justify-content: center;
}
.pb-row-thumb .pbthumb, .pb-row-thumb img{ width: 100%; height: 100%; }
.pb-row-main{ flex: 1 1 auto; min-width: 0; }
.pb-row-name{
    display: block;
    font-size: 15px; font-weight: 600; color: #1f5fa8;
    text-decoration: none;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pb-row-name:hover{ text-decoration: underline; }
.pb-row-locked .pb-row-name{ color: #6a7683; }
.pb-row-badges{ margin-top: 3px; display: flex; gap: 6px; flex-wrap: wrap; }
.pb-badge{ font-size: 10.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; letter-spacing: .02em; }
.pb-badge-play{ background: #e9f0f9; color: #26507e; border: 1px solid #d5e2f2; }
.pb-badge-drill{ background: #fdf0e6; color: #b25a1e; border: 1px solid #f4d6ba; }
.pb-badge-mine{ background: #eafaf0; color: #1e7a44; border: 1px solid #c6ecd4; }
.pb-badge-locked{ background: #f0e1e0; color: #9a3b34; border: 1px solid #e2c9c7; }
.pb-row-remove{
    flex: 0 0 auto;
    width: 40px; height: 40px;
    border: none; border-radius: 8px;
    background: none; color: #b3261e;
    font-size: 22px; line-height: 1; cursor: pointer;
}
.pb-row-remove:hover{ background: #fbeceb; }
.pb-row-placeholder{
    border: 2px dashed #9ab6d6;
    border-radius: 8px;
    background: #eef5fc;
    height: 52px;
    margin: 2px 0;
}

.pb-btn-danger{ background: #b3261e; border-color: #b3261e; color: #fff; }
.pb-btn-danger:hover{ background: #97201a; }

.pb-cardname-input{ font-size: 15px; max-width: 100%; }

/* confirm popover (replaces window.confirm) */
#pbconfirm{
    position: fixed;
    z-index: 1003;
    background: #fff;
    border: 1px solid #d3d9e0;
    border-radius: 10px;
    box-shadow: 0 8px 26px rgba(0,0,0,.18);
    max-width: 300px;
    padding: 14px;
}
.pb-confirm-msg{ font-size: 14px; color: #22303c; line-height: 1.4; margin-bottom: 12px; }
.pb-confirm-row{ display: flex; gap: 8px; justify-content: flex-end; }

/* remove-from-playbook undo snackbar (bottom-center, non-blocking) */
#pbsnackbar{
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom));
    transform: translate(-50%, 20px);
    z-index: 3200;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    max-width: calc(100vw - 24px);
    background: #232a3b;
    color: #fff;
    padding: 11px 12px 11px 16px;
    border-radius: 10px;
    box-shadow: 0 8px 26px rgba(0,0,0,.34);
    font-size: 14px;
    opacity: 0;
    transition: opacity .18s ease, transform .18s ease;
}
#pbsnackbar.show{ opacity: 1; transform: translate(-50%, 0); }
.pb-snack-msg{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-snack-undo{
    border: none; background: none; cursor: pointer;
    color: #f2a866; font-weight: 700; font-size: 14px;
    padding: 4px 6px; border-radius: 6px; white-space: nowrap;
}
.pb-snack-undo:hover{ color: #f6bd85; background: rgba(255,255,255,.08); }
.pb-snack-close{
    border: none; background: none; cursor: pointer;
    color: #aab4c2; font-size: 20px; line-height: 1;
    padding: 2px 6px; border-radius: 6px;
}
.pb-snack-close:hover{ color: #fff; background: rgba(255,255,255,.08); }
@media (max-width: 992px){
    /* clear the phone tab bar */
    #pbsnackbar{ bottom: calc(76px + env(safe-area-inset-bottom)); }
}

/* ==================== Print / Export dialog ==================== */
#pbxdialog-overlay{
    position: fixed; inset: 0; z-index: 10050;
    background: rgba(20,28,42,.5);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.pbx-modal{
    background: #fff; border-radius: 12px;
    box-shadow: 0 14px 44px rgba(0,0,0,.28);
    width: 480px; max-width: 100%; max-height: 90vh;
    display: flex; flex-direction: column; overflow: hidden;
}
.pbx-head{ position: relative; padding: 16px 44px 14px 18px; border-bottom: 1px solid #e6eaf0; }
.pbx-title{ font-size: 17px; font-weight: 700; color: #1c2432; }
.pbx-subttl{ font-size: 13px; color: #6a7284; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbx-close{ position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border: 0; background: transparent; font-size: 22px; line-height: 1; color: #8a92a2; cursor: pointer; border-radius: 6px; }
.pbx-close:hover{ background: #f0f3f8; color: #333; }

.pbx-body{ padding: 14px 18px; overflow-y: auto; }
.pbx-flabel{ font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #6a7284; margin: 4px 0 8px; }

.pbx-layouts{ display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.pbx-layopt{ display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border: 1px solid #d9dee6; border-radius: 8px; cursor: pointer; }
.pbx-layopt:hover{ background: #f6f8fb; }
.pbx-layopt input{ margin-top: 2px; }
.pbx-laytxt{ flex: 1; }
.pbx-layname{ font-size: 14px; font-weight: 600; color: #22303c; }
.pbx-laydesc{ font-size: 12px; color: #6a7284; line-height: 1.35; margin-top: 1px; }
.pbx-layopt input:checked ~ .pbx-laytxt .pbx-layname{ color: #006dae; }
.pbx-layopt:has(input:checked){ border-color: #006dae; background: #f0f7fc; }

.pbx-opt{ display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 0; border-top: 1px solid #eef1f5; }
.pbx-check{ display: flex; align-items: center; gap: 8px; font-size: 14px; color: #22303c; cursor: pointer; }
.pbx-check input{ width: 17px; height: 17px; }
.pbx-hint{ font-size: 12px; color: #909aa8; flex-basis: 100%; }
.pbx-opt.pbx-disabled{ opacity: .55; }
.pbx-opt.pbx-disabled .pbx-check{ cursor: default; }
.pbx-inlinelabel{ font-size: 14px; color: #22303c; }
.pbx-subwrap{ padding: 2px 0 6px 25px; }
.pbx-subinput{ width: 100%; padding: 8px 10px; border: 1px solid #cfd6df; border-radius: 7px; font-size: 13px; }

.pbx-seg{ display: inline-flex; border: 1px solid #cfd6df; border-radius: 7px; overflow: hidden; }
.pbx-seg button{ border: 0; background: #fff; padding: 7px 12px; font-size: 13px; color: #45505f; cursor: pointer; }
.pbx-seg button + button{ border-left: 1px solid #cfd6df; }
.pbx-seg button.on{ background: #006dae; color: #fff; }
.pbx-seg button:disabled{ color: #b3bac5; cursor: default; }

.pbx-foot{ display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid #e6eaf0; background: #fafbfc; }
.pbx-footbtns{ display: flex; gap: 8px; }

@media (max-width: 700px){
    .pb-grid{ grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
    .pb-detailhead{ align-items: flex-start; }
    .pb-detail-actions{ width: 100%; }
    .pb-detail-actions .pb-btn{ padding: 8px 10px; }
    .pb-row-thumb{ width: 52px; height: 34px; }
    #pbconfirm{ max-width: calc(100vw - 24px); }
}
@media (max-width: 400px){
    .pb-grid{ grid-template-columns: 1fr 1fr; gap: 10px; }
    .pb-page-title{ font-size: 20px; }
}
/* phone: full-width bottom sheet */
@media (max-width: 992px){
    #pbxdialog-overlay{ align-items: flex-end; padding: 0; }
    .pbx-modal{ width: 100%; max-width: 100%; max-height: 92vh; border-radius: 14px 14px 0 0; }
    .pbx-foot{ position: sticky; bottom: 0; }
}
