/* ============================================================
   PDF to PNG Tool — pdf-to-png.css
   Prefix: ptp-
   Accent: #8B5CF6  (violet)
   Accent RGB: 139, 92, 246
   ============================================================ */

/* ── Accent override for tool-base shared classes ─────────── */
.ptp-section {
    --tool-accent: #8B5CF6;
    --tool-accent-rgb: 139, 92, 246;
    padding: 40px 0 80px;
}

/* ── Section badge ─────────────────────────────────────────── */
.ptp-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 18px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.22);
    border-radius: 50px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #8B5CF6;
    margin-bottom: 12px;
}

.ptp-badge i {
    font-size: 0.875rem;
}

/* ── Upload Zone ───────────────────────────────────────────── */
.ptp-upload-zone {
    border: 2px dashed rgba(139, 92, 246, 0.32);
    border-radius: 16px;
    background: rgba(139, 92, 246, 0.03);
    padding: 56px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    outline: none;
}

.ptp-upload-zone:hover,
.ptp-upload-zone:focus-visible {
    border-color: rgba(139, 92, 246, 0.6);
    background: rgba(139, 92, 246, 0.07);
}

.ptp-upload-zone.ptp-drag-over {
    border-color: #8B5CF6;
    background: rgba(139, 92, 246, 0.1);
}

.ptp-upload-icon {
    font-size: 3rem;
    color: #8B5CF6;
    opacity: 0.65;
    margin-bottom: 14px;
    display: block;
}

.ptp-upload-title {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 6px;
}

.ptp-upload-sub {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0 0 10px;
}

.ptp-upload-formats {
    font-size: 0.875rem;
    color: var(--text-light);
    margin: 0;
    letter-spacing: 0.01em;
}

/* ── Workspace ─────────────────────────────────────────────── */
.ptp-workspace {
    margin-top: 24px;
}

/* ── File Info Bar ─────────────────────────────────────────── */
.ptp-file-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: rgba(139, 92, 246, 0.04);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.ptp-file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.ptp-file-icon {
    font-size: 1.75rem;
    color: #8B5CF6;
    flex-shrink: 0;
}

.ptp-file-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ptp-file-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 360px;
}

.ptp-file-meta {
    font-size: 0.8125rem;
    color: var(--text-light);
}

/* ── Toolbar ───────────────────────────────────────────────── */
.ptp-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 0;
    border-top: 1px solid rgba(100, 116, 139, 0.1);
    border-bottom: 1px solid rgba(100, 116, 139, 0.1);
    margin-bottom: 20px;
}

.ptp-toolbar-left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.ptp-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Thin vertical divider between controls */
.ptp-toolbar-divider {
    width: 1px;
    height: 20px;
    background: rgba(100, 116, 139, 0.2);
    margin: 0 2px;
    flex-shrink: 0;
}

/* ── DPI Selector ──────────────────────────────────────────── */
.ptp-dpi-group {
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(100, 116, 139, 0.06);
    border: 1px solid rgba(100, 116, 139, 0.14);
    border-radius: 8px;
    padding: 3px;
}

.ptp-dpi-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    padding: 0 6px 0 4px;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.ptp-dpi-btn {
    padding: 4px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.ptp-dpi-btn:hover {
    background: rgba(139, 92, 246, 0.08);
    color: #8B5CF6;
}

.ptp-dpi-btn--active {
    background: #8B5CF6;
    color: #FFFFFF;
}

.ptp-dpi-btn--active:hover {
    background: #7C3AED;
    color: #FFFFFF;
}

/* Summary pill */
.ptp-summary {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(139, 92, 246, 0.07);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 8px;
    padding: 5px 12px;
    white-space: nowrap;
}

/* ── Page Selection Grid ───────────────────────────────────── */
.ptp-page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 14px;
    padding: 4px 0 24px;
}

/* ── Page Card ─────────────────────────────────────────────── */
.ptp-page-card {
    border-radius: 10px;
    background: #FFFFFF;
    border: 2px solid rgba(100, 116, 139, 0.14);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
    position: relative;
    outline: none;
}

.ptp-page-card:hover {
    border-color: rgba(139, 92, 246, 0.35);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
    z-index: 1;
}

.ptp-page-card:focus-visible {
    border-color: #8B5CF6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
    outline: none;
}

/* Selected state — violet ring */
.ptp-page-card.ptp-selected {
    border-color: #8B5CF6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

/* ── Thumbnail wrap (A4 portrait ratio 0.707) ──────────────── */
.ptp-thumb-wrap {
    position: relative;
    aspect-ratio: 0.707;
    background: #F1F5F9;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.ptp-thumb-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Placeholder while thumbnail renders */
.ptp-thumb-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #8B5CF6;
}

.ptp-thumb-placeholder i {
    font-size: 1.75rem;
    opacity: 0.35;
}

.ptp-thumb-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(139, 92, 246, 0.2);
    border-top-color: #8B5CF6;
    border-radius: 50%;
    animation: ptp-spin 0.7s linear infinite;
}

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

