* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --dark: #1e293b;
    --gray: #64748b;
    --light: #f1f5f9;
    --white: #ffffff;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

/* فونت‌های ایرانی */
@font-face {
    font-family: 'IranNastaliq';
    src: local('IranNastaliq'), url('https://cdn.fontcdn.ir/FontPersian/IranNastaliq/IranNastaliq.ttf') format('truetype');
}
@font-face {
    font-family: 'BTitr';
    src: local('BTitrBold'), url('https://cdn.fontcdn.ir/FontPersian/BTitr/BTitrBold.ttf') format('truetype');
}
@font-face {
    font-family: 'BNazanin';
    src: local('BNazanin'), url('https://cdn.fontcdn.ir/FontPersian/BNazanin/BNazanin.ttf') format('truetype');
}
@font-face {
    font-family: 'IranSans';
    src: local('IranSans'), url('https://cdn.fontcdn.ir/FontPersian/IRANSans/IRANSans.ttf') format('truetype');
}

.font-vazirmatn { font-family: 'Vazirmatn', sans-serif; }
.font-amiri { font-family: 'Amiri', serif; }
.font-cairo { font-family: 'Cairo', sans-serif; }
.font-tajawal { font-family: 'Tajawal', sans-serif; }
.font-markazi { font-family: 'Markazi Text', serif; }
.font-iran-nastaliq { font-family: 'IranNastaliq', 'Vazirmatn', serif; }
.font-btitr { font-family: 'BTitr', 'Vazirmatn', sans-serif; }
.font-bnazanin { font-family: 'BNazanin', 'Vazirmatn', sans-serif; }
.font-iransans { font-family: 'IranSans', 'Vazirmatn', sans-serif; }

body {
    font-family: 'Vazirmatn', sans-serif;
    background: #e2e8f0;
    height: 100vh;
    overflow: hidden;
    color: var(--dark);
}

/* ========== حذف خط سیاه دور عناصر قابل ویرایش ========== */
.element-content:focus,
[contenteditable="true"]:focus,
.element-content[contenteditable="true"]:focus,
div[contenteditable="true"]:focus,
.logo-text:focus {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
}

button[contenteditable="true"]:focus {
    outline: none !important;
}

/* ========== استایل پیام راهنما برای زوم مرورگر ========== */
.zoom-message-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 20000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Vazirmatn', sans-serif;
}

.zoom-message-box {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 450px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 35px rgba(0,0,0,0.2);
    direction: rtl;
}

.zoom-message-box i {
    font-size: 48px;
    color: #3b82f6;
    margin-bottom: 16px;
}

.zoom-message-box h3 {
    font-size: 22px;
    margin-bottom: 12px;
    color: #1e293b;
}

.zoom-message-box p {
    font-size: 15px;
    color: #475569;
    line-height: 1.6;
    margin-bottom: 20px;
}

.zoom-message-box .note {
    font-size: 13px;
    color: #ef4444;
    background: #fef2f2;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.checkbox-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    cursor: pointer;
}

.checkbox-container input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-container label {
    font-size: 14px;
    color: #475569;
    cursor: pointer;
}

.zoom-message-btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    font-family: inherit;
}

.zoom-message-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

/* ========== استایل فرم سئو ========== */
.seo-form {
    direction: rtl;
}

.seo-form .property-group {
    margin-bottom: 20px;
}

.seo-form .property-row {
    margin-bottom: 15px;
}

.seo-form .property-label {
    width: 120px;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.header {
    background: var(--white);
    padding: 10px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--primary);
    box-shadow: var(--shadow);
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
}

.logo i {
    color: var(--primary);
    font-size: 24px;
}

.badge {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 20px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--light);
    color: var(--dark);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-icon {
    padding: 8px;
    background: transparent;
}

.btn-icon:hover {
    background: var(--light);
}

.btn-add-page {
    width: 100%;
    margin-top: 10px;
    justify-content: center;
}

.workspace {
    display: flex;
    flex: 1;
    padding: 16px;
    gap: 16px;
    overflow: hidden;
}

.panel {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: 0.2s;
}

.panel-left {
    width: 280px;
    min-width: 280px;
}

.panel-right {
    width: 340px;
    min-width: 340px;
}

.panel.collapsed {
    width: 48px !important;
    min-width: 48px !important;
}

