* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #8b5cf6;
    --danger: #ef4444;
    --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;
}

body {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: #e2e8f0;
    height: 100vh;
    overflow: hidden;
    color: #1e293b;
}

.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;
    flex-shrink: 0;
}

.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: 8px; align-items: center; }

.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;
    font-size: 13px;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-secondary { background: var(--light); color: #1e293b; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-icon {
    padding: 8px 10px;
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
}
.btn-icon:hover { background: var(--light); }

/* ===== دکمه‌های ویژه ===== */
#templatesBtn {
    background: linear-gradient(135deg, #8b5cf6, #3b82f6);
    color: white;
    border: none;
    transition: all 0.3s ease;
}
#templatesBtn:hover {
    background: linear-gradient(135deg, #7c3aed, #2563eb);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(139,92,246,0.3);
}

#bgGalleryBtn {
    background: linear-gradient(135deg, #10b981, #06b6d4);
    color: white;
    border: none;
    transition: all 0.3s ease;
}
#bgGalleryBtn:hover {
    background: linear-gradient(135deg, #059669, #0891b2);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(16,185,129,0.3);
}

/* ===== دکمه‌های هوش مصنوعی ===== */
#aiEditBtn {
    transition: all 0.3s ease !important;
}
#aiEditBtn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 25px rgba(139,92,246,0.5) !important;
}

#aiBuildBtn {
    transition: all 0.3s ease !important;
}
#aiBuildBtn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 25px rgba(16,185,129,0.5) !important;
}

/* ===== بج مودال هوش مصنوعی ===== */
#aiModeBadge {
    font-size: 10px !important;
    padding: 2px 10px !important;
    border-radius: 20px !important;
    margin-right: 8px !important;
    color: white !important;
}

/* ===== فضای کاری ===== */
.workspace {
    display: flex;
    flex: 1;
    padding: 12px;
    gap: 12px;
    overflow: hidden;
    min-height: 0;
}

/* ===== پنل‌ها ===== */
.panel {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: 0.3s;
}
.panel-left { width: 260px; min-width: 260px; }
.panel-right { width: 320px; min-width: 320px; }
.panel.collapsed { width: 48px !important; min-width: 48px !important; }
.panel.collapsed .panel-body { display: none; }

.panel-header {
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    background: #fafafa;
}
.panel-header h3 { font-size: 14px; display: flex; align-items: center; gap: 6px; color: #1e293b; }
.panel-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
}
.panel-toggle:hover { background: var(--light); }

.panel-body { flex: 1; overflow-y: auto; padding: 12px; }

/* ===== بخش‌های پنل ===== */
.elements-section { margin-bottom: 16px; }
.elements-section h4 {
    font-size: 11px;
    color: var(--gray);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e2e8f0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.elements-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.element-card {
    background: var(--white);
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 6px 4px;
    text-align: center;
    cursor: grab;
    transition: 0.15s;
    font-size: 10px;
}
.element-card:hover {
    border-color: var(--primary);
    background: #eff6ff;
    transform: translateY(-1px);
}
.element-card i { font-size: 16px; color: var(--primary); margin-bottom: 2px; display: block; }
.element-card span { font-size: 10px; font-weight: 500; }

.quick-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.quick-actions .btn { flex: 1; min-width: 45px; justify-content: center; font-size: 10px; padding: 4px 6px; }

/* ===== مدیریت صفحات ===== */
.pages-manager { background: var(--light); border-radius: var(--radius-sm); padding: 6px; }
.pages-list { max-height: 150px; overflow-y: auto; }
.page-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    margin-bottom: 3px;
    background: var(--white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: 0.15s;
    border: 1px solid transparent;
    font-size: 12px;
}
.page-item:hover { border-color: var(--primary); }
.page-item.active { background: #eff6ff; border-color: var(--primary); }
.page-name { flex: 1; font-size: 12px; font-weight: 500; }
.page-actions { display: flex; gap: 3px; }
.page-actions button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    color: var(--gray);
    font-size: 11px;
}
.page-actions button:hover { background: var(--light); color: var(--danger); }
.btn-add-page { width: 100%; margin-top: 6px; justify-content: center; font-size: 11px; padding: 4px; }

/* ===== بوم ===== */
.canvas-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #cbd5e1;
    border-radius: var(--radius);
    overflow: hidden;
    min-width: 0;
}

.canvas-toolbar {
    background: var(--white);
    padding: 6px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.page-indicator { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--primary); }
