* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    min-height: 100vh;
    direction: rtl;
}

/* نوار بالا */
.top-bar {
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
    border-bottom: 2px solid #3498db;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: bold;
}

.logo-img {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid #3498db;
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.nav-links a {
    color: #ddd;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 20px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.nav-links a:hover {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: #fff;
    transform: translateY(-2px);
}

/* تب‌های اصلی */
.main-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 2rem auto;
    max-width: 1200px;
    padding: 0 1rem;
}

.main-tab-btn {
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
    flex: 1;
    max-width: 300px;
    justify-content: center;
}

.main-tab-btn:hover {
    background: rgba(52, 152, 219, 0.2);
    border-color: #3498db;
    transform: translateY(-3px);
}

.main-tab-btn.active {
    background: linear-gradient(45deg, #3498db, #2980b9);
    border-color: transparent;
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

/* کانتینر اصلی */
.editor-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* هدر ویرایشگر */
.editor-header {
    text-align: center;
    margin-bottom: 3rem;
}

.editor-header h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(45deg, #3498db, #2ecc71);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.editor-header p {
    font-size: 1.1rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

/* ناحیه آپلود */
.upload-container {
    margin-bottom: 3rem;
}

.upload-area {
    background: rgba(255, 255, 255, 0.05);
    border: 3px dashed rgba(52, 152, 219, 0.5);
    border-radius: 20px;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
    max-width: 600px;
    margin: 0 auto;
}

.upload-area:hover {
    background: rgba(52, 152, 219, 0.1);
    border-color: #3498db;
    transform: scale(1.02);
}

.upload-area.drag-over {
    background: rgba(52, 152, 219, 0.2);
    border-color: #3498db;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.upload-icon {
    font-size: 4rem;
    color: #3498db;
    margin-bottom: 1.5rem;
    opacity: 0.8;
}

.upload-area h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: #fff;
}

.upload-area p {
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

.upload-info {
    font-size: 0.9rem;
    opacity: 0.6;
    margin-top: 1rem;
}

.upload-btn {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 2rem;
}

.upload-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

/* نوار ابزار */
.toolbar {
    background: rgba(0, 0, 0, 0.5);
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 2rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-label {
    color: #3498db;
    font-weight: bold;
    margin-left: 10px;
}

.tool-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.tool-btn:hover {
    background: rgba(52, 152, 219, 0.3);
    border-color: #3498db;
    transform: translateY(-2px);
}

.tool-btn.active {
    background: linear-gradient(45deg, #3498db, #2980b9);
    border-color: transparent;
}

.tool-select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-family: inherit;
    min-width: 120px;
}

.tool-select option {
    background: #1a1a2e;
    color: white;
}

/* محیط کار */
.workspace {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    min-height: 600px;
}

.pdf-viewer {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.viewer-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
    justify-content: center;
}

.viewer-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.viewer-btn:hover {
    background: rgba(52, 152, 219, 0.3);
    border-color: #3498db;
}

#zoomLevel {
    font-weight: bold;
    color: #3498db;
    min-width: 60px;
    text-align: center;
}

.pdf-canvas-container {
    position: relative;
    width: 100%;
    height: 500px;
    background: white;
    border-radius: 5px;
    overflow: auto;
    margin: 0 auto;
}

#pdfCanvas, #drawCanvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.page-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.page-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.page-btn:hover {
    background: rgba(52, 152, 219, 0.3);
    border-color: #3498db;
}

.page-info {
    font-weight: bold;
    color: #3498db;
}

#pageInput {
    padding: 5px 10px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    text-align: center;
}

/* پنل کناری */
.sidebar {
    width: 300px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-section h4 {
    color: #3498db;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
}

.page-thumbnails {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 5px;
}

.page-thumbnail {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
    position: relative;
}

.page-thumbnail:hover {
    background: rgba(52, 152, 219, 0.2);
}

.page-thumbnail.active {
    border-color: #3498db;
    background: rgba(52, 152, 219, 0.1);
}

.page-thumbnail img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 3px;
}

.page-number {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.settings {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.setting-item label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.setting-item select {
    padding: 8px 10px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-family: inherit;
}

.security-settings label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin-bottom: 10px;
}

.security-settings input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.security-settings input[type="password"] {
    padding: 8px 10px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* دکمه‌های اقدام */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 3rem;
}

.action-btn {
    padding: 12px 30px;
    border-radius: 25px;
    border: none;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
    min-width: 180px;
    justify-content: center;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.action-btn:not(:disabled):hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.action-btn:nth-child(1) {
    background: linear-gradient(45deg, #2ecc71, #27ae60);
    color: white;
}

.action-btn:nth-child(2) {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
}

.action-btn:nth-child(3) {
    background: linear-gradient(45deg, #9b59b6, #8e44ad);
    color: white;
}

.action-btn:nth-child(4) {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    color: white;
}

/* بخش ابزارهای PDF */
.tools-section, .convert-section {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.tools-header, .convert-header {
    text-align: center;
    margin-bottom: 3rem;
}

.tools-header h2, .convert-header h2 {
    font-size: 2.2rem;
    margin-bottom: 1rem;
    color: #3498db;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.tool-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.tool-card:hover {
    transform: translateY(-10px);
    border-color: #3498db;
    background: rgba(52, 152, 219, 0.1);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.tool-icon {
    font-size: 3rem;
    color: #3498db;
    margin-bottom: 1.5rem;
}

.tool-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #fff;
}

.tool-card p {
    opacity: 0.8;
    line-height: 1.6;
}

/* بخش تبدیل */
.redirect-notice {
    background: rgba(52, 152, 219, 0.1);
    border: 2px solid #3498db;
    border-radius: 15px;
    padding: 3rem;
    text-align: center;
    margin: 2rem auto;
    max-width: 600px;
}

.redirect-notice i {
    font-size: 4rem;
    color: #3498db;
    margin-bottom: 1.5rem;
}

.redirect-notice p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.redirect-btn {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    padding: 12px 30px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
}

.redirect-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

/* Modal‌ها */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 2rem;
    border-radius: 15px;
    max-width: 800px;
    width: 90%;
    border: 2px solid #3498db;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    color: #3498db;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-manager {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    max-height: 400px;
    overflow-y: auto;
}

#textInput {
    width: 100%;
    padding: 1rem;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    margin: 1rem 0;
    min-height: 150px;
    resize: vertical;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.modal-btn {
    padding: 10px 30px;
    border-radius: 25px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 120px;
}

.modal-btn.primary {
    background: linear-gradient(45deg, #3498db, #2980b9);
    border-color: transparent;
}

.modal-btn:hover {
    transform: translateY(-2px);
}

/* Modal بارگذاری */
.loader {
    text-align: center;
    padding: 2rem;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-top: 5px solid #3498db;
    border-radius: 50%;
    margin: 0 auto 2rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loadingMessage {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* ریسپانسیو */
@media (max-width: 1200px) {
    .workspace {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
    }
    
    .page-thumbnails {
        flex-direction: row;
        overflow-x: auto;
        max-height: 150px;
    }
    
    .page-thumbnail {
        min-width: 100px;
    }
}

@media (max-width: 768px) {
    .top-bar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .main-tabs {
        flex-direction: column;
        align-items: center;
    }
    
    .main-tab-btn {
        width: 100%;
        max-width: 400px;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .tool-group {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .pdf-canvas-container {
        height: 400px;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .action-btn {
        width: 100%;
        max-width: 300px;
    }
    
    .tools-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .editor-header h1 {
        font-size: 2rem;
    }
    
    .upload-area {
        padding: 2rem 1rem;
    }
    
    .tool-btn span {
        display: none;
    }
    
    .tool-btn {
        width: 45px;
        height: 45px;
        justify-content: center;
    }
    
    .pdf-canvas-container {
        height: 300px;
    }
    
    .page-controls {
        flex-wrap: wrap;
    }
}