/* =====================================================
   Split PDF into Parts - CSS (محدث مع المصغرات)
   تم إضافة تنسيقات لمجموعة output-parts-group
   ===================================================== */

/* ===== Main Container ===== */
.tool-wrapper[data-tool="split-pdf-into-parts"] {
    font-family: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    color: #1e293b;
}

/* ===== Status Message ===== */
.status-message {
    background: #f8fafc;
    border: 1px solid #e9edf2;
    border-radius: 0.75rem;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1.25rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: #1e293b;
    display: none;
}
.status-message.show { display: block; }
.status-message.success {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}
.status-message.error {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b;
}

/* ===== Editor Layout ===== */
.editor-layout {
    background: #ffffff;
    border-radius: 1rem;
    padding: 1.5rem 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    border: 1px solid #e9edf2;
    margin-top: 1.5rem;
}
.editor-layout.hidden { display: none; }

/* ===== File Box ===== */
.file-box {
    background: #f8fafc;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid #e9edf2;
    margin-bottom: 1.25rem;
    display: none;
}
.file-box.show { display: flex; }
.file-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.5rem;
    flex: 1;
}
.file-name {
    font-weight: 600;
    color: #0f172a;
    font-size: 0.9rem;
    word-break: break-all;
    flex: 1;
    min-width: 120px;
}
.file-size {
    color: #475569;
    font-size: 0.85rem;
    background: #eef2f6;
    padding: 0.15rem 0.8rem;
    border-radius: 1rem;
    white-space: nowrap;
}
.file-pages {
    font-size: 0.85rem;
    color: #475569;
    background: #eef2f6;
    padding: 0.15rem 0.8rem;
    border-radius: 1rem;
    white-space: nowrap;
}
.remove-file {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 0.4rem;
    font-size: 1rem;
    transition: color 0.2s, background 0.2s;
}
.remove-file:hover {
    color: #dc2626;
    background: #fef2f2;
}

/* ===== Tool Settings ===== */
.tool-settings {
    background: #f8fafc;
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid #e9edf2;
    margin-bottom: 1.25rem;
}
.tool-settings h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.tool-settings h3 i { color: #0067b8; }

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.5rem;
}
.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.option-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.option-label i {
    color: #0067b8;
    width: 1.1rem;
}
.option-input,
.option-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d9e6;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    color: #1e293b;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}
.option-input:focus,
.option-group select:focus {
    border-color: #0067b8;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 103, 184, 0.12);
}
.option-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364758b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}
.option-hint {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.2rem;
}
.option-hint i {
    margin-right: 0.25rem;
    color: #0067b8;
}

/* ===== Page Selection Group ===== */
.page-selection-group {
    background: #f8fafc;
    border: 1px solid #e9edf2;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin: 1.25rem 0 0.75rem 0;
    display: none;
}
.page-selection-group.show { display: block; }
.page-selection-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.badge {
    display: inline-block;
    background: #0067b8;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.1rem 0.8rem;
    border-radius: 1rem;
    line-height: 1.6rem;
    min-width: 2.5rem;
    text-align: center;
}
.page-selection-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    margin-top: 0.5rem;
}
.page-selection-controls input[data-tool-pages] {
    flex: 1;
    min-width: 180px;
    padding: 0.4rem 0.75rem;
    border: 1px solid #d1d9e6;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    color: #1e293b;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.page-selection-controls input[data-tool-pages]:focus {
    border-color: #0067b8;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 103, 184, 0.12);
}
.page-selection-buttons {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.btn-sm {
    padding: 0.3rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 1.5rem;
}
.page-selection-hint {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #64748b;
}
.page-selection-hint i {
    margin-right: 0.25rem;
    color: #0067b8;
}

/* ===== Parts Preview ===== */
.split-preview {
    margin-top: 12px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 0.5rem;
    border: 1px solid #e9edf2;
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.85rem;
}

.split-preview .part-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 8px;
    border-bottom: 1px solid #e9edf2;
}

.split-preview .part-item:last-child {
    border-bottom: none;
}

.split-preview .part-number {
    font-weight: 600;
    color: #0f172a;
}