.zoom-controls { display: flex; align-items: center; gap: 6px; }
.zoom-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #e2e8f0;
    background: var(--white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
}
.zoom-btn:hover { background: var(--light); }
#zoomLevel { font-size: 12px; min-width: 40px; text-align: center; }

.canvas-wrapper {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 12px;
    background: #94a3b8;
    transition: background 0.3s ease;
}

.canvas {
    background: var(--white);
    box-shadow: var(--shadow-lg);
    position: relative;
    transition: transform 0.2s, background 0.3s ease;
    transform-origin: top center;
    width: 1100px;
    min-height: 700px;
    background-image: linear-gradient(to right, #e2e8f0 1px, transparent 1px),
                      linear-gradient(to bottom, #e2e8f0 1px, transparent 1px);
    background-size: 20px 20px;
}

.canvas-status {
    background: var(--white);
    padding: 4px 14px;
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--gray);
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

/* ===== عناصر بوم ===== */
.element {
    position: absolute;
    cursor: move;
    transition: outline 0.1s;
}
.element.selected { outline: 2px solid var(--primary); outline-offset: 2px; }
.element.has-link { outline: 1px dashed var(--primary); }

.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; }

/* ===== پنل ویرایشگر ===== */
.property-group { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid #e2e8f0; }
.property-group h4 { font-size: 11px; margin-bottom: 6px; color: var(--gray); }
.property-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; gap: 6px; }
.property-label { font-size: 11px; font-weight: 500; min-width: 60px; }
.property-input {
    padding: 4px 6px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 11px;
    flex: 1;
}
.property-textarea {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-family: inherit;
    resize: vertical;
    font-size: 11px;
}
.color-input {
    width: 32px;
    height: 32px;
    padding: 2px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.slider-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.slider-row input[type="range"] { flex: 1; }
.slider-row span { font-size: 11px; min-width: 30px; }

.no-selection { text-align: center; padding: 30px 12px; color: var(--gray); }
.no-selection i { font-size: 40px; margin-bottom: 8px; opacity: 0.5; }
.no-selection p { font-size: 13px; }
.no-selection small { font-size: 11px; }

/* ===== گالری پس‌زمینه ===== */
#backgroundGallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 8px 0;
}

.bg-item {
    transition: all 0.25s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    width: 90px;
    height: 65px;
    border-radius: 10px;
    border: 3px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 500;
    text-align: center;
    padding: 4px;
    word-break: break-all;
}

.bg-item:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    z-index: 2;
}

.bg-item.active {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.3);
}

.bg-item span {
    position: relative;
    z-index: 1;
}

.bg-item .bg-type {
    position: absolute;
    bottom: 3px;
    right: 5px;
    font-size: 7px;
    opacity: 0.6;
    background: rgba(0,0,0,0.4);
    padding: 1px 6px;
    border-radius: 4px;
    color: white;
}

/* ===== قالب‌ها ===== */
.template-card {
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.template-card:hover {
    border-color: #3b82f6 !important;
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.1) !important;
}

.template-card .template-load {
    transition: all 0.25s ease;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border: none;
    color: white;
}

.template-card .template-load:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(59,130,246,0.4);
}

/* ===== پروژه‌ها ===== */
.project-item {
    transition: all 0.2s ease;
}

.project-item:hover {
    border-color: #3b82f6 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* ===== مودال‌ها ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}
.modal.active { display: flex; }
.modal-content {
    background: var(--white);
    border-radius: 16px;
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    overflow: hidden;
    animation: modalIn 0.3s ease;
}
.modal-large { max-width: 720px; }
.modal-header {
    padding: 10px 16px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { font-size: 15px; }
.modal-close {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--light); }
.modal-body { padding: 14px 16px; max-height: 60vh; overflow-y: auto; }
.modal-footer {
    padding: 10px 16px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-15px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ===== آپلود ===== */
.upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: 0.15s;
}
.upload-area:hover { border-color: var(--primary); background: #f8fafc; }
.upload-area i { font-size: 30px; color: var(--gray); margin-bottom: 4px; }

.url-input { display: flex; gap: 6px; margin-top: 10px; }
.url-input input { flex: 1; padding: 5px 8px; border: 1px solid #e2e8f0; border-radius: var(--radius-sm); font-family: inherit; font-size: 12px; }

.code-actions { display: flex; gap: 6px; margin-bottom: 10px; }
pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 11px;
    line-height: 1.5;
    font-family: monospace;
    max-height: 350px;
}

/* ===== پیش‌نمایش موبایل ===== */
#mobilePreviewModal .modal-content {
    max-width: 1000px;
    width: 95%;
}

.preview-device-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    min-height: 500px;
    transition: all 0.3s ease;
}

