/* ============================================================
   Organize PDF Tool — organize-pdf.css
   Prefix: op-
   Accent: #8B5CF6  (violet)
   Accent RGB: 139, 92, 246
   ============================================================ */

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

/* ── Section badge ─────────────────────────────────────────── */
.op-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;
}

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

/* ── Upload Zone ───────────────────────────────────────────── */
.op-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;
}

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

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

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

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

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

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

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

/* ── File Info Bar ─────────────────────────────────────────── */
.op-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;
}

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

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

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

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

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

/* ── Toolbar ───────────────────────────────────────────────── */
.op-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;
}

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

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

/* Thin vertical divider between selection buttons and bulk actions */
.op-bulk-divider {
    width: 1px;
    height: 20px;
    background: rgba(100, 116, 139, 0.2);
    margin: 0 2px;
    flex-shrink: 0;
}

.op-bulk-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Red-tinted bulk delete button */
.op-btn-bulk-delete {
    color: #DC2626 !important;
}

.op-btn-bulk-delete:hover {
    background: rgba(239, 68, 68, 0.08) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
    color: #DC2626 !important;
}

/* Summary pill — live page count */
.op-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 Grid ─────────────────────────────────────────────── */
.op-page-grid {
    display: grid;
    /* Responsive: ~6 cols on desktop, auto-fills down to ~100px */
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 14px;
    padding: 4px 0 24px;
}

/* ── Page Card ─────────────────────────────────────────────── */
.op-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: grab;
    user-select: none;
    transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s, transform 0.1s;
    position: relative;
    outline: none;
}

.op-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;
}

.op-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 */
.op-page-card.op-selected {
    border-color: #8B5CF6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

/* Being dragged — ghosted */
.op-page-card.op-dragging {
    opacity: 0.35;
    cursor: grabbing;
    transform: none;
}

/* Drag target — highlighted drop position */
.op-page-card.op-drag-target {
    border-color: #8B5CF6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.28);
    transform: scale(1.02);
}

/* ── Thumbnail area ────────────────────────────────────────── */

/* A4 portrait ratio (210/297 = 0.707) — any page aspect is accommodated via object-fit */
.op-thumb-wrap {
    position: relative;
    aspect-ratio: 0.707;
    background: #F1F5F9;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

/* Thumbnail image — fills container, respects original aspect via object-fit: contain */
.op-thumb-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: transform 0.25s ease;
}

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

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

/* Spinner inside placeholder while thumbnail loads */
.op-thumb-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(139, 92, 246, 0.2);
    border-top-color: #8B5CF6;
    border-radius: 50%;
    animation: op-spin 0.7s linear infinite;
}

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

/* Rotation badge — displayed in top-right when page has been rotated */
.op-rotation-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 3;
    background: rgba(139, 92, 246, 0.88);
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 4px;
    line-height: 1.5;
    pointer-events: none;
    display: none;
}

/* Show badge only when the thumb-wrap has the op-rotated class */
.op-thumb-wrap.op-rotated .op-rotation-badge {
    display: block;
}

/* ── Hover action overlay (rotate CW, CCW, delete) ─────────── */
.op-page-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 8px;
    gap: 5px;
    /* Dark gradient from bottom for legibility */
    background: linear-gradient(to top, rgba(15, 23, 42, 0.55) 0%, transparent 50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    border-radius: 8px 8px 0 0;
    z-index: 4;
}

/* Show overlay on hover — buttons become interactive */
.op-page-card:hover .op-page-overlay {
    opacity: 1;
    pointer-events: auto;
}

/* Small icon button inside the overlay */
.op-overlay-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.92);
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    color: #0F172A;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.op-overlay-btn:hover {
    background: #FFFFFF;
}

/* Delete button in overlay — red tint on hover */
.op-overlay-btn--delete:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #DC2626;
}

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

/* Hide real checkbox — replaced by custom dot */
.op-select-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Custom checkbox circle — hidden by default, visible on hover or when checked */
.op-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);
}

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

/* Filled violet when checked */
.op-select-label input:checked~.op-select-dot {
    background: #8B5CF6;
    border-color: #8B5CF6;
}

/* Checkmark inside */
.op-select-dot::after {
    content: '';
    display: none;
    width: 5px;
    height: 9px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translate(-1px, -1px);
}

.op-select-label input:checked~.op-select-dot::after {
    display: block;
}

/* ── Page number footer ────────────────────────────────────── */
.op-page-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px 8px;
    border-top: 1px solid rgba(100, 116, 139, 0.1);
}

.op-page-num {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    line-height: 1;
}

/* ── Action Panel ──────────────────────────────────────────── */
.op-action-panel {
    background: #F8FAFC;
    border: 1px solid rgba(100, 116, 139, 0.12);
    border-radius: 14px;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Output filename row */
.op-output-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.op-output-label {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.op-output-input-wrap {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 160px;
    max-width: 360px;
    background: #FFFFFF;
    border: 1px solid rgba(100, 116, 139, 0.22);
    border-radius: 9px;
    overflow: hidden;
    transition: border-color 0.15s;
}

.op-output-input-wrap:focus-within {
    border-color: #8B5CF6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.op-output-input {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--text-primary);
    background: transparent;
    border: none;
    outline: none;
}

.op-output-input::placeholder {
    color: #94A3B8;
}

.op-output-ext {
    padding: 8px 12px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
    border-left: 1px solid rgba(100, 116, 139, 0.15);
}

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

.op-btn-save {
    min-width: 160px;
    padding: 11px 28px;
    font-size: 1rem;
    justify-content: center;
}

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

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

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

.op-progress-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
}

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

@media (max-width: 600px) {
    .op-upload-zone {
        padding: 40px 16px;
    }

    .op-page-grid {
        grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
        gap: 8px;
    }

    .op-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .op-file-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .op-file-name {
        max-width: 100%;
    }

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

    .op-output-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .op-output-input-wrap {
        max-width: 100%;
        width: 100%;
    }

    .op-btn-save {
        width: 100%;
    }

    .op-overlay-btn {
        width: 26px;
        height: 26px;
        font-size: 0.8125rem;
    }
}