/* CSS за модалните прозорци за секции */

/* Общи стилове за модалите */
.section-modal, .code-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Съдържание на модалите */
.section-modal-content, .code-modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    min-width: 1280px;
    width: 90%;
    min-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease;
}

.code-modal-content {
    max-width: 800px;
    width: 95%;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header на модалите */
.section-modal-header, .code-modal-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-modal-header h3, .code-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-modal-close, .code-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.section-modal-close:hover, .code-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Body на модалите */
.section-modal-body, .code-modal-body {
    padding: 25px;
    overflow-y: auto;
    max-height: calc(90vh - 160px);
}

/* Form елементи */
.section-form-group {
    margin-bottom: 20px;
}

.section-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.section-form-group input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.2s;
    box-sizing: border-box;
}

.section-form-group input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.section-help-text {
    display: block;
    margin-top: 8px;
    color: #7f8c8d;
    font-size: 12px;
    line-height: 1.4;
}

/* Error съобщения */
.section-error, .code-error {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 6px;
    padding: 12px;
    margin-top: 10px;
    color: #e53e3e;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-error:before, .code-error:before {
    content: "⚠️";
    font-size: 16px;
}

/* Code Editor стилове */
.code-editor-container {
    position: relative;
}

#codeEditor {
    width: 100%;
    height: 400px;
    padding: 16px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    background: #f8f9fa;
    box-sizing: border-box;
    transition: all 0.2s;
}

#codeEditor:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: white;
}

.code-editor-hint {
    margin-top: 12px;
    padding: 12px;
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 6px;
    font-size: 13px;
    color: #1565c0;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.4;
}

.code-editor-hint i {
    margin-top: 2px;
    flex-shrink: 0;
}

/* Footer на модалите */
.section-modal-footer, .code-modal-footer {
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Бутони */
.section-btn, .code-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
    justify-content: center;
}

.section-btn-secondary, .code-btn-secondary {
    background: #6c757d;
    color: white;
}

.section-btn-secondary:hover, .code-btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.section-btn-primary, .code-btn-primary {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
}