.preview-device-container.device-mobile {
    padding: 10px 0;
}

.preview-device-container.device-tablet {
    padding: 10px 0;
}

.preview-device-container.device-desktop {
    padding: 0;
}

#previewIframe {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
    background: white;
}

.preview-device-container.device-mobile #previewIframe {
    border-radius: 40px !important;
    box-shadow: 0 8px 40px rgba(0,0,0,0.4), inset 0 0 0 2px #1e293b;
}

.preview-device-container.device-tablet #previewIframe {
    border-radius: 24px !important;
    box-shadow: 0 8px 40px rgba(0,0,0,0.3), inset 0 0 0 2px #1e293b;
}

.preview-device-container.device-desktop #previewIframe {
    border-radius: 12px !important;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}

.device-btn {
    transition: all 0.25s ease;
    border: 2px solid transparent !important;
}

.device-btn.active {
    border-color: #3b82f6 !important;
    background: #eff6ff !important;
    color: #3b82f6 !important;
}

.device-btn:hover {
    transform: translateY(-2px);
}

#qrCodeContainer img {
    transition: all 0.3s ease;
}

#qrCodeContainer img:hover {
    transform: scale(1.05);
}

#previewLinkDisplay input {
    transition: all 0.2s ease;
    direction: ltr !important;
    text-align: left !important;
}

#previewLinkDisplay input:hover {
    border-color: #3b82f6 !important;
    background: #eff6ff !important;
}

/* ===== ریسپانسیو ===== */
@media (max-width: 768px) {
    .panel-left { width: 200px !important; min-width: 200px !important; }
    .panel-right { width: 250px !important; min-width: 250px !important; }
    .elements-grid { grid-template-columns: repeat(2, 1fr); }
    .element { position: relative !important; margin-bottom: 12px; width: 100% !important; left: 0 !important; top: 0 !important; }
    .element[data-type="table"] { overflow-x: auto !important; display: block !important; }
    .element[data-type="table"] table { min-width: 280px !important; }
    .element[data-type="video"] iframe { height: 180px !important; }
    .element[data-type="slider"] { height: 300px !important; }
    .slider-item .slider-content h2 { font-size: 20px !important; }
    .slider-item .slider-content p { font-size: 14px !important; }
    .slider-item .slider-content .slider-btn { font-size: 13px !important; padding: 8px 18px !important; }
    .slider-prev-btn, .slider-next-btn { width: 32px !important; height: 32px !important; font-size: 14px !important; }
    .slider-prev-btn { right: 8px !important; }
    .slider-next-btn { left: 8px !important; }
    .card-title { font-size: 0.95em !important; }
    .card-text { font-size: 0.85em !important; }
    .logo-text { font-size: 18px !important; }
    .logo-container img { height: 32px !important; }
    .footer-container div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; gap: 20px !important; }
    .bg-item { width: 70px; height: 50px; font-size: 8px; }
    
    /* پیش‌نمایش موبایل - ریسپانسیو */
    #mobilePreviewModal .modal-body {
        flex-direction: column !important;
        align-items: center !important;
    }
    
    #mobilePreviewModal .modal-body > div:first-child {
        width: 100% !important;
        min-width: unset !important;
        padding: 12px !important;
    }
    
    #mobilePreviewModal .modal-body > div:last-child {
        width: 100% !important;
        flex: unset !important;
    }
    
    .preview-device-container {
        min-height: 400px !important;
    }
    
    #previewIframe {
        width: 320px !important;
        height: 640px !important;
    }
}

@media (max-width: 480px) {
    .header { padding: 6px 12px; }
    .logo span { font-size: 14px; }
    .btn { padding: 4px 8px; font-size: 10px; }
    .panel-left { width: 160px !important; min-width: 160px !important; }
    .panel-right { width: 200px !important; min-width: 200px !important; }
    .elements-grid { grid-template-columns: repeat(2, 1fr); }
    .element[data-type="video"] iframe { height: 140px !important; }
    .element[data-type="slider"] { height: 220px !important; }
    .card-img { height: 120px !important; }
    .slider-item .slider-content h2 { font-size: 16px !important; }
    .slider-item .slider-content p { font-size: 12px !important; }
    .slider-item .slider-content .slider-btn { font-size: 11px !important; padding: 6px 14px !important; }
    .slider-prev-btn, .slider-next-btn { width: 28px !important; height: 28px !important; font-size: 12px !important; }
    .modal-content { max-width: 95%; margin: 10px; border-radius: 12px; }
    .modal-large { max-width: 95%; }
    .template-card { padding: 10px 12px !important; }
    .template-card .template-load { font-size: 10px !important; padding: 4px 10px !important; }
    .bg-item { width: 60px; height: 44px; font-size: 7px; }
    
    #previewIframe {
        width: 280px !important;
        height: 560px !important;
    }
    
    #mobilePreviewModal .modal-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    #mobilePreviewModal .modal-header > div {
        width: 100%;
        justify-content: center;
    }
    
    .device-btn {
        font-size: 10px !important;
        padding: 3px 8px !important;
    }
}

