
/* admin_panel/news/news_editor.css */
html, body {
    touch-action: manipulation;
}

:root {
    --background-light: #f0f2f5;
    --card-background: #ffffff;
    --field-background: #ffffff;
    --border-color: #e5e5ea;
    --text-dark: #1c1c1e;
    --text-secondary: #6c757d;
    --primary-blue: #007aff;
    --primary-red: #ff3b30;
    --primary-green: #34c759;
    --theme-red: #FF4D4D; /* Coral - Fixed Color */
}

body.light-theme {
    background: var(--background-light);
}

.news-editor-container {
    max-width: 800px;
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1rem;
}
.main-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    word-break: break-word; /* Allow long titles to wrap */
    min-width: 0;
}

.form-group { margin-bottom: 1.5rem; }
.form-group label:not(.toggle-switch) { display: block; font-weight: 500; margin-bottom: 0.75rem; color: var(--text-secondary); font-size: 0.9rem; padding-left: 0.25rem;}
.form-group input, .form-group textarea {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 26px; /* iOS Style */
    background: var(--field-background);
}

.form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}
#title {
    font-size: 2.5rem;
    font-weight: 700;
    padding: 0.5rem 0;
    border: none;
    background: transparent;
    border-radius: 0;
    border-bottom: 2px solid var(--border-color);
    word-wrap: break-word; /* Allow long titles to wrap */
}
#title:focus { 
    border-bottom-color: var(--primary-blue);
    box-shadow: none;
}

#slug {
    font-family: monospace;
    transition: border-color 0.3s ease;
}
#slug.available {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.15);
}
#slug.unavailable {
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.15);
}
.slug-feedback {
    font-size: 0.8rem;
    margin-top: 0.5rem;
    padding-left: 0.5rem;
}
.slug-feedback.available { color: var(--primary-green); }
.slug-feedback.unavailable { color: var(--primary-red); }


/* === DATETIME BLOCK - STYLED NATIVE INPUTS === */
.datetime-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.date-input-wrapper,
.time-input-wrapper {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* На узких экранах в столбик */
@media (max-width: 480px) {
    .date-input-wrapper,
    .time-input-wrapper {
        flex: 1 1 100%;
    }
}

/* Контейнер для input + иконка */
.datetime-input-container {
    position: relative;
    width: 100%;
}

/* Стилизация нативных input'ов */
.datetime-group input[type="date"],
.datetime-group input[type="time"] {
    width: 100%;
    padding: 1rem;
    padding-right: 3rem; /* Место для иконки */
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 26px;
    background: var(--field-background);
    color: var(--text-dark);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.datetime-group input[type="date"]::-webkit-calendar-picker-indicator,
.datetime-group input[type="time"]::-webkit-calendar-picker-indicator {
    opacity: 0;
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    cursor: pointer;
}

.datetime-group input[type="date"]:hover,
.datetime-group input[type="time"]:hover {
    border-color: var(--primary-blue);
    background: rgba(0, 122, 255, 0.05);
}

.datetime-group input[type="date"]:focus,
.datetime-group input[type="time"]:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

/* Кастомная иконка справа */
.datetime-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    pointer-events: none; /* Иконка не блокирует клики */
    opacity: 0.6;
}


.date-input-wrapper label, .time-input-wrapper label {
    margin-bottom: 0.75rem;
    display: block;
}


/* Block Editor Styles */
#editor-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 2rem;
}
.editor-block {
    position: relative;
    background: var(--card-background);
    border-radius: 26px; /* iOS Style */
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}
.block-actions { display: none; }

.block-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.block-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.footer-delete-btn {
    background: transparent;
    border: none;
    color: var(--primary-red);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 26px; /* iOS Style */
    font-weight: 500;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}
.footer-delete-btn:hover { background-color: rgba(255, 59, 48, 0.1); }
.footer-delete-btn img {
    width: 16px;
    height: 16px;
    filter: invert(39%) sepia(85%) saturate(1495%) hue-rotate(335deg) brightness(100%) contrast(101%);
}

.text-block-content {
    outline: none;
    min-height: 100px;
    font-size: 1.1rem;
    line-height: 1.25;
    color: var(--text-dark);
}
.text-block-content:empty:before {
    content: attr(data-placeholder);
    color: var(--text-secondary);
    pointer-events: none;
    cursor: text;
}
.text-block-content p {
    margin: 0; /* Убираем отступы у параграфов для поведения как у простого переноса строки */
}
.text-block-content h2 { font-size: 1.5em; margin: 1.5em 0 0.5em; }
.text-block-content h3 { font-size: 1.25em; margin: 1.25em 0 0.5em; }

/* --- NEW IMAGE GALLERY STYLES --- */
.image-gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}
.image-slot-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.image-gallery-slot {
    position: relative;
    aspect-ratio: 1 / 1;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    overflow: hidden; /* To clip the image preview */
}
.image-gallery-slot:hover {
    border-color: var(--primary-blue);
    background-color: #f8f9fa;
}
.image-gallery-slot.has-image {
    border-style: solid;
    padding: 0;
}
.image-gallery-placeholder {
    font-size: 2rem;
    color: var(--text-secondary);
}
.slot-image-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.remove-image-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}
.image-gallery-slot:hover .remove-image-btn {
    opacity: 1;
}