.split-preview .part-range {
    color: #475569;
}

.split-preview .part-item.active {
    background: #dbeafe;
    border-radius: 4px;
}

.split-preview-empty {
    color: #94a3b8;
    font-style: italic;
    text-align: center;
    padding: 8px;
}

/* responsive */
@media (max-width: 480px) {
    .split-preview {
        font-size: 0.75rem;
        max-height: 150px;
        padding: 8px;
    }
}

/* =====================================================
   OUTPUT PARTS GROUP - NEW
   ===================================================== */
.option-group[data-role="output-parts-group"] {
    display: none;
}
.option-group[data-role="output-parts-group"].active {
    display: flex;
}

/* =====================================================
   OUTPUT PARTS GROUP
   ===================================================== */
.option-group[data-role="output-parts-group"] {
    display: none;
}
.option-group[data-role="output-parts-group"].active {
    display: flex;
}

/* التأكد من ظهور القائمة المنسدلة */
.option-group select[data-role="split-mode"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* التأكد من ظهور جميع الخيارات */
.option-group select[data-role="split-mode"] option {
    display: block !important;
}
/* =====================================================
   Thumbnails Section
   ===================================================== */
.thumbnails-section {
    margin: 1rem 0 0 0;
    display: none;
}
.thumbnails-section.show { display: block; }
.thumbnails-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.thumbnails-header h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.thumbnails-header h4 i { color: #0067b8; }
.thumbnails-info {
    font-size: 0.75rem;
    color: #64748b;
}

.thumbnails-grid-wrapper { width: 100%; }
.thumbnails-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 0.75rem;
    border: 1px solid #e9edf2;
}
.thumbnail-item {
    border: 3px solid #e5e7eb;
    border-radius: 0.5rem;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
    user-select: none;
}
.thumbnail-item:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.thumbnail-item.selected {
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.3);
}
.thumbnail-item .page-number {
    position: absolute;
    bottom: 6px;
    right: 8px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 500;
    pointer-events: none;
}
.thumbnail-item .selection-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: #22c55e;
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.thumbnail-item.selected .selection-badge { opacity: 1; }
.thumbnail-item canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1.4;
    object-fit: contain;
}

/* Thumbnails Pagination */
.thumb-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 12px 0 4px;
}
.thumb-pagination button {
    padding: 6px 16px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #f9fafb;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}
.thumb-pagination button:hover:not(:disabled) { background: #e5e7eb; }
.thumb-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.thumb-pagination .page-indicator {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
}

/* Preview Wrapper (Zoomed) */
.preview-wrapper {
    margin: 20px auto;
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    max-width: 1100px;
    display: none;
}
.preview-canvas-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 400px;
}
.preview-canvas-wrapper canvas {
    width: 70% !important;
    max-width: 70% !important;
    height: auto !important;
    display: block;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    border-radius: 4px;
}

/* ===== Progress Bar ===== */
.progress-container {
    background: #e9edf2;
    border-radius: 2rem;
    height: 24px;
    margin: 1rem 0 0.5rem 0;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #0067b8, #3b8fd9);
    border-radius: 2rem;
    transition: width 0.4s ease;
}
.progress-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: 0.3px;
}

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin: 1rem 0 0.5rem 0;
}
.btn {
    padding: 0.6rem 1.8rem;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}