/* ===== اسکرول ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #e2e8f0; }
::-webkit-scrollbar-thumb { background: var(--gray); border-radius: 10px; }
/* ============================================================ */
/* ===== انیمیشن‌ها و افکت‌ها ===== */
/* ============================================================ */

/* ===== حالت‌های کلی ===== */
.element {
    transition: transform 0.3s ease, box-shadow 0.3s ease, filter 0.3s ease;
}

.element.animating {
    pointer-events: none;
}

/* ===== انیمیشن‌های ورود ===== */
.animate-fadeIn {
    animation: fadeIn 0.6s ease-out both;
}
.animate-fadeInUp {
    animation: fadeInUp 0.6s ease-out both;
}
.animate-fadeInDown {
    animation: fadeInDown 0.6s ease-out both;
}
.animate-fadeInLeft {
    animation: fadeInLeft 0.6s ease-out both;
}
.animate-fadeInRight {
    animation: fadeInRight 0.6s ease-out both;
}
.animate-zoomIn {
    animation: zoomIn 0.6s ease-out both;
}
.animate-zoomOut {
    animation: zoomOut 0.6s ease-out both;
}
.animate-slideInUp {
    animation: slideInUp 0.6s ease-out both;
}
.animate-slideInDown {
    animation: slideInDown 0.6s ease-out both;
}
.animate-slideInLeft {
    animation: slideInLeft 0.6s ease-out both;
}
.animate-slideInRight {
    animation: slideInRight 0.6s ease-out both;
}
.animate-bounceIn {
    animation: bounceIn 0.8s ease both;
}
.animate-rotateIn {
    animation: rotateIn 0.7s ease-out both;
}
.animate-flipInX {
    animation: flipInX 0.6s ease-out both;
}
.animate-flipInY {
    animation: flipInY 0.6s ease-out both;
}
.animate-lightSpeedIn {
    animation: lightSpeedIn 0.8s ease-out both;
}

/* ===== انیمیشن‌های هاور ===== */
.element.has-hover-animation {
    cursor: pointer;
    transition: transform var(--hover-duration, 0.3s) var(--hover-easing, ease-out),
                box-shadow var(--hover-duration, 0.3s) var(--hover-easing, ease-out),
                filter var(--hover-duration, 0.3s) var(--hover-easing, ease-out);
}

.element.has-hover-animation:hover {
    transform: var(--hover-transform, scale(1));
    box-shadow: var(--hover-shadow, none);
}

.element.has-hover-animation[data-animation-hover="glow"]:hover {
    filter: brightness(1.1) drop-shadow(0 0 20px rgba(59,130,246,0.5));
}
.element.has-hover-animation[data-animation-hover="float"]:hover {
    animation: floatAnim 2s ease-in-out infinite;
}
.element.has-hover-animation[data-animation-hover="pulse"]:hover {
    animation: pulseAnim 1s ease-in-out infinite;
}
.element.has-hover-animation[data-animation-hover="bounce"]:hover {
    animation: bounceAnim 0.8s ease infinite;
}
.element.has-hover-animation[data-animation-hover="wobble"]:hover {
    animation: wobbleAnim 0.6s ease infinite;
}

/* ===== انیمیشن‌های کلیک ===== */
.element[data-animation-click="pop"]:active {
    transform: scale(0.85) !important;
    transition: transform 0.15s ease !important;
}
.element[data-animation-click="squish"]:active {
    transform: scale(0.8, 0.9) !important;
    transition: transform 0.15s ease !important;
}
.element[data-animation-click="shake"]:active {
    animation: shakeAnim 0.4s ease !important;
}
.element[data-animation-click="bounce"]:active {
    animation: bounceClickAnim 0.4s ease !important;
}
.element[data-animation-click="flash"]:active {
    animation: flashAnim 0.2s ease !important;
}

