/* PDF Page Manager — thumbnail grid, per-page actions, toolbar. */

/* Drop zone base styles live in dev-tools.css; only the icon is page-specific. */
.pms-dropzone-icon {
    display: block;
    width: 52px;
    height: 64px;
    margin: 0 auto 4px;
}

.ppm-filebar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 14px 0 0;
    font-size: 14px;
    color: #5f6368;
    min-width: 0;
}

.ppm-filename {
    font-weight: 600;
    color: #202124;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60%;
}

.ppm-pagecount {
    flex: 0 0 auto;
}

.ppm-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin: 14px 0 0;
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #e6e9ed;
    border-radius: 10px;
}

.ppm-toolbar-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ppm-btn {
    padding: 7px 12px;
    font-size: 13px;
    line-height: 1.4;
    border: 1px solid #d7dbe0;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    color: #202124;
    font-family: inherit;
}

.ppm-btn:hover:not(:disabled) {
    border-color: #1a73e8;
    color: #1a73e8;
}

.ppm-btn.danger:hover:not(:disabled) {
    border-color: #d93025;
    color: #d93025;
}

.ppm-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.ppm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    margin: 18px 0 0;
}

.ppm-grid:empty {
    display: none;
}

.ppm-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    background: #fff;
    border: 1px solid #e6e9ed;
    border-radius: 10px;
    transition: border-color .12s ease, box-shadow .12s ease;
    content-visibility: auto;
    contain-intrinsic-size: auto 240px;
}

.ppm-card.selected {
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, .15);
}

.ppm-card.deleted {
    opacity: .42;
}

.ppm-drag-handle {
    position: absolute;
    top: 4px;
    left: 4px;
    z-index: 3;
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: rgba(255, 255, 255, .92);
    color: #5f6368;
    font-size: 16px;
    line-height: 1;
    cursor: grab;
    touch-action: none;
}

@media (pointer: coarse), (any-pointer: coarse) {
    .ppm-drag-handle {
        display: inline-flex;
    }
}

.ppm-card.is-touch-dragging {
    opacity: .55;
}

.ppm-card.is-drop-target {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}

.ppm-card.deleted .ppm-thumb::after {
    content: "✕";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    color: #d93025;
    background: rgba(255, 255, 255, .55);
}

.ppm-card.drop-target {
    border-color: #1a73e8;
    border-style: dashed;
}

.ppm-thumb {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 3 / 4;
    background: #f1f3f4;
    border-radius: 6px;
    overflow: hidden;
}

.ppm-thumb canvas {
    max-width: 100%;
    max-height: 100%;
    transition: transform .15s ease;
}

.ppm-thumb.is-loading::before {
    content: "";
    width: 18px;
    height: 18px;
    border: 2px solid #dadce0;
    border-top-color: #1a73e8;
    border-radius: 50%;
    animation: ppm-spin .8s linear infinite;
}

@keyframes ppm-spin {
    to { transform: rotate(360deg); }
}

.ppm-page-no {
    position: absolute;
    right: 6px;
    bottom: 6px;
    padding: 1px 6px;
    font-size: 11px;
    line-height: 1.5;
    color: #fff;
    background: rgba(32, 33, 36, .72);
    border-radius: 10px;
}

.ppm-select {
    position: absolute;
    right: 10px;
    top: 10px;
    display: flex;
    padding: 2px;
    background: rgba(255, 255, 255, .9);
    border-radius: 6px;
    cursor: pointer;
}

.ppm-select input {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

.ppm-card-actions {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.ppm-icon-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 14px;
    line-height: 1;
    color: #5f6368;
    background: #fff;
    border: 1px solid #e6e9ed;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
}

.ppm-icon-btn:hover:not(:disabled) {
    color: #1a73e8;
    border-color: #1a73e8;
}

.ppm-icon-btn[data-act="delete"]:hover:not(:disabled) {
    color: #d93025;
    border-color: #d93025;
}

.ppm-icon-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.ppm-empty {
    padding: 28px 0;
    font-size: 14px;
    color: #80868b;
    text-align: center;
}

@media (max-width: 640px) {
    .ppm-grid {
        grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
        gap: 10px;
    }

    .ppm-filename {
        max-width: 100%;
    }

    .ppm-toolbar {
        padding: 10px;
    }

    .ppm-btn {
        padding: 6px 10px;
        font-size: 12.5px;
    }
}

/* GEO: the direct answer is a real heading, not a paragraph. */
.geo-answer-title {
    margin: 12px 0 6px;
    font-size: 16px;
    line-height: 1.4;
}

/* Key facts block for search and AI answer engines. */
.ppm-key-facts {
    margin: 18px 0 0;
    padding: 14px 16px;
    background: #f8f9fa;
    border: 1px solid #e6e9ed;
    border-radius: 10px;
}

.ppm-key-facts h2 {
    margin: 0 0 8px;
    font-size: 16px;
    line-height: 1.4;
}

.ppm-key-facts ul {
    margin: 0;
    padding-left: 20px;
    font-size: 14px;
    line-height: 1.6;
    color: #3c4043;
}

.ppm-key-facts li + li {
    margin-top: 6px;
}

/* A page that could not be rendered. */
.ppm-card:not(.deleted) .ppm-thumb.is-error::after {
    content: "⚠";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    color: #d93025;
    background: rgba(255, 255, 255, .7);
}

.ppm-card:not(.deleted) .ppm-thumb.is-error::before {
    content: attr(data-error);
    position: absolute;
    left: 4px;
    right: 4px;
    bottom: 4px;
    z-index: 2;
    padding: 2px 3px;
    border-radius: 3px;
    background: rgba(255, 255, 255, .85);
    font-size: 10px;
    line-height: 1.25;
    color: #d93025;
    text-align: center;
}

/* Deleted pages are not part of the output numbering. */
.ppm-card.deleted .ppm-page-no {
    background: rgba(95, 99, 104, .55);
    text-decoration: line-through;
}

.ppm-shortcuts {
    margin: 8px 0 0;
    font-size: 12px;
    line-height: 1.5;
    color: #5f6368;
    unicode-bidi: plaintext;
    text-align: start;
}

@media (hover: none) and (pointer: coarse) {
    .ppm-shortcuts {
        display: none;
    }
}
