/* =====================================================
   Add Blank Pages to PDF - Tool Styles
   ===================================================== */

/* ===== Main Container ===== */
.tool-wrapper[data-tool="add-blank-pages-to-pdf"] {
    font-family: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    color: #1e293b;
}

/* ===== 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: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}
.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;
}

/* ===== Settings Panel ===== */
.tool-settings {
    margin-bottom: 1.25rem;
}
.tool-settings h3 {
    font-size: 1.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: 1.2rem 2rem;
}
.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.option-group label {
    font-weight: 600;
    font-size: 0.85rem;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.option-group label i {
    color: #0067b8;
    width: 1.1rem;
}
.option-select,
.option-input {
    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-select:focus,
.option-input:focus {
    border-color: #0067b8;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 103, 184, 0.12);
}
.option-hint {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.2rem;
}
.option-hint i {
    margin-right: 0.25rem;
    color: #0067b8;
}

/* ===== Color Picker ===== */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.color-picker {
    width: 44px;
    height: 44px;
    padding: 2px;
    border: 1px solid #d1d9e6;
    border-radius: 0.5rem;
    cursor: pointer;
    background: #fff;
    flex-shrink: 0;
}
.color-hex-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d9e6;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    color: #1e293b;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    text-transform: uppercase;
}
.color-hex-input:focus {
    border-color: #0067b8;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 103, 184, 0.12);
}

/* ===== Result Section ===== */
.result-section {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.result-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    flex: 1;
}
.result-title {
    font-weight: 700;
    color: #065f46;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.result-title i {
    color: #0b7e3d;
    font-size: 1.25rem;
}
.result-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.result-info {
    font-size: 0.85rem;
    color: #065f46;
    flex-basis: 100%;
}

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 0.5rem;
}

.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);
}

.btn-sm {
    padding: 0.3rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 1.5rem;
}

/* ===== Progress Bar ===== */
.progress-container {
    background: #e9edf2;
    border-radius: 2rem;
    height: 28px;
    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.75rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: 0.3px;
}

/* ===== 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;
}
.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: flex;
    align-items: center;
    gap: 0.6rem;
}
.warning-message i {
    color: #f59e0b;
    font-size: 1rem;
}

/* ===== 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;
}
.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;
}
.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;
}

/* ===== Thumbnails Section ===== */
.thumbnails-section {
    margin: 1rem 0 0 0;
}
.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;
}

/* ===== Upload Area ===== */
.upload-area {
    background: #ffffff;
    border: 2px dashed #dbe0e8;
    border-radius: 1rem;
    padding: 2.5rem 1.5rem;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.02);
    cursor: pointer;
}
.upload-area:hover {
    border-color: #0067b8;
    background: #f9fcff;
}
.upload-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.upload-icon {
    font-size: 3rem;
    color: #0067b8;
    opacity: 0.7;
}
.upload-text {
    font-size: 1.3rem;
    font-weight: 600;
    color: #0f172a;
}
.upload-hint {
    font-size: 0.95rem;
    color: #64748b;
    margin-bottom: 0.25rem;
}
.upload-btn {
    background: #0067b8;
    border: none;
    padding: 0.7rem 2rem;
    border-radius: 2rem;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    transition: background 0.2s, box-shadow 0.2s;
    margin-top: 0.25rem;
}
.upload-btn:hover {
    background: #005499;
    box-shadow: 0 4px 12px rgba(0, 103, 184, 0.25);
}

/* ===== Hidden ===== */
.hidden {
    display: none !important;
}

/* =====================================================
   Responsive
   ===================================================== */

@media (max-width: 1024px) {
    .options-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem 1.5rem;
    }
    .thumbnails-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .tool-wrapper[data-tool="add-blank-pages-to-pdf"] {
        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;
    }
    .thumbnail-item .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;
    }
    .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;
    }
    .color-picker-wrapper {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .upload-area {
        padding: 1.5rem 1rem;
    }
    .upload-text {
        font-size: 1rem;
    }
    .upload-icon {
        font-size: 2.5rem;
    }
    .upload-btn {
        padding: 0.5rem 1.5rem;
        font-size: 0.85rem;
    }
    .editor-layout {
        padding: 0.75rem;
    }
    .thumbnails-grid {
        grid-template-columns: repeat(2, 1fr);
        padding: 8px;
        gap: 6px;
    }
    .thumbnail-item .page-number {
        font-size: 8px;
        padding: 1px 4px;
        bottom: 4px;
        right: 4px;
    }
    .thumbnail-item .selection-badge {
        width: 18px;
        height: 18px;
        font-size: 10px;
        top: 4px;
        left: 4px;
    }
    .tool-settings h3 {
        font-size: 1rem;
    }
    .btn {
        padding: 0.4rem 1.2rem;
        font-size: 0.8rem;
    }
    .result-section {
        padding: 0.75rem 1rem;
    }
    .result-title {
        font-size: 0.9rem;
    }
    .page-selection-group {
        padding: 0.75rem 1rem;
    }
}

/* ===== RTL Support ===== */
html[dir="rtl"] .btn i,
html[dir="rtl"] .upload-btn i {
    margin-left: 0.4rem;
    margin-right: 0;
}
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;
}