.btn:active { transform: scale(0.97); }
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}
.btn-primary {
    background: #0067b8;
    color: #ffffff;
}
.btn-primary:hover:not(:disabled) {
    background: #005499;
    box-shadow: 0 4px 12px rgba(0, 103, 184, 0.25);
}
.btn-secondary {
    background: #f1f5f9;
    color: #1e293b;
    border: 1px solid #d1d9e6;
}
.btn-secondary:hover { background: #e2e8f0; }
.btn-success {
    background: #0b7e3d;
    color: #ffffff;
}
.btn-success:hover:not(:disabled) {
    background: #096633;
    box-shadow: 0 4px 12px rgba(11, 126, 61, 0.25);
}

/* ===== Result Section ===== */
.result-section {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    display: none;
}
.result-section.show { display: block; }
.result-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.result-title {
    font-weight: 700;
    color: #065f46;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.result-title i {
    color: #0b7e3d;
    font-size: 1.1rem;
}
.result-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.result-info {
    font-size: 0.8rem;
    color: #065f46;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #a7f3d0;
}

/* ===== Messages ===== */
.error-message {
    background: #fef2f2;
    border-left: 4px solid #dc2626;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    margin: 1rem 0;
    color: #991b1b;
    font-weight: 500;
    font-size: 0.9rem;
    display: none;
}
.error-message.show { display: block; }
.success-message {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 0.75rem;
    padding: 0.75rem 1.25rem;
    margin: 0.75rem 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #065f46;
    font-weight: 500;
    font-size: 0.9rem;
}
.success-message i {
    color: #0b7e3d;
    font-size: 1.25rem;
}
.warning-message {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    border-radius: 0.5rem;
    padding: 0.6rem 1rem;
    margin: 0.75rem 0;
    font-size: 0.85rem;
    color: #92400e;
    display: none;
    align-items: center;
    gap: 0.6rem;
}
.warning-message.show { display: flex; }
.warning-message i {
    color: #f59e0b;
    font-size: 1rem;
}

/* =====================================================
   Responsive
   ===================================================== */
@media (max-width: 1024px) {
    .thumbnails-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 768px) {
    .tool-wrapper[data-tool="split-pdf-into-parts"] { padding: 0 0.5rem; margin: 1rem auto; }
    .editor-layout { padding: 1rem 1rem; }
    .options-grid { grid-template-columns: 1fr; gap: 0.8rem; }
    .thumbnails-grid { grid-template-columns: repeat(3, 1fr); padding: 10px; gap: 8px; }
    .thumbnails-grid .page-number { font-size: 9px; padding: 1px 6px; }
    .thumb-pagination { gap: 10px; }
    .thumb-pagination button { padding: 4px 12px; font-size: 12px; }
    .action-buttons { flex-direction: column; align-items: stretch; }
    .action-buttons .btn { justify-content: center; width: 100%; }
    .page-selection-controls { flex-direction: column; align-items: stretch; }
    .page-selection-controls input[data-tool-pages] { min-width: unset; }
    .page-selection-buttons { justify-content: center; }
    .file-row { flex-wrap: wrap; gap: 0.4rem; }
    .file-name { font-size: 0.8rem; width: 100%; min-width: unset; }
    .result-header { flex-direction: column; align-items: stretch; }
    .result-actions { justify-content: center; }
}
@media (max-width: 480px) {
    .editor-layout { padding: 0.75rem; }
    .thumbnails-grid { grid-template-columns: repeat(2, 1fr); padding: 8px; gap: 6px; }
    .thumbnails-grid .page-number { font-size: 8px; padding: 1px 4px; bottom: 4px; right: 4px; }
    .thumbnails-grid .selection-badge { width: 18px; height: 18px; font-size: 10px; top: 4px; left: 4px; }
    .btn { padding: 0.4rem 1rem; font-size: 0.8rem; }
}

/* ===== RTL Support ===== */
html[dir="rtl"] .btn i,
html[dir="rtl"] .option-label i,
html[dir="rtl"] .tool-settings h3 i,
html[dir="rtl"] .success-message i,
html[dir="rtl"] .thumbnails-header h4 i {
    margin-left: 0.4rem;
    margin-right: 0;
}
html[dir="rtl"] .option-group select {
    background-position: left 12px center;
    padding-right: 0.75rem;
    padding-left: 32px;
}
html[dir="rtl"] .option-hint i {
    margin-left: 0.25rem;
    margin-right: 0;
}
html[dir="rtl"] .thumbnail-item .page-number {
    right: auto;
    left: 8px;
}
html[dir="rtl"] .thumbnail-item .selection-badge {
    left: auto;
    right: 6px;
}
html[dir="rtl"] .page-selection-hint i {
    margin-left: 0.25rem;
    margin-right: 0;
}
html[dir="rtl"] .remove-file i { margin: 0; }