/* ===== کی‌فریم‌های اصلی ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInLeft { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fadeInRight { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes zoomIn { from { opacity: 0; transform: scale(0.5); } to { opacity: 1; transform: scale(1); } }
@keyframes zoomOut { from { opacity: 0; transform: scale(1.3); } to { opacity: 1; transform: scale(1); } }
@keyframes slideInUp { from { transform: translateY(50px); } to { transform: translateY(0); } }
@keyframes slideInDown { from { transform: translateY(-50px); } to { transform: translateY(0); } }
@keyframes slideInLeft { from { transform: translateX(-50px); } to { transform: translateX(0); } }
@keyframes slideInRight { from { transform: translateX(50px); } to { transform: translateX(0); } }
@keyframes bounceIn { 0% { opacity: 0; transform: scale(0.3); } 50% { opacity: 1; transform: scale(1.05); } 70% { transform: scale(0.9); } 100% { transform: scale(1); } }
@keyframes rotateIn { from { opacity: 0; transform: rotate(-200deg) scale(0.5); } to { opacity: 1; transform: rotate(0) scale(1); } }
@keyframes flipInX { from { opacity: 0; transform: perspective(400px) rotateX(90deg); } to { opacity: 1; transform: perspective(400px) rotateX(0); } }
@keyframes flipInY { from { opacity: 0; transform: perspective(400px) rotateY(90deg); } to { opacity: 1; transform: perspective(400px) rotateY(0); } }
@keyframes lightSpeedIn { from { opacity: 0; transform: translateX(100px) skewX(-30deg); } to { opacity: 1; transform: translateX(0) skewX(0); } }

/* ===== کی‌فریم‌های هاور ===== */
@keyframes floatAnim { 0%, 100% { transform: translateY(-6px); } 50% { transform: translateY(-14px); } }
@keyframes pulseAnim { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes bounceAnim { 0%, 100% { transform: scale(1); } 30% { transform: scale(1.15); } 60% { transform: scale(0.9); } }
@keyframes wobbleAnim { 0%, 100% { transform: rotate(0) scale(1); } 25% { transform: rotate(-3deg) scale(1.03); } 75% { transform: rotate(3deg) scale(1.03); } }

/* ===== کی‌فریم‌های کلیک ===== */
@keyframes shakeAnim { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-6px); } }
@keyframes bounceClickAnim { 0% { transform: scale(0.8); } 30% { transform: scale(1.1); } 60% { transform: scale(0.95); } 100% { transform: scale(1); } }
@keyframes flashAnim { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(2); } }

/* ===== استایل‌های بخش انیمیشن در پنل ===== */
.animation-section {
    background: #f8fafc;
    border-radius: 6px;
    margin-bottom: 4px;
}
.animation-section summary {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #1e293b;
    user-select: none;
}
.animation-section summary:hover {
    background: #f1f5f9;
    border-radius: 6px;
}
.animation-section .animation-details {
    padding: 8px 10px 10px;
    border-top: 1px solid #e2e8f0;
}
.animation-section .property-row {
    margin-bottom: 4px;
}
.animation-section .property-label {
    font-size: 10px;
    min-width: 40px;
}
.animation-section .animation-range {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #e2e8f0;
    border-radius: 2px;
    outline: none;
}
.animation-section .animation-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #8b5cf6;
    border-radius: 50%;
    cursor: pointer;
}
.animation-section .animation-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #8b5cf6;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}
.animation-section .animation-value {
    font-size: 10px;
    min-width: 30px;
    color: #64748b;
}
.animation-section .animation-select {
    font-size: 11px;
    padding: 2px 6px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: white;
}

/* ===== دکمه پیش‌نمایش انیمیشن ===== */
#previewAnimBtn {
    background: linear-gradient(135deg, #8b5cf6, #3b82f6);
    color: white;
    border: none;
    transition: all 0.3s ease;
}
#previewAnimBtn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(139,92,246,0.3);
}
#clearAnimBtn {
    background: #ef4444;
    color: white;
    border: none;
    transition: all 0.3s ease;
}
#clearAnimBtn:hover {
    background: #dc2626;
    transform: scale(1.02);
}

/* ===== ریسپانسیو بخش انیمیشن ===== */
@media (max-width: 768px) {
    .animation-section .property-row {
        flex-wrap: wrap;
    }
    .animation-section .property-label {
        min-width: 100%;
        margin-bottom: 2px;
    }
}
/* ===== فلش چرخان برای بخش‌های انیمیشن ===== */
.anim-arrow.rotated {
    transform: rotate(180deg);
}

