/* ============================================================
   PDF to EPS - Stylesheet (Organized & Duplicate-Free)
   ============================================================ */

/* ============================================================
   1. LAYOUT & CONTAINERS
   ============================================================ */

.editor-layout {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 0 20px;
    box-sizing: border-box;
}

.tool-wrapper {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}


/* ============================================================
   3. FILE BOX
   ============================================================ */

.file-box {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px 20px;
    box-sizing: border-box;
}
.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.file-name {
    font-weight: 500;
    color: #1f2937;
    word-break: break-all;
}
.file-size {
    font-size: 14px;
    color: #6b7280;
}
.remove-file {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}
.remove-file:hover {
    background: #fee2e2;
}
.file-details {
    margin-top: 8px;
    font-size: 12px;
    color: #6b7280;
}
.file-details i {
    margin-right: 4px;
}

/* ============================================================
   4. TOOL SETTINGS (خيارات التحويل)
   ============================================================ */

.tool-settings {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 24px;
    box-sizing: border-box;
}
.tool-settings h3 {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}
.tool-settings h3 i {
    margin-right: 8px;
    color: #3b82f6;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 24px;
}
.options-grid > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.options-grid label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}
.options-grid select,
.options-grid input[type="text"] {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.options-grid select:focus,
.options-grid input[type="text"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
.options-grid input[type="range"] {
    width: 100%;
    accent-color: #3b82f6;
}
.range-value {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
}
.options-grid small {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}

/* ============================================================
   5. ACTION BUTTONS & ZOOM CONTROLS
   ============================================================ */

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    width: 100%;
    max-width: 1100px;
}
.action-buttons .btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.action-buttons .zoom-group {
    display: flex;
    align-items: center;
    gap: 6px;
}
.action-buttons .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.action-buttons .btn:hover {
    transform: scale(1.02);
}
.action-buttons .btn:active {
    transform: scale(0.96);
}
.btn-primary {
    background: #3b82f6;
    color: #fff;
}
.btn-primary:hover {
    background: #2563eb;
}
.btn-secondary {
    background: #f3f4f6;
    color: #1f2937;
    border: 1px solid #d1d5db;
}
.btn-secondary:hover {
    background: #e5e7eb;
}
.btn-success {
    background: #10b981;
    color: #fff;
}
.btn-success:hover {
    background: #059669;
}

#zoom-in-btn,
#zoom-out-btn {
    background: #f3f4f6;
    color: #1f2937;
    border: 1px solid #d1d5db;
    padding: 4px 10px;
    font-size: 14px;
}
#zoom-in-btn:hover,
#zoom-out-btn:hover {
    background: #e5e7eb;
}
#zoom-level {
    font-weight: 600;
    min-width: 44px;
    text-align: center;
    font-size: 14px;
    color: #1f2937;
}

/* ============================================================
   6. PROGRESS BAR
   ============================================================ */

.progress-container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    position: relative;
    height: 24px;
    background: #e5e7eb;
    border-radius: 30px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: #3b82f6;
    border-radius: 30px;
    transition: width 0.3s ease;
}
.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: 600;
    color: #1f2937;
}

/* ============================================================
   7. THUMBNAILS GRID (مع الترقيم والتنقل)
   ============================================================ */

.thumbnails-grid-wrapper {
    width: 100%;
    max-width: 1100px;
    margin: 20px auto 0;
}

.thumbnails-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 16px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    max-height: 70vh;
    overflow-y: auto;
    box-sizing: border-box;
}

.thumbnail-item {
    border: 3px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
    position: relative;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.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;
}

/* Pagination for thumbnails */
.thumb-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 8px 0;
}
.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;
}

/* ============================================================
   8. SINGLE PAGE PREVIEW (معاينة صفحة واحدة)
   ============================================================ */

.preview-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    box-sizing: border-box;
}

.preview-canvas-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 500px;
    position: relative;
    cursor: pointer;
}
.preview-canvas-wrapper canvas,
.preview-canvas-wrapper img {
    width: 70%;
    max-width: 70%;
    height: auto;
    display: block;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    border-radius: 4px;
}
.selection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    border-radius: 4px;
    transition: background 0.2s, border 0.2s;
}

.preview-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border: none;
    background: none;
}
.preview-controls button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    color: #1f2937;
    border: 1px solid #d1d5db;
    transition: background 0.2s;
}
.preview-controls button:hover:not(:disabled) {
    background: #e5e7eb;
}
.preview-controls button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
#toggle-selection-btn {
    background: #4f46e5;
    color: #fff;
    border: none;
    width: auto;
    padding: 0 16px;
}
#toggle-selection-btn:hover:not(:disabled) {
    background: #4338ca;
}
.preview-controls span {
    min-width: 70px;
    text-align: center;
    font-weight: 600;
    color: #1f2937;
}

/* ============================================================
   9. MESSAGES (Success, Error, Warning, Info)
   ============================================================ */

.success-message,
.error-message,
.warning-message,
.info-note {
    width: 100%;
    max-width: 1100px;
    margin: 12px auto;
    padding: 12px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    box-sizing: border-box;
}
.success-message {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}
.error-message {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}
.warning-message {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}
.info-note {
    background: #f0f9ff;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}
.success-message i,
.error-message i,
.warning-message i,
.info-note i {
    font-size: 18px;
}

/* ============================================================
   10. TOAST NOTIFICATION
   ============================================================ */

.copy-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #10b981;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    display: none;
    align-items: center;
    gap: 8px;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    font-weight: 500;
}

/* ============================================================
   11. ADDITIONAL HELPERS (اعداد التحديد والحقول)
   ============================================================ */

[data-role="selection-counter"] {
    font-size: 12px;
    color: #6b7280;
    margin-left: 8px;
    font-weight: 500;
}

#eps-pages {
    flex: 1;
    min-width: 150px;
}
#clear-page-selection,
#select-all-pages {
    white-space: nowrap;
}

/* ============================================================
   12. RESPONSIVE DESIGN (Mobile First)
   ============================================================ */

@media (max-width: 768px) {
    .editor-layout {
        padding: 0 12px;
        gap: 16px;
    }
    .tool-wrapper {
        padding: 0 12px;
    }
    .tool-settings {
        padding: 16px;
    }
    .options-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    .action-buttons .btn-group {
        justify-content: center;
    }
    .action-buttons .zoom-group {
        justify-content: center;
    }
    .action-buttons .btn {
        width: 100%;
        justify-content: center;
    }
    .preview-wrapper {
        padding: 12px;
    }
    .preview-canvas-wrapper {
        min-height: auto;
    }
    .preview-canvas-wrapper canvas,
    .preview-canvas-wrapper img {
        width: 90%;
        max-width: 90%;
    }
    .thumbnails-grid {
        grid-template-columns: repeat(3, 1fr);
        max-height: 50vh;
        padding: 10px;
        gap: 8px;
    }
    .thumbnail-item .page-number {
        font-size: 9px;
        padding: 1px 6px;
    }
    .thumb-pagination {
        gap: 10px;
    }
    .thumb-pagination button {
        padding: 4px 12px;
        font-size: 12px;
    }
    #eps-pages {
        min-width: 100%;
    }
    #clear-page-selection,
    #select-all-pages {
        flex: 1;
        justify-content: center;
    }
}

@media (max-width: 400px) {
    .thumbnails-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}