.panel.collapsed .panel-body {
    display: none;
}

.panel-header {
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
    background: var(--white);
}

.panel-header h3 {
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
}

.panel-toggle:hover {
    background: var(--light);
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.elements-section {
    margin-bottom: 24px;
}

.elements-section h4 {
    font-size: 13px;
    color: var(--gray);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e2e8f0;
}

.elements-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.element-card {
    background: var(--white);
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 10px;
    text-align: center;
    cursor: grab;
    transition: 0.15s;
}

.element-card:hover {
    border-color: var(--primary);
    background: #eff6ff;
    transform: translateY(-2px);
}

.element-card i {
    font-size: 20px;
    color: var(--primary);
    margin-bottom: 6px;
    display: block;
}

.element-card span {
    font-size: 12px;
    font-weight: 500;
}

.quick-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* مدیریت صفحات */
.pages-manager {
    background: var(--light);
    border-radius: var(--radius-sm);
    padding: 10px;
}

.pages-list {
    max-height: 200px;
    overflow-y: auto;
}

.page-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: var(--white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: 0.15s;
    border: 1px solid transparent;
}

.page-item:hover {
    border-color: var(--primary);
}

.page-item.active {
    background: #eff6ff;
    border-color: var(--primary);
}

.page-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
}

.page-actions {
    display: flex;
    gap: 6px;
}

.page-actions button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: var(--gray);
}

.page-actions button:hover {
    background: var(--light);
    color: var(--danger);
}

/* بوم طراحی */
.canvas-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #cbd5e1;
    border-radius: var(--radius);
    overflow: hidden;
}

.canvas-toolbar {
    background: var(--white);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
}

.page-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--primary);
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #e2e8f0;
    background: var(--white);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.zoom-btn:hover {
    background: var(--light);
}

.canvas-wrapper {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    background: #94a3b8;
}

.canvas {
    background: var(--white);
    box-shadow: var(--shadow-lg);
    position: relative;
    transition: 0.2s;
    transform-origin: top center;
    width: 1200px;
    min-height: 800px;
}

.canvas-status {
    background: var(--white);
    padding: 6px 16px;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--gray);
    border-top: 1px solid #e2e8f0;
}

/* عناصر قابل ویرایش */
.element {
    position: absolute;
    cursor: move;
    transition: outline 0.1s;
}

.element.selected {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.resize-handle {
    position: absolute;
    bottom: -5px;
    right: -5px;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    cursor: nw-resize;
    opacity: 0;
    transition: 0.15s;
}

.element:hover .resize-handle {
    opacity: 1;
}

/* منوی استیکی (چسبنده) */
.navbar-sticky {
    position: sticky !important;
    top: 0 !important;
    z-index: 1000;
    background: white;
    box-shadow: var(--shadow);
}

/* پنل تنظیمات */
.property-group {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.property-group h4 {
    font-size: 13px;
    margin-bottom: 10px;
    color: var(--gray);
}

.property-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.property-label {
    font-size: 12px;
    font-weight: 500;
}

.property-input {
    width: 140px;
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 12px;
}

.property-textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-family: inherit;
    resize: vertical;
    font-size: 12px;
}

.color-input {
    width: 40px;
    height: 40px;
    padding: 2px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.slider-row input {
    flex: 1;
}

.slider-row span {
    font-size: 12px;
    min-width: 35px;
}

.font-select {
    width: 160px;
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 12px;
}

.no-selection {
    text-align: center;
    padding: 40px 16px;
    color: var(--gray);
}

.no-selection i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* مودال‌ها */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
}

.modal-large {
    max-width: 760px;
}

.modal-header {
    padding: 14px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 22px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: 0.15s;
}

.upload-area:hover {
    border-color: var(--primary);
    background: #f8fafc;
}

.upload-area i {
    font-size: 40px;
    color: var(--gray);
    margin-bottom: 8px;
}

.url-input {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.url-input input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-family: inherit;
}

.image-preview {
    margin-top: 16px;
    text-align: center;
    padding: 10px;
    background: var(--light);
    border-radius: var(--radius-sm);
}

.image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius-sm);
}

.video-preview {
    margin-top: 16px;
    text-align: center;
}

.video-preview video {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius-sm);
    background: #000;
}