/* ===== بخش انیمیشن در پنل ===== */
.property-group .animation-select:focus {
    border-color: #8b5cf6;
    outline: none;
    box-shadow: 0 0 0 2px rgba(139,92,246,0.2);
}

.property-group .animation-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #8b5cf6;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.property-group .animation-range::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #8b5cf6;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
/* ================================================================ */
/* ===== سیستم لایه‌ها (قفل کردن عناصر) ===== */
/* ================================================================ */

.layers-count-badge {
    display: inline-block;
    background: #3b82f6;
    color: #fff;
    font-size: 10px;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    padding: 0 5px;
    margin-right: 4px;
    font-weight: 600;
}

.layers-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.layers-list {
    max-height: 260px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px;
    background: #f8fafc;
}

.layers-empty {
    font-size: 12px;
    color: #94a3b8;
    text-align: center;
    padding: 14px 4px;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.15s ease;
}

.layer-item:hover {
    border-color: #3b82f6;
    background: #eff6ff;
}

.layer-item.active {
    border-color: #3b82f6;
    background: #dbeafe;
    box-shadow: 0 0 0 1px #3b82f6;
}

.layer-item.locked {
    background: #fffbeb;
    border-color: #fcd34d;
}

.layer-item.locked.active {
    background: #fef3c7;
    box-shadow: 0 0 0 1px #f59e0b;
}

.layer-icon {
    width: 16px;
    text-align: center;
    color: #64748b;
    font-size: 12px;
    flex-shrink: 0;
}

.layer-item.active .layer-icon {
    color: #3b82f6;
}

.layer-name {
    flex: 1;
    font-size: 12px;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-lock-btn {
    border: none;
    background: transparent;
    color: #94a3b8;
    width: 24px;
    height: 24px;
    border-radius: 5px;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 12px;
    transition: all 0.15s ease;
}

.layer-lock-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.layer-item.locked .layer-lock-btn {
    color: #f59e0b;
}

.layer-item.locked .layer-lock-btn:hover {
    background: #fde68a;
    color: #92400e;
}

.layers-hint {
    font-size: 10px;
    color: #94a3b8;
    line-height: 1.6;
    display: block;
}

/* ===== نشانگر عنصر قفل‌شده روی بوم طراحی ===== */
.element.element-locked {
    outline: 2px dashed #f59e0b !important;
    outline-offset: 2px;
    cursor: not-allowed !important;
}

.element.element-locked::before {
    content: "\f023";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    top: -11px;
    left: -11px;
    width: 22px;
    height: 22px;
    background: #f59e0b;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    z-index: 600;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    pointer-events: none;
}

.element.element-locked .resize-handle {
    display: none !important;
}

.element.element-locked .element-content {
    cursor: not-allowed !important;
}

/* ================================================================ */
/* ===== تحلیل سئو با هوش مصنوعی ===== */
/* ================================================================ */

.seo-analysis-group {
    border-top: 2px dashed #e2e8f0;
    padding-top: 14px;
}

.seo-analysis-desc {
    font-size: 11px;
    color: #64748b;
    line-height: 1.7;
    margin-bottom: 10px;
}

.seo-analysis-result {
    margin-top: 12px;
}

.seo-analysis-result:empty {
    margin-top: 0;
}

.seo-score-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

.seo-score-circle {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    flex-shrink: 0;
}

.seo-score-meta h5 {
    font-size: 13px;
    margin: 0 0 4px 0;
    color: #1e293b;
}

.seo-score-meta p {
    font-size: 11px;
    color: #64748b;
    margin: 0;
}

.seo-check-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.seo-check-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 11.5px;
    line-height: 1.7;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.seo-check-item i {
    margin-top: 2px;
    flex-shrink: 0;
}

.seo-check-item.ok { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.seo-check-item.ok i { color: #22c55e; }
.seo-check-item.warn { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.seo-check-item.warn i { color: #f59e0b; }
.seo-check-item.error { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.seo-check-item.error i { color: #ef4444; }

.seo-ai-notes {
    background: #faf5ff;
    border: 1px solid #e9d5ff;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.9;
    color: #4c1d95;
    white-space: pre-line;
}

.seo-ai-notes h5 {
    font-size: 12px;
    margin: 0 0 6px 0;
    color: #7c3aed;
}

.seo-analysis-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #64748b;
    padding: 10px 4px;
}

.seo-analysis-loading i { color: #3b82f6; }
