:root {
    --primary-bg: #212529;
    --secondary-bg: #495057;
    --button-bg: #343a40;
    --button-hover-bg: #5a6268;
    --active-color: #0d6efd;
    --text-color: #f8f9fa;
    --save-color: #198754;
    --export-color: #dc3545;
    --danger-color: #b30000;
    --selection-color: rgba(13, 110, 253, 0.7);
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: #525659;
    direction: rtl;
    overflow: hidden;
}

/* --- دیزاینا نوو یا Toolbar --- */
#toolbar {
    position: fixed;
    top: 0;
    right: 0;
    width: 60px; /* پانییا کێم */
    height: 100vh;
    background-color: var(--primary-bg);
    color: var(--text-color);
    box-shadow: -4px 0 15px rgba(0,0,0,0.3);
    border-left: 1px solid #4a4a4a;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: center; /* ئایکۆن دکەڤنە ناڤەڕاست */
    padding: 10px 0;
    overflow-y: auto; /* سکڕۆڵ ئەگەر پێدڤی کر */
    gap: 10px;
}

.tool-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 5px 0;
    border-bottom: 1px solid #555;
    margin: 0;
    gap: 5px;
}
.tool-group:last-child {
    border-bottom: none;
}
.tools-main-group {
    flex-wrap: wrap;
    flex-direction: row;
    justify-content: center;
}
.btn-text {
    display: none; /* نڤیسینا ناڤ دوگمەیان ڤەدشێریت */
}

.toolbar button, .upload-label {
    background-color: var(--button-bg);
    color: var(--text-color);
    border: 1px solid #6c757d;
    border-radius: 5px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    width: 45px;
    height: 45px;
    font-size: 22px;
    padding: 0;
    margin: 2px 0;
}
.tool-btn {
    min-width: 45px;
}

.toolbar button:hover, .upload-label:hover {
    background-color: var(--button-hover-bg);
    transform: scale(1.05);
}
.toolbar button:disabled {
    opacity: 0.5; cursor: not-allowed; transform: none;
}
.toolbar .active {
    background-color: var(--active-color);
    border-color: #0a58ca;
    box-shadow: 0 0 8px rgba(13, 110, 253, 0.5);
}

.file-group button, .file-group label { font-weight: bold; }
#save-project-btn { background-color: var(--save-color); }
#export-pdf-btn { background-color: var(--export-color); }
#delete-object-btn:not(:disabled) { background-color: var(--danger-color); }
#delete-object-btn:not(:disabled):hover { background-color: #e00000; }

.settings {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 100%;
    padding: 10px 5px;
}
.settings label, .settings span {
    font-size: 12px;
    text-align: center;
}
.settings input[type="color"]{
    width: 40px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: none;
    margin: 0 auto;
}
.settings input[type="range"]{
    width: 90%;
    margin: 5px auto;
}

.navigation-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 90%;
}
.navigation-group input {
    width: 100%;
    padding: 6px;
    border-radius: 4px;
    border: 1px solid #6c757d;
    background-color: var(--secondary-bg);
    color: var(--text-color);
    text-align: center;
    box-sizing: border-box;
}
.navigation-group button {
    width: 100%;
    height: auto;
    padding: 8px 0;
}


/* --- کانتینەرێ سەرەکی و لابردنا بۆشاییان --- */
#main-container {
    flex-grow: 1;
    overflow: hidden;
    height: 100vh;
    margin-right: 60px; /* جهـ بۆ Toolbar دهێلیت */
}
#pdf-container {
    height: 100%;
    overflow-y: auto;
    padding: 0; /* بۆشایی ژ ڕەخا نامینیت */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0; /* بۆشایی دناڤبەرا لاپەران دا نامینیت */
}
.canvas-wrapper {
    position: relative;
    box-shadow: 0 5px 20px rgba(0,0,0,0.25);
    line-height: 0;
    background-color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    height: auto;
    border: 3px solid transparent;
    transition: border-color 0.3s;
    margin: 0;
    border-radius: 0;
}
.canvas-wrapper.active-page {
    border-color: var(--active-color);
}
.canvas-wrapper canvas {
    max-width: 100%;
    height: auto !important;
}

/* --- پەنچەرا رێکخستنا لاپەران --- */
#page-manager-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: none; 
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}
.page-manager-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px 15px 10px;
    color: white;
    flex-shrink: 0;
}
.page-manager-header h3 { margin: 0; }
.page-manager-header #delete-btn {
    background-color: var(--danger-color);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
}
#close-page-manager {
    background: none;
    border: none;
    color: white;
    font-size: 40px;
    cursor: pointer;
    line-height: 1;
}
#page-thumbnails-container {
    width: 100%;
    flex-grow: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    padding: 10px;
}

.thumbnail-item {
    position: relative;
    border: 2px solid #888;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    background-color: var(--primary-bg);
    display: flex;
    justify-content: center;
    align-items: center;
}
.thumbnail-item:hover { border-color: var(--active-color); }
.thumbnail-item.active-thumbnail { box-shadow: 0 0 10px var(--active-color); }
.thumbnail-item.selected {
    border-color: var(--selection-color);
    box-shadow: 0 0 12px var(--selection-color);
}
.selection-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(13, 110, 253, 0.3);
    display: flex; justify-content: center; align-items: center;
    color: white; font-size: 32px; font-weight: bold;
    opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.thumbnail-item.selected .selection-overlay { opacity: 1; }
.thumbnail-item img { width: 100%; display: block; border-radius: 2px; }
.thumbnail-page-number {
    position: absolute; bottom: 5px; right: 5px;
    background: rgba(0, 0, 0, 0.7); color: white;
    padding: 2px 6px; border-radius: 3px; font-size: 12px;
}

/* --- شێوازێن گشتی --- */
.page-loader { color: #888; font-size: 20px; }
.loader-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.75); z-index: 9999; display: flex;
    justify-content: center; align-items: center; color: white; font-size: 24px;
}
.context-menu {
    position: absolute; z-index: 1001; background-color: var(--primary-bg);
    border: 1px solid #555; border-radius: 5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4); display: flex; padding: 5px;
}
.context-menu .tool-btn { margin: 2px; }

/* --- ستایل بۆ چینی نووسین (Text Layer) --- */
.textLayer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    opacity: 1;
    line-height: 1.0;
    pointer-events: none; 
}

.textLayer > span {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 0%;
}