/**
 * Enhanced Split PDF Styles
 * Page thumbnail grid with selection UI
 */

/* ═══════════════════════════════════════════════════════════════
   Page Grid Layout
   ═══════════════════════════════════════════════════════════════ */

.split-page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    padding: 1rem 0;
}

.split-page-card {
    position: relative;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.split-page-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

.split-page-card.selected {
    border-color: #667eea;
    background: #f5f3ff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Rotation Buttons */
.btn-rotate {
    padding: 0.25rem 0.5rem;
    border: 1px solid #e5e7eb;
    background: white;
    color: #64748b;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-rotate:hover {
    border-color: #667eea;
    color: #667eea;
    background: #f5f3ff;
    transform: scale(1.1);
}

/* Drag Handle */
.drag-handle {
    cursor: grab !important;
}

.drag-handle:active {
    cursor: grabbing !important;
}


/* ═══════════════════════════════════════════════════════════════
   Page Checkbox
   ═══════════════════════════════════════════════════════════════ */

.page-checkbox {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 2;
}

.page-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #667eea;
}

/* ═══════════════════════════════════════════════════════════════
   Thumbnail
   ═══════════════════════════════════════════════════════════════ */

.page-thumbnail {
    width: 100%;
    aspect-ratio: 3/4;
    background: #f9fafb;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.page-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ═══════════════════════════════════════════════════════════════
   Page Number
   ═══════════════════════════════════════════════════════════════ */

.page-number {
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: #64748b;
}

.split-page-card.selected .page-number {
    color: #667eea;
}

/* ═══════════════════════════════════════════════════════════════
   Selection Toolbar
   ═══════════════════════════════════════════════════════════════ */

.selection-toolbar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.selection-count {
    font-weight: 600;
    color: #667eea;
    min-width: 100px;
}

.selection-actions {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    flex-wrap: wrap;
}

/* Compact Buttons */
.btn-selection-compact {
    padding: 0.4rem 0.75rem;
    border: 1px solid #e5e7eb;
    background: white;
    color: #64748b;
    border-radius: 6px;
    font-size: 0.813rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-selection-compact:hover {
    border-color: #667eea;
    color: #667eea;
    background: #f5f3ff;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    width: 40px;
    height: 22px;
    background: #e5e7eb;
    border-radius: 22px;
    transition: background 0.3s;
}

.toggle-slider:before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    top: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-switch input:checked+.toggle-slider {
    background: #dc2626;
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(18px);
}

.toggle-label {
    font-size: 0.813rem;
    color: #64748b;
    font-weight: 500;
}

.toggle-switch input:checked~.toggle-label {
    color: #dc2626;
}

/* Responsive Design */
@media (max-width: 768px) {
    .selection-toolbar {
        flex-direction: column;
        gap: 0.75rem;
    }

    .selection-count {
        text-align: center;
        min-width: auto;
    }

    .selection-actions {
        flex-direction: column;
        width: 100%;
    }

    .selection-actions>div {
        width: 100%;
    }

    .btn-selection-compact {
        flex: 1;
    }

    .split-page-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .split-page-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.5rem;
    }

    .toggle-label {
        font-size: 0.75rem;
    }

    .btn-selection-compact {
        font-size: 0.75rem;
        padding: 0.35rem 0.6rem;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Loading Spinner
   ═══════════════════════════════════════════════════════════════ */

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}