﻿/* За админ заглавната лента */
.admin-header, .site-header {
    position: sticky;
    top: 0;
    z-index: 1050; /* Над всичко останало */
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* За тулбара на редактора - под заглавната лента */
.tiptap-toolbar {
    position: sticky;
    top: 160px; /* Стойността на височината на твоя админ хедър */
    z-index: 1040;
    background: white;
}


.cms-block-standard {
    width: 100%;
}

.cms-block-specific {
    width: 100%;
}

.cms-block-empty {
    color: #888;
    font-style: italic;
    padding: 1rem 0;
}

/* EDIT MODE — рамка + hover */
.cms-block-host-edit {
    position: relative;
    border: 2px dashed transparent;
    padding: 0;
    margin: 0;
    background: none;
}

    .cms-block-host-edit:hover {
        border-color: #007bff;
        background: rgba(0, 123, 255, 0.05);
    }

/* Бутоните се появяват само при hover */
.hover-tools {
    position: absolute;
    top: -14px;
    right: -14px;
    display: none;
    gap: 6px;
}

.cms-block-host-edit:hover .hover-tools {
    display: flex;
}

.tiptap-editor {
    display: block;
    width: 100%;
    min-height: 150px;
    border: 1px solid #ccc;
    padding: 12px;
    border-radius: 6px;
}

    .tiptap-editor .ProseMirror {
        outline: none;
        min-height: 150px;
    }

/*           _______       ! ! !        __________        */

/* Основният контейнер */
.cms-image-text-block {
    border-radius: 8px; /* Опционално, за по-мек вид при наличие на фон */
    transition: background-color 0.3s ease;
    overflow: hidden; /* Важно за заоблянето на ъглите */
    transition: all 0.2s ease;
}

/* Основен стил за картинката */
.cms-image-text-block img {
    width: var(--image-width, auto);
    max-width: 100%;
    height: auto;
    transition: all 0.3s ease;
    /* Подобрява изобразяването */
    object-fit: cover;
    image-rendering: -webkit-optimize-contrast;
    aspect-ratio: attr(width) / attr(height); /* Запазва мястото на картинката преди да се зареди */
}

/* Това гарантира, че текстът и картинката са винаги подравнени, 
   независимо дали блокът има фон или не */
.cms-content-wrapper {
    padding: 2rem; /* Еднакво отстояние за всички блокове */
    width: 100%;
}

/* Контейнерът на текста */
.cms-block-text {
    flex: 1;
    display: block;
    line-height: 1.6;
}

    .cms-block-text a {
        /* Използва променливата, ако я има, иначе пада до синьо (#007bff) */
        color: var(--cms-link-color, #007bff) !important;
        text-decoration: underline;
        transition: filter 0.2s;
    }

        .cms-block-text a:hover {
            filter: brightness(1.2); /* Автоматично леко "светване" при посочване */
            text-decoration: double underline;
        }

/* Когато блокът е в Edit Mode, линковете също трябва да са видими */
.tiptap-editor a {
    color: var(--cms-link-color, #007bff);
}


/* TipTap Viewer - правим го inline, за да може текстът вътре да обтича картинката */
[id^="viewer-"] {
    display: inline;
}

/* Гарантираме, че TipTap и Viewer наследяват цвета */
.cms-block-text,
[id^="viewer-"],
.tiptap.ProseMirror {
    color: inherit; /* Взима цвета от GetTextStyles() */
}

/* РЕСПОНСИВ ЛОГИКА */
@media (max-width: 767.98px) {
    .cms-image-text-block img {
        /* На мобилни картинката е винаги центрирана и голяма */
        width: 100% !important;
        float: none !important;
        margin: 0 0 1.5rem 0 !important; /* Разстояние само отдолу */
        display: block;
    }

    /* Нулираме отместванията, които Bootstrap класовете (ms-md-4 / me-md-4) биха добавили */
    .cms-image-text-block .ms-md-4,
    .cms-image-text-block .me-md-4 {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* _________________________________________________________________ */

/* Стилизиране на таблиците  */
.table {
    border-collapse: collapse;
    table-layout: fixed;
    width: 100%;
    margin: 0;
    overflow: hidden;
}

.td,
.th {
    min-width: 1em;
    /* Светло сива пунктирана линия, за да виждаш клетките без да пречи на дизайна */
    border: 1px dashed #ced4da;
    padding: 3px 5px;
    vertical-align: top;
    box-sizing: border-box;
    position: relative;
}

/* Когато клетката е маркирана или активна */
.selectedCell:after {
    background: rgba(200, 200, 255, 0.4);
    content: "";
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    pointer-events: none;
    position: absolute;
    z-index: 2;
}

/* Когато минеш с мишката над таблица - показваме по-ясно рамките */
.table:hover td {
    border-color: #adb5bd;
}

/*   -----------------------------------------------------    */
/* The Sidebar Container */
.cms-inspector-pane {
    position: fixed;
    top: 0;
    right: -450px; /* Start hidden */
    width: 400px;
    height: 100vh;
    background: var(--bs-body-bg, #fff);
    color: var(--bs-body-color, #212529);
    box-shadow: -5px 0 25px rgba(0,0,0,0.15);
    z-index: 2000; /* Above the sticky header */
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

    .cms-inspector-pane.open {
        right: 0;
    }

.inspector-header {
    padding: 1rem;
    background: var(--bs-tertiary-bg, #f8f9fa);
    color: var(--bs-emphasis-color, #212529);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
/*  _____________________________________________________  */

.upload-zone {
    border: 2px dashed #dee2e6 !important;
    background: #f8f9fa;
    transition: all 0.2s;
}

    .upload-zone:hover {
        background: #e9ecef;
        border-color: #0d6efd !important;
    }

.cursor-pointer {
    cursor: pointer;
}

.tiny-label {
    font-size: 0.65rem;
    font-weight: bold;
}

/*  ______________________________________  */

.web-style-editor {
    display: grid;
    gap: 0.75rem;
}

.style-editor-accordion {
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.5rem;
    background: var(--bs-body-bg, #fff);
    overflow: hidden;
}

.style-editor-group-button {
    width: 100%;
    min-height: 3rem;
    padding: 0.65rem 0.85rem;
    border: 0;
    background: var(--bs-tertiary-bg, #f8f9fa);
    color: var(--bs-body-color, #212529);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 1.125rem;
    font-weight: 600;
    text-align: left;
}

.style-editor-group-button:hover,
.style-editor-group-button:focus-visible {
    background: var(--bs-secondary-bg, #e9ecef);
    outline: none;
}

.style-editor-group-content {
    padding: 0.9rem;
}

.style-editor-subsection-title {
    margin-bottom: 0.65rem;
    color: var(--bs-secondary-color, #6c757d);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.style-editor-divider {
    height: 1px;
    margin: 1.1rem 0;
    background: var(--bs-border-color, #dee2e6);
}

.style-editor-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.style-editor-spacing-grid {
    grid-template-columns: 1fr;
}

.style-editor-preset-category {
    margin: 0.8rem 0 0.4rem;
    color: var(--bs-secondary-color, #6c757d);
    font-size: 0.8125rem;
    font-weight: 700;
}

.style-editor-preset-category:first-child {
    margin-top: 0;
}

.style-editor-preset-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.style-editor-preset {
    min-height: 2.2rem;
    padding: 0.35rem 0.55rem;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 0.35rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.style-editor-switch {
    margin-bottom: 0.9rem;
    font-size: 0.9375rem;
}

.style-editor-switch .form-check-input {
    cursor: pointer;
}

.style-editor-image-picker {
    font-size: 0.9375rem;
}

.style-editor-select-field {
    min-width: 0;
}

.style-editor-select-field label,
.style-property-label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--bs-body-color, #343a40);
    font-size: 0.9375rem;
    font-weight: 600;
}

.style-editor-select-field .form-select,
.style-editor-image-picker .form-control,
.style-editor-image-picker .btn,
.style-property-editor .form-control,
.style-property-editor .form-range {
    font-size: 0.9375rem;
}

.style-property-editor {
    min-width: 0;
}

.style-property-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.style-property-header .style-property-label {
    margin-bottom: 0;
}

.style-property-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex: 0 0 auto;
    margin: 0;
    font-size: 0.875rem;
}

.style-property-toggle .form-check-input {
    margin: 0;
    cursor: pointer;
}

.style-property-editor .form-control-color {
    min-height: 2.45rem;
}

@media (max-width: 420px) {
    .style-editor-field-grid {
        grid-template-columns: 1fr;
    }
}