.section-btn-primary:hover, .code-btn-primary:hover {
    background: linear-gradient(135deg, #218838 0%, #1ea384 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.section-btn:disabled, .code-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Анимации за зареждане */
.section-btn.loading, .code-btn.loading {
    pointer-events: none;
}

.section-btn.loading i, .code-btn.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive дизайн */
@media (max-width: 768px) {
    .section-modal-content, .code-modal-content {
        width: 95%;
        margin: 20px;
        max-height: calc(100vh - 40px);
    }

    .section-modal-header, .code-modal-header {
        padding: 15px;
    }

    .section-modal-header h3, .code-modal-header h3 {
        font-size: 16px;
    }

    .section-modal-body, .code-modal-body {
        padding: 20px 15px;
        max-height: calc(100vh - 140px);
    }

    .section-modal-footer, .code-modal-footer {
        padding: 15px;
        flex-direction: column;
    }

    .section-btn, .code-btn {
        width: 100%;
    }

    #codeEditor {
        height: 300px;
        font-size: 13px;
    }
}

/* Стилове за custom компоненти в floating menu */
.custom-component {
    border-left: 3px solid #f59e0b !important; /* Златист accent за custom компоненти */
}

.custom-component .menu-label i {
    color: #f59e0b !important; /* Златиста икона */
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% {
        text-shadow: 0 0 5px #f59e0b66;
        transform: scale(1);
    }
    50% {
        text-shadow: 0 0 10px #f59e0b99, 0 0 15px #f59e0b66;
        transform: scale(1.05);
    }
}

.custom-component .current-variant::after {
    content: " ✨";
    color: #f59e0b;
    font-size: 0.8em;
}

/* Delete бутон за custom секции */
.delete-section-btn {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 2px 4px;
    margin-left: 8px;
    border-radius: 3px;
    font-size: 0.8em;
    transition: all 0.2s;
    opacity: 0.7;
}

.delete-section-btn:hover {
    opacity: 1;
    background: #fee2e2;
    color: #dc2626;
    transform: scale(1.1);
}

/* Стилове за create section бутона */
.create-section-btn {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 15px;
}

.create-section-btn:hover {
    background: linear-gradient(135deg, #218838 0%, #1ea384 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.create-section-btn:active {
    transform: translateY(0);
}

/* Validácia стилове */
.section-form-group input.error {
    border-color: #e74c3c;
    background: #fdf2f2;
}

.section-form-group input.success {
    border-color: #27ae60;
    background: #f0fff4;
}

/* Delete Modal Styles */
.delete-warning {
    text-align: center;
    margin-bottom: 25px;
    padding: 20px;
    background: #fef2f2;
    border: 2px solid #fecaca;
    border-radius: 8px;
}

.warning-icon {
    margin-bottom: 15px;
}

.warning-text {
    font-size: 16px;
    margin-bottom: 10px;
    color: #1f2937;
    line-height: 1.5;
}

.warning-subtext {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.4;
}

.delete-confirm-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #fecaca !important;
    border-radius: 8px;
    font-size: 16px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background: #fef2f2;
    transition: all 0.2s;
    box-sizing: border-box;
}

.delete-confirm-input:focus {
    outline: none;
    border-color: #ef4444 !important;
    background: white;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.delete-confirm-input.valid {
    border-color: #10b981 !important;
    background: #f0fdf4;
}

.section-help-text code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    color: #ef4444;
    border: 1px solid #e5e7eb;
}

/* Danger Button */
.section-btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.section-btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.section-btn-danger:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Табов интерфейс за код едитора */
.code-tab-navigation {
    display: flex;
    border-bottom: 2px solid #e1e8ed;
    margin-bottom: 20px;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.code-tab-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: #f8f9fa;
    color: #6c757d;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-bottom: 3px solid transparent;
}

.code-tab-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.code-tab-btn.active {
    background: white;
    color: #667eea;
    border-bottom-color: #667eea;
}

.code-tab-btn.active:hover {
    background: white;
    color: #5a6ab5;
}

/* Табово съдържание */
.code-tab-content {
    display: none;
}

.code-tab-content.active {
    display: block;
}

/* Бърз редактор стилове */
.quick-editor-container {
    height: 500px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

.quick-editor-layout {
    display: flex;
    height: 100%;
}

.quick-editor-preview {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: white;
    border-right: 1px solid #e1e8ed;
    position: relative;
}

.quick-editor-sidebar {
    width: 280px;
    background: #f8f9fa;
    padding: 20px;
    overflow-y: auto;
    border-left: 1px solid #e1e8ed;
}

.quick-editor-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
    font-size: 16px;
    gap: 10px;
}

.quick-editor-info h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-editor-info p {
    margin: 0 0 20px 0;
    font-size: 14px;
    color: #6c757d;
    line-height: 1.5;
}

.quick-editor-controls {
    margin-top: 20px;
}

.quick-btn {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    background: white;
    color: #495057;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.quick-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

.quick-btn-refresh {
    color: #28a745;
    border-color: #28a745;
}

.quick-btn-refresh:hover {
    background: #f8f9fa;
    border-color: #20c997;
    color: #20c997;
}

/* Inline editing стилове */
.quick-editable {
    position: relative;
    cursor: text;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    min-height: 1.2em;
    border: 1px solid transparent;
}

.quick-editable:hover {
    background: #fff3cd;
    border-color: #ffeaa7;
}

.quick-editable.editing {
    background: white;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.quick-editable::before {
    content: "✏️";
    position: absolute;
    right: -25px;
    top: 0;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s;
}

.quick-editable:hover::before {
    opacity: 0.7;
}

.quick-editable.editing::before {
    display: none;
}

/* Error състояние за inline editing */
.quick-editable.error {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

/* Responsive дизайн за табовете */
@media (max-width: 768px) {
    .code-modal-content {
        max-width: 95%;
    }

    .quick-editor-layout {
        flex-direction: column;
    }

    .quick-editor-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid #e1e8ed;
        max-height: 200px;
    }

    .quick-editor-container {
        height: 400px;
    }

    .code-tab-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* Preview секции стилове */
.quick-preview-sections {
    max-height: 100%;
    overflow-y: auto;
}

.preview-section {
    margin-bottom: 20px;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

.preview-section-header {
    background: #f8f9fa;
    padding: 12px 16px;
    border-bottom: 1px solid #e1e8ed;
}

.preview-section-header h5 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-content {
    padding: 16px;
    min-height: 60px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.preview-content:hover {
    background: #f8f9fa;
}

.preview-content:hover::after {
    content: "✏️ Кликнете за редактиране";
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 12px;
    color: #6c757d;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.preview-section-actions {
    padding: 12px 16px;
    background: #f8f9fa;
    border-top: 1px solid #e1e8ed;
    display: flex;
    justify-content: flex-end;
}

.edit-section-btn {
    background: #667eea !important;
    color: white !important;
    border-color: #667eea !important;
}

.edit-section-btn:hover {
    background: #5a6ab5 !important;
    border-color: #5a6ab5 !important;
}

/* Inline editing controls */
.inline-edit-controls {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.inline-edit-textarea {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace !important;
    line-height: 1.4;
    tab-size: 4;
}

.save-inline-btn {
    background: #28a745 !important;
    color: white !important;
    border-color: #28a745 !important;
}

.save-inline-btn:hover {
    background: #218838 !important;
    border-color: #218838 !important;
}

.cancel-inline-btn {
    background: #6c757d !important;
    color: white !important;
    border-color: #6c757d !important;
}

.cancel-inline-btn:hover {
    background: #5a6268 !important;
    border-color: #5a6268 !important;
}

/* Contenteditable preview стилове */
.preview-content-editable {
    padding: 20px;
    border: 2px dashed #e1e8ed;
    border-radius: 8px;
    background: #fafbfc;
    margin-bottom: 15px;
    position: relative;
}

.preview-content-editable::before {
    content: "💡 Кликнете върху текст за редактиране";
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 12px;
    color: #6c757d;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    pointer-events: none;
}

.editable-text {
    transition: all 0.2s;
    border-radius: 4px;
    padding: 2px 4px;
    margin: -2px -4px;
}

.editable-text:hover {
    background-color: #fff3cd !important;
    outline: 2px solid #ffeaa7 !important;
    cursor: text !important;
}

.editable-text:focus {
    background-color: white !important;
    outline: 2px solid #667eea !important;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1) !important;
}

.editable-text[contenteditable="true"]:empty::before {
    content: "Кликнете за редактиране...";
    color: #adb5bd;
    font-style: italic;
}

/* Бутони за запазване/отмяна */
.save-changes-btn {
    background: #28a745 !important;
    color: white !important;
    border-color: #28a745 !important;
    margin-right: 8px;
}

.save-changes-btn:hover {
    background: #218838 !important;
    border-color: #218838 !important;
    transform: translateY(-1px);
}

.reset-changes-btn {
    background: #6c757d !important;
    color: white !important;
    border-color: #6c757d !important;
}

.reset-changes-btn:hover {
    background: #5a6268 !important;
    border-color: #5a6268 !important;
    transform: translateY(-1px);
}