/* ── Selection checkbox (top-left of card) ─────────────────── */
.ptp-select-label {
    position: absolute;
    top: 7px;
    left: 7px;
    z-index: 5;
    cursor: pointer;
    line-height: 0;
}

.ptp-select-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.ptp-select-dot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(139, 92, 246, 0.4);
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
    opacity: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.ptp-page-card:hover .ptp-select-dot,
.ptp-page-card.ptp-selected .ptp-select-dot {
    opacity: 1;
}

.ptp-page-card.ptp-selected .ptp-select-dot {
    background: #8B5CF6;
    border-color: #8B5CF6;
}

.ptp-select-dot i {
    font-size: 0.6875rem;
    color: #FFFFFF;
    opacity: 0;
    transition: opacity 0.1s;
}

.ptp-page-card.ptp-selected .ptp-select-dot i {
    opacity: 1;
}

/* ── Card Footer (page label) ──────────────────────────────── */
.ptp-card-footer {
    padding: 7px 8px 8px;
    text-align: center;
}

.ptp-card-page-num {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ── Action Panel ──────────────────────────────────────────── */
.ptp-action-panel {
    background: rgba(139, 92, 246, 0.03);
    border: 1px solid rgba(139, 92, 246, 0.12);
    border-radius: 14px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 8px;
}

/* Filename prefix row */
.ptp-output-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.ptp-output-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 110px;
}

.ptp-output-input-wrap {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 1;
    min-width: 180px;
}

.ptp-output-input {
    flex: 1;
    height: 38px;
    padding: 0 12px;
    border: 1px solid rgba(100, 116, 139, 0.25);
    border-right: none;
    border-radius: 8px 0 0 8px;
    background: #FFFFFF;
    font-size: 0.9375rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
    min-width: 0;
}

.ptp-output-input:focus {
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.08);
}

.ptp-output-ext {
    display: flex;
    align-items: center;
    height: 38px;
    padding: 0 12px;
    background: rgba(100, 116, 139, 0.06);
    border: 1px solid rgba(100, 116, 139, 0.25);
    border-radius: 0 8px 8px 0;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-light);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Action buttons row */
.ptp-action-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Progress bar */
.ptp-progress-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ptp-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(139, 92, 246, 0.12);
    border-radius: 99px;
    overflow: hidden;
}

.ptp-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #8B5CF6, #A78BFA);
    border-radius: 99px;
    transition: width 0.25s ease;
}

.ptp-progress-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: 0;
    text-align: center;
}

/* ── Results Section ───────────────────────────────────────── */
.ptp-results-section {
    margin-top: 32px;
}

.ptp-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.ptp-results-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Results Grid — wider cards since they show full PNG preview */
.ptp-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

/* ── Result Card ───────────────────────────────────────────── */
.ptp-result-card {
    border-radius: 10px;
    background: #FFFFFF;
    border: 1px solid rgba(100, 116, 139, 0.14);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.15s, transform 0.1s;
}

.ptp-result-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

/* PNG preview inside result card */
.ptp-result-preview-wrap {
    position: relative;
    aspect-ratio: 0.707;
    background:
        linear-gradient(45deg, #E2E8F0 25%, transparent 25%),
        linear-gradient(-45deg, #E2E8F0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #E2E8F0 75%),
        linear-gradient(-45deg, transparent 75%, #E2E8F0 75%);
    background-size: 12px 12px;
    background-position: 0 0, 0 6px, 6px -6px, -6px 0;
    background-color: #F8FAFC;
    overflow: hidden;
}

.ptp-result-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.ptp-result-footer {
    padding: 8px 10px;
    border-top: 1px solid rgba(100, 116, 139, 0.1);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ptp-result-filename {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ptp-result-dl-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 30px;
    border-radius: 6px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.2);
    font-size: 0.8125rem;
    font-weight: 600;
    color: #8B5CF6;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.ptp-result-dl-btn:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.35);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
    .ptp-page-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }

    .ptp-results-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 12px;
    }

    .ptp-output-row {
        flex-direction: column;
        align-items: stretch;
    }

    .ptp-output-label {
        min-width: unset;
    }

    .ptp-action-panel {
        padding: 16px;
    }

    .ptp-dpi-group {
        flex-wrap: wrap;
    }

    .ptp-file-name {
        max-width: 200px;
    }
}