.code-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.5;
    font-family: monospace;
}

::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

::-webkit-scrollbar-track {
    background: #e2e8f0;
}

::-webkit-scrollbar-thumb {
    background: var(--gray);
    border-radius: 10px;
}

/* ========== ریسپانسیو هوشمند ========== */
.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--dark);
    padding: 8px;
}

.nav-links-container {
    display: flex;
    gap: 8px;
}

@media (max-width: 1024px) and (min-width: 769px) {
    .panel-left, .panel-right {
        width: 260px;
        min-width: 260px;
    }
    .panel-right {
        width: 300px;
        min-width: 300px;
    }
    body {
        font-size: 0.95rem;
    }
    .element {
        font-size: 0.95em;
    }
    .card-title {
        font-size: 0.95em;
    }
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
    
    .nav-links-container {
        display: none;
        position: absolute;
        top: 60px;
        right: 0;
        left: 0;
        background: white;
        flex-direction: column;
        padding: 16px;
        box-shadow: var(--shadow-lg);
        z-index: 1000;
    }
    
    .nav-links-container.open {
        display: flex;
    }
    
    .nav-link {
        padding: 12px !important;
        text-align: center;
        border-bottom: 1px solid #e2e8f0;
        font-size: 0.95rem;
    }
    
    .panel-left, .panel-right {
        position: absolute;
        z-index: 200;
        background: white;
        box-shadow: var(--shadow-lg);
    }
    .panel-left { left: 16px; top: 70px; }
    .panel-right { right: 16px; top: 70px; }
    
    .page-section {
        width: 100% !important;
        padding: 0 16px;
    }
    
    .element {
        position: relative !important;
        margin-bottom: 20px;
        width: 100% !important;
        left: 0 !important;
        top: 0 !important;
        font-size: 0.9rem;
    }
    
    .element h1, .element h2, .element h3, .element h4,
    .heading, [data-type="heading"] {
        font-size: 0.95em !important;
    }
    
    .element p, .paragraph, [data-type="paragraph"] {
        font-size: 0.9em !important;
    }
    
    .element button, [data-type="button"] {
        font-size: 0.9em !important;
        padding: 8px 16px !important;
    }
    
    .card, [data-type="card"] {
        width: 100% !important;
    }
    
    .card-title {
        font-size: 0.95em !important;
    }
    
    .card-text {
        font-size: 0.85em !important;
    }
    
    .navbar-sticky {
        position: relative !important;
    }
    
    .logo-text {
        font-size: 18px !important;
    }
    
    .logo-container img {
        height: 32px !important;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 8px 16px;
    }
    
    .logo span {
        font-size: 16px;
    }
    
    .badge {
        font-size: 8px;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .page-section {
        padding: 0 12px;
    }
    
    .element {
        margin-bottom: 16px;
        font-size: 0.85rem;
    }
    
    .element h1, .element h2, .element h3, .element h4,
    .heading, [data-type="heading"] {
        font-size: 0.9em !important;
    }
    
    .card-title {
        font-size: 0.9em !important;
    }
    
    .card-text {
        font-size: 0.8em !important;
    }
    
    .logo-text {
        font-size: 16px !important;
    }
}
/* استایل منوی کلیک راست لینک */
.link-context-menu {
    position: fixed;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 30000;
    min-width: 200px;
    overflow: hidden;
    direction: rtl;
}

.link-context-menu .menu-item:hover {
    background: #f8fafc;
}
/* استایل منوی کلیک راست لینک */
.link-context-menu {
    position: fixed;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 30000;
    min-width: 220px;
    overflow: hidden;
    direction: rtl;
}

.link-context-menu .menu-item:hover {
    background: #f8fafc !important;
}

/* استایل دیالوگ سفارشی */
.custom-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 40000;
    display: flex;
    justify-content: center;
    align-items: center;
    direction: rtl;
}

.custom-dialog-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    box-shadow: 0 20px 35px rgba(0,0,0,0.2);
}

.custom-dialog-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.custom-dialog-header h3 {
    margin: 0;
    font-size: 18px;
}

.custom-dialog-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
}

.custom-dialog-body {
    padding: 20px;
}

.custom-dialog-body p {
    margin-bottom: 10px;
    color: #475569;
}

.custom-dialog-footer {
    padding: 16px 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}