/* =====================================================
   RESCALE PDF TOOL - Additional Styles (No conflicts)
   ===================================================== */

/* Editor layout: two columns */
.editor-layout {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-top: 20px;
}

@media (min-width: 992px) {
    .editor-layout {
        flex-direction: row;
        align-items: flex-start;
    }
    .preview-box {
        flex: 1.2;
        position: sticky;
        top: 20px;
    }
    .tool-settings {
        flex: 0.9;
        margin-top: 0;
    }
}

/* Preview toolbar (pagination) */
.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
    background: #f9fafb;
    border-bottom: 1px solid var(--border, #e5e7eb);
    border-radius: 12px 12px 0 0;
}

.preview-toolbar button {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    color: #1f2937;
    min-width: 38px;
}

.preview-toolbar button:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.preview-toolbar input {
    width: 60px;
    text-align: center;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
}

/* Ensure canvas inside preview-box is properly styled */
.preview-box {
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: var(--card-shadow, 0 1px 3px rgba(0,0,0,0.1));
}

/* Override any conflicting .preview-box margin from tools.css */
.preview-box {
    margin: 0;
}

/* Tool settings panel - ensure hidden class works */
.tool-settings.hidden {
    display: none !important;
}

/* Editor layout hidden initially */
.editor-layout.hidden {
    display: none !important;
}

/* Custom size group (flex row) */
[data-role="custom-size-group"] > div {
    display: flex;
    gap: 8px;
    width: 100%;
}

/* Form controls inside options-grid - ensure consistency */
.option-group .form-control,
.option-group input[type="number"],
.option-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    transition: 0.2s;
}

.option-group .form-control:focus,
.option-group input:focus,
.option-group select:focus {
    outline: none;
    border-color: var(--primary, #00008B);
    box-shadow: 0 0 0 2px rgba(0,0,139,0.1);
}

/* Checkbox label alignment */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal !important;
    cursor: pointer;
}

.checkbox-label input {
    width: 18px;
    height: 18px;
    margin: 0;
}

/* Progress container inside tool-settings */
.progress-container {
    margin-top: 20px;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary, #00008B);
    width: 0%;
    transition: width 0.3s;
}

.progress-text {
    font-size: 13px;
    color: #4b5563;
    text-align: center;
    margin-top: 8px;
}

/* Success & error messages inside tool-settings */
.success-message {
    margin-top: 16px;
    padding: 10px;
    background: #d1fae5;
    color: #065f46;
    border-radius: 8px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Buttons inside tool-settings action-buttons */
.tool-settings .action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
    justify-content: center;
}

.tool-settings .btn {
    padding: 10px 20px;
    border-radius: 40px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.tool-settings .btn-primary {
    background: var(--primary, #00008B);
    color: white;
}

.tool-settings .btn-primary:hover {
    background: #1e40af;
    transform: translateY(-1px);
}

.tool-settings .btn-secondary {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #334155;
}

.tool-settings .btn-secondary:hover {
    background: #e2e8f0;
}

/* Upload area drag-over effect (ensures consistency) */
.upload-area.drag-over {
    border-color: var(--primary, #00008B) !important;
    background-color: rgba(0, 0, 139, 0.05) !important;
    box-shadow: 0 0 0 3px rgba(0,0,139,0.2);
}

/* Ensure file-box doesn't inherit extra margins */
.file-box {
    margin-bottom: 24px;
}

/* Status message (status-message) may be used optionally */
.status-message {
    margin: 20px auto;
    max-width: 600px;
}

/* Ruler styles for rescale-pdf tool */
.preview-canvas-wrap {
    position: relative;
    overflow: auto;
    background: #f5f5f7;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    min-height: 300px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.preview-canvas-wrap canvas {
    display: block;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    background: white;
    margin: 20px; /* مسافة حول الصفحة للمسطرة */
}

.ruler-x, .ruler-y {
    position: absolute;
    pointer-events: none;
    z-index: 10;
    font-family: monospace;
    font-size: 9px;
    color: #333;
}

.ruler-x {
    top: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: #f0f0f0;
    border-bottom: 1px solid #aaa;
}

.ruler-y {
    left: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: #f0f0f0;
    border-right: 1px solid #aaa;
}

.ruler-mark {
    position: absolute;
    white-space: nowrap;
}

.ruler-tick {
    position: absolute;
    background-color: #888;
}

/* Ensure canvas has margin to accommodate rulers */
.preview-canvas-wrap canvas {
    margin: 20px 20px 20px 40px;
    box-shadow: 0 5px 15px rgba(0,0,0,.08);
    background: white;
}

/* Responsive: adjust margins for mobile */
@media (max-width: 768px) {
    .preview-toolbar {
        gap: 8px;
    }
    .tool-settings {
        padding: 16px;
    }
    .file-row {
        flex-direction: column;
        align-items: flex-start;
    }
}