.image-alt-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.8rem;
    background-color: var(--field-background);
}
.image-alt-input:focus {
    outline: none;
    border-color: var(--primary-blue);
}
/* --- END NEW STYLES --- */


.add-block-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem;
    margin-top: 1rem;
    border: 2px dashed var(--border-color);
    border-radius: 26px; /* iOS Style */
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 600;
    background: transparent;
    transition: all 0.2s;
}
.add-block-btn:hover {
    border-color: var(--primary-blue);
    color: var(--primary-blue);
    background: rgba(0, 122, 255, 0.05);
}

/* Text Formatting Toolbar */
#text-toolbar {
    display: none; /* Correctly hidden by default */
    background: var(--text-dark);
    border-radius: 26px; /* iOS Style */
    padding: 5px;
    z-index: 10;
    gap: 5px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    margin-bottom: 1rem; /* Space between toolbar and the block */
}
.toolbar-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    width: 36px;
    height: 36px;
    font-size: 1rem;
    border-radius: 20px; /* Smaller radius for inner buttons */
}
.toolbar-btn:hover { background: #444; }
.toolbar-btn.active { background: var(--primary-blue); color: white; }

/* Add Block Modal */
#add-block-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}
.add-block-modal-content {
    background: var(--card-background);
    border-radius: 26px; /* iOS Style */
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 90%;
    max-width: 300px;
}
.add-block-modal-btn {
    padding: 1rem;
    border-radius: 26px; /* iOS Style */
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: transform 0.2s, opacity 0.2s;
}
.add-block-modal-btn:hover {
    transform: scale(1.03);
    opacity: 0.9;
}
.add-block-modal-btn[data-type="text"] {
    background: var(--text-dark);
    color: white;
    border: none;
}
.add-block-modal-btn[data-type="image_gallery"] {
    background: var(--primary-blue);
    color: white;
    border: none;
}

/* Form Actions */
.form-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
}

.form-actions .btn {
    padding: 1rem;
    border-radius: 26px; /* iOS Style */
    font-size: 1rem;
    font-weight: 600;
    border: none;
    height: 54px; /* Set a fixed height */
    line-height: 1;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn-cancel {
    background: var(--text-dark);
    color: white;
}
.btn-cancel:hover {
    opacity: 0.9;
}

/* New Toggle Switch Styles */
.form-group-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--field-background);
    padding: 0.75rem 1.5rem;
    border-radius: 26px;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

/* DEEP FIX for vertical alignment */
.form-group-toggle > label:first-of-type {
    margin-bottom: 0;
    font-weight: 600;
    color: var(--text-dark);
    /* By making the label a flex container, we can perfectly center its text content. */
    display: flex;
    align-items: center;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    flex-shrink: 0; /* Prevent the switch from shrinking */
}
.toggle-switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 28px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: #FF4D4D; /* Coral color */
}
input:checked + .slider:before {
    transform: translateX(22px);
}

/* Override from news.css to make header scroll with the page in admin context */
#header-placeholder {
    position: static;
}

/* NEW SEO SECTION STYLES */
.seo-section {
    background-color: #f8f9fa; /* Slightly off-white */
    border: 1px solid var(--border-color);
    border-radius: 26px;
    padding: 1.5rem;
    margin-top: 2rem;
    color: var(--text-secondary);
}

.seo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.btn-seo-toggle {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    
    background: rgba(255, 255, 255, 0.7); /* Frosted glass */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-dark);
    transition: background 0.2s;
}

.btn-seo-toggle:hover {
    background: rgba(230, 230, 230, 0.7);
}


.seo-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.seo-section .form-group {
    margin-bottom: 1rem;
}

.seo-subtitle {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.seo-input, .seo-status {
    width: 100%;
    padding: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 1px dashed #ccc;
    border-radius: 0;
}
.char-counter {
    font-size: 0.75rem;
    text-align: right;
    color: #8a8a8e;
    margin-top: 4px;
}
.char-counter.over-limit {
    color: var(--primary-red);
    font-weight: 500;
}

/* Styles for textarea inside SEO block */
#seo-description-input, #seo-title-input {
    resize: vertical; /* Allow vertical resizing */
    overflow-wrap: break-word; /* Wrap long words */
    min-height: 40px; /* Sensible default height */
    line-height: 1.5;
}


.seo-input:focus {
    outline: none;
    border-bottom: 1px solid var(--primary-blue);
    color: var(--text-dark);
    background: rgba(0, 122, 255, 0.05);
}

.seo-status {
    border-bottom: none;
    padding-left: 0;
}

/* NEW: Microdata status indicator styles */
#microdata-status.present {
    color: var(--primary-green);
    font-weight: 600;
}

#microdata-status.absent {
    color: var(--primary-red);
    font-weight: 600;
}

/* === НОВЫЕ СТИЛИ ДЛЯ РЕДАКТОРА === */
.text-block-content blockquote {
    margin: 1em 0;
    padding-left: 1em;
    border-left: 2px solid var(--theme-red); /* Тоньше */
    border-radius: 2px; /* Скругление */
    font-style: italic;
    color: var(--text-secondary);
}

.text-block-content ul {
    margin: 1em 0;
    padding-left: 2em;
}

.text-block-content ul li {
    margin-bottom: 0.5em;
    padding-left: 0.5em;
}

.toolbar-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    display: block;
    margin: auto;
}
