:root {
    --primary: #2787F5;
    --primary-hover: #1b6bd1;
    --bg-body: #EDEEF0;
    --bg-card: #ffffff;
    --text-main: #000000;
    --text-muted: #818C99;
    --border: #e1e3e6;
    --btn-gray: #f5f5f5;
    --btn-gray-hover: #ebebeb;
}

body { font-family: -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif; background-color: var(--bg-body); color: var(--text-main); margin: 0; padding: 0; -webkit-font-smoothing: antialiased; }
* { box-sizing: border-box; }

/* --- ЕДИНЫЙ ХЕДЕР --- */
.main-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    background: var(--bg-card);
}
.top-partners-bar {
    background-color: #111;
    width: 100%;
    padding: 8px 0;
}
.top-partners-img {
    height: 40px;
    max-width: 100%;
    object-fit: contain;
    vertical-align: middle;
}
.header-bottom {
    background: var(--bg-card);
    padding: 0 15px;
    height: 60px;
}
.header-content { display: flex; justify-content: space-between; align-items: center; max-width: 800px; margin: 0 auto; height: 100%; }
.header-logo { height: 40px; border-radius: 50%; }
.header-title { font-size: 18px; font-weight: bold; color: var(--text-main); }

.container { max-width: 800px; margin: 0 auto; padding: 0 15px; }
.main-container { padding-top: 25px; padding-bottom: 50px; }

/* --- КНОПКИ --- */
.auth-block { display: flex; gap: 10px; align-items: center; }
button { font-family: inherit; cursor: pointer; transition: 0.2s ease; }
.nav-btn { background: none; border: none; color: var(--primary); font-size: 14px; font-weight: 500; padding: 8px 12px; border-radius: 6px; }
.nav-btn:hover { background: rgba(39, 135, 245, 0.1); }
.btn-outline { border: 1px solid var(--primary); color: var(--primary); }
.submit-btn { background: var(--primary); color: white; border: none; padding: 8px 16px; border-radius: 6px; font-weight: 500; }
.submit-btn:hover { background: var(--primary-hover); }
.submit-btn.btn-success { background: #28a745; box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3); }

/* --- ПРОЕКТ И ФИЛЬТРЫ --- */
.project-description { text-align: center; margin-bottom: 25px; padding: 20px 15px; background: var(--bg-card); border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border: 1px solid var(--border); }
.project-description h1 { font-size: 18px; color: var(--text-main); margin: 0 0 8px 0; font-weight: bold; line-height: 1.3; }
.project-description p { font-size: 14px; color: var(--text-muted); margin: 0; line-height: 1.5; }
.filter-banner { background: #fff8e1; color: #856404; padding: 10px 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #ffeeba; display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.btn-clear-filter { background: none; border: 1px solid #856404; color: #856404; padding: 4px 10px; border-radius: 4px; font-size: 12px; }

/* --- РЕДАКТОР --- */
.editor-container { background: var(--bg-card); border-radius: 12px; padding: 15px; margin-bottom: 25px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); border: 1px solid var(--border); }
.hidden { display: none !important; }
.actions-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.attach-group { display: flex; gap: 5px; }
.icon-btn { background: none; border: none; font-size: 20px; color: var(--text-muted); padding: 5px; border-radius: 50%; width: 35px; height: 35px; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.icon-btn:hover { background: var(--btn-gray); color: var(--primary); }

.emoji-picker { display: none; grid-template-columns: repeat(7, 1fr); gap: 5px; background: white; border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-top: 10px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.emoji-item { cursor: pointer; text-align: center; font-size: 20px; padding: 5px; transition: 0.1s; }
.emoji-item:hover { transform: scale(1.2); }

#previewContainer { margin-top: 15px; padding-top: 15px; border-top: 1px dashed var(--border); display: none; }
#previewContent { display: flex; flex-wrap: wrap; gap: 10px; }
.preview-item { position: relative; width: 100px; height: 100px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: #fafafa; }
.preview-media { width: 100%; height: 100%; object-fit: cover; }
.preview-video-stub, .preview-audio-stub { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 12px; text-align: center; padding: 5px; word-break: break-all; }
.btn-rm-preview { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,0.6); color: white; border: none; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center; }

/* --- ЛЕНТА ПОСТОВ --- */
.post { background: var(--bg-card); border-radius: 12px; padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); border: 1px solid var(--border); overflow: hidden;}
.post-header { display: flex; justify-content: space-between; margin-bottom: 15px; font-size: 14px; color: var(--text-muted); align-items: center; }
.school-link { color: var(--primary); font-weight: 500; cursor: pointer; }
.school-link:hover { text-decoration: underline; }
.post-content { font-size: 15px; line-height: 1.6; word-wrap: break-word; overflow-wrap: break-word; color: var(--text-main); margin-bottom: 15px; }

.post-media-grid { display: grid; gap: 10px; margin-top: 10px; border-radius: 8px; overflow: hidden; }
.grid-multi { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.post-media-item { width: 100%; height: auto; max-height: 500px; object-fit: cover; border-radius: 8px; cursor: pointer; border: 1px solid var(--border);}
.video-wrapper { position: relative; cursor: pointer; display: block; height: 100%; width: 100%; }
.video-wrapper::after { content: '▶'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 50px; height: 50px; background: rgba(0,0,0,0.5); border-radius: 50%; color: white; display: flex; align-items: center; justify-content: center; font-size: 20px; border: 2px solid white; transition: 0.2s; pointer-events: none; }
.video-wrapper:hover::after { background: rgba(39, 135, 245, 0.8); scale: 1.1; }

.post-audio-list { margin-top: 15px; display: flex; flex-direction: column; gap: 10px; }
.audio-track { background: #f0f2f5; padding: 10px 15px; border-radius: 8px; display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--border); }
.audio-name { font-size: 14px; font-weight: 500; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 8px; }
.post-audio { width: 100%; outline: none; height: 35px; }

/* --- МОДАЛКИ И ПРОЧЕЕ --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 2000; }
.modal-content { background: var(--bg-card); padding: 25px; border-radius: 12px; width: 90%; max-width: 400px; box-shadow: 0 4px 24px rgba(0,0,0,0.15); }
.modal-content h3 { margin-top: 0; margin-bottom: 20px; font-size: 18px; }
.form-input { width: 100%; padding: 10px; margin-bottom: 15px; border: 1px solid var(--border); border-radius: 6px; font-size: 15px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

.media-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 100000; display: none; align-items: center; justify-content: center; cursor: pointer; backdrop-filter: blur(5px); }
.media-modal-close { position: absolute; top: 20px; right: 30px; color: rgba(255,255,255,0.7); font-size: 35px; cursor: pointer; transition: 0.2s; }
.media-modal-content { max-width: 95vw; max-height: 95vh; display: flex; justify-content: center; align-items: center; cursor: default; }
.media-modal-content img, .media-modal-content video { max-width: 100%; max-height: 95vh; border-radius: 6px; box-shadow: 0 4px 30px rgba(0,0,0,0.8); }

.loader-overlay { position: fixed; top:0; left:0; width: 100%; height: 100%; background: rgba(255,255,255,0.8); display: none; flex-direction: column; align-items: center; justify-content: center; z-index: 3000; }
.spinner { border: 4px solid rgba(0,0,0,0.1); width: 40px; height: 40px; border-radius: 50%; border-left-color: var(--primary); animation: spin 1s linear infinite; margin-bottom: 10px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.toast { position: fixed; bottom: -50px; left: 50%; transform: translateX(-50%); background: #333; color: white; padding: 10px 20px; border-radius: 8px; opacity: 0; transition: 0.3s; z-index: 4000; font-size: 14px; }
.toast.show { bottom: 20px; opacity: 1; }

.main-footer { padding: 30px 15px; text-align: center; font-size: 13px; color: var(--text-muted); background: var(--bg-card); border-top: 1px solid var(--border); }

/* --- МОБИЛЬНАЯ АДАПТАЦИЯ (CSS Media Queries) --- */
@media (max-width: 600px) {
    /* Шапка */
    .header-bottom { padding: 0 10px; height: 50px; }
    .header-logo { height: 32px; }
    .header-title { font-size: 15px; }
    .nav-btn { padding: 6px 8px; font-size: 13px; }
    
    /* Сокращаем имя пользователя в шапке (если длинное) */
    #authBlock span { max-width: 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: middle; }

    /* Описание проекта */
    .project-description { padding: 15px 10px; margin-bottom: 15px; }
    .project-description h1 { font-size: 16px; }
    .project-description p { font-size: 13px; }

    /* Редактор */
    .editor-container { padding: 10px; }
    .icon-btn { width: 30px; height: 30px; font-size: 18px; }
    .submit-btn { padding: 6px 12px; font-size: 13px; }
    .emoji-picker { grid-template-columns: repeat(5, 1fr); }

    /* Лента постов */
    .post { padding: 15px; border-radius: 8px; }
    .post-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .post-header > div:last-child { align-self: flex-end; margin-top: -30px; } /* Кнопки удаления наверх вправо */
    .grid-multi { grid-template-columns: 1fr; } /* На телефоне фото/видео друг под другом, а не в сетке */
    .post-media-item { max-height: 300px; }
    
    /* Футер */
    .main-footer { padding: 20px 10px; font-size: 12px; }
}

/* --- ВОЗВРАЩАЕМ ФОН --- */
body {
    background-color: var(--bg-body);
    background-image: url('/assets/background.jpg'); /* Убедись, что файл так называется */
    background-size: cover;
    background-position: center top;
    background-attachment: fixed;
    background-repeat: no-repeat;
}

/* --- ВОЗВРАЩАЕМ ПОЛУПРОЗРАЧНЫЙ ФУТЕР --- */
.main-footer {
    background: rgba(255, 255, 255, 0.75) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255, 255, 255, 0.5) !important;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.05);
}

/* Для мобилок тоже немного подправим отступы футера, чтобы смотрелось легче */
@media (max-width: 600px) {
    .main-footer { padding: 25px 15px !important; }
}

/* --- УЛЬТРА-ПРОЗРАЧНЫЙ ФУТЕР (REMASTERED) --- */
.main-footer {
    background: rgba(255, 255, 255, 0.15) !important; /* Уменьшил с 0.75 до 0.15 */
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: none !important;
    color: #111; /* Текст делаем максимально контрастным */
    text-shadow: 0 1px 2px rgba(255,255,255,0.5); /* Легкое свечение под буквами для читаемости */
}

/* Убираем лишние рамки у контейнера в футере */
.main-footer .container {
    background: transparent;
}

/* --- ИДЕАЛЬНЫЙ ФУТЕР (FINAL VERSION) --- */
.main-footer {
    background: rgba(255, 255, 255, 0.45) !important; /* Баланс между 0.15 и 0.75 */
    backdrop-filter: blur(15px) saturate(150%);
    -webkit-backdrop-filter: blur(15px) saturate(150%);
    border-top: 1px solid rgba(255, 255, 255, 0.3) !important;
    padding: 30px 15px !important;
    position: relative;
    margin-top: 50px;
    margin-bottom: 0 !important; /* Убираем внешние отступы */
}

/* Убиваем ту самую «щель» внизу */
.main-footer p:last-child {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Фикс для html/body, чтобы футер не оставлял зазоров */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

/* --- ФИКС ОТСТУПОВ --- */
.container { max-width: 800px; margin: 0 auto; padding: 0 15px; }
.main-container { padding-top: 25px; padding-bottom: 50px; }
.post { margin-bottom: 20px; }

/* --- КНОПКА ОТМЕНЫ --- */
.btn-outline#cancelEditBtn {
    background-color: #f8f9fa;
    border: 1px solid #ced4da;
    color: #495057;
    transition: all 0.2s;
}
.btn-outline#cancelEditBtn:hover {
    background-color: #e2e6ea;
    border-color: #dae0e5;
    color: #212529;
}

/* --- ОБЛАГОРАЖИВАЕМ РЕДАКТОР --- */
.editor-container {
    border: 1px solid var(--border);
    border-radius: 12px;
    background-color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    overflow: hidden; /* Чтобы углы тулбара не вылезали */
}

/* Скругляем тулбар Quill и убираем дублирующуюся рамку */
.ql-toolbar.ql-snow {
    border: none !important;
    border-bottom: 1px solid var(--border) !important;
    background-color: #f8f9fa;
    border-radius: 12px 12px 0 0;
    padding: 10px 15px !important;
}

/* Настраиваем саму область ввода */
.ql-container.ql-snow {
    border: none !important;
    font-size: 15px;
    font-family: inherit;
}
.ql-editor {
    min-height: 120px;
    padding: 15px !important;
}
.ql-editor.ql-blank::before {
    color: #adb5bd; /* Более мягкий цвет плейсхолдера */
    font-style: italic;
}

/* --- СТИЛИЗАЦИЯ ИНПУТОВ И ФОРМ --- */
.form-input {
    border: 1px solid #ced4da;
    border-radius: 8px;
    padding: 12px 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: #fff;
}
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(39, 135, 245, 0.2);
}

/* --- ЖЕСТКИЙ ФИКС КНОПКИ ОТМЕНЫ --- */
button#cancelEditBtn {
    background-color: transparent !important;
    border: 1px solid #ced4da !important;
    color: #495057 !important;
    border-radius: 6px;
    padding: 8px 16px;
}
button#cancelEditBtn:hover {
    background-color: #e2e6ea !important;
    border-color: #dae0e5 !important;
    color: #212529 !important;
}

/* --- ФИКС ИКОНОК В ШАПКЕ ПОСТА (ВЫСТРАИВАЕМ В СТРОКУ) --- */
.post-header > div:last-child {
    display: flex !important;
    flex-direction: row !important;
    gap: 5px;
    align-items: center;
}

/* На всякий случай выравниваем сами иконки */
.icon-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* --- ЖЕЛЕЗОБЕТОННЫЙ ФИКС ИКОНОК ПОСТА --- */
.post-actions {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
}

/* --- ЛОКАЛЬНАЯ КНОПКА ОТМЕНЫ (БЕЗ СТОРОННИХ СЕРВИСОВ) --- */
.btn-cancel {
    background-color: #f1f3f5;
    border: 1px solid #ced4da;
    color: #495057;
    border-radius: 6px;
    padding: 8px 16px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    margin-right: 10px;
}
.btn-cancel:hover {
    background-color: #e2e6ea;
    color: #212529;
}

/* --- СТИЛИ ЗАКРЕПЛЕННОГО ПОСТА --- */
.is-pinned {
    border: 2px solid var(--primary);
    box-shadow: 0 4px 15px rgba(39, 135, 245, 0.15);
}
.pinned-badge {
    font-size: 13px;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 12px;
    display: inline-block;
    background: rgba(39, 135, 245, 0.1);
    padding: 4px 10px;
    border-radius: 6px;
}

/* --- ТЕМНЫЙ ФУТЕР (КАК НА СКРИНШОТЕ) --- */
.main-footer {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 10%, rgba(0, 0, 0, 0.6) 60%, transparent 100%) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-top: none !important;
    color: #ffffff !important;
    text-align: left !important;
    padding: 80px 15px 30px 15px !important; /* Увеличен верхний отступ для плавности градиента */
    margin-top: 50px;
    margin-bottom: 0 !important;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8); /* Легкая тень для читаемости */
}
.main-footer .container {
    max-width: 800px;
    margin: 0 auto;
}
.main-footer p {
    color: #ffffff !important;
}
.footer-title { font-weight: bold; font-size: 15px; margin-bottom: 15px !important; }
.footer-subtitle { font-weight: bold; font-size: 14px; margin-bottom: 8px !important; }
.footer-authors p { font-size: 13px; line-height: 1.6; margin: 0 0 4px 0 !important; color: #f0f0f0 !important; }
.footer-support { font-size: 13px; margin-top: 15px !important; margin-bottom: 10px !important; color: #e0e0e0 !important; }
.footer-copy { font-size: 13px; color: #999 !important; margin: 0 !important; }

/* Фикс для мобильных */
@media (max-width: 600px) {
    .main-footer { padding: 60px 15px 20px 15px !important; }
}

/* --- СМЕЩАЕМ ФУТЕР К ЛЕВОМУ КРАЮ ЭКРАНА --- */
.main-footer .container {
    max-width: 100% !important;
    margin-left: 0 !important;
    padding-left: 20px !important; /* Небольшой отступ, чтобы не прилипало вплотную к рамке */
    padding-right: 20px !important;
}

/* --- КОРРЕКТИРОВКА ШРИФТОВ ФУТЕРА --- */
.footer-support {
    font-weight: bold !important;
}
.footer-copy {
    color: #666666 !important; /* Уводим в более темный серый */
}

/* --- СКРЫТИЕ ДЛИННЫХ ТЕКСТОВ --- */
.post-text-wrapper {
    position: relative;
    max-height: 250px; /* Порог высоты текста */
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.post-text-wrapper.expanded {
    max-height: none !important;
}
.read-more-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: linear-gradient(to bottom, transparent, var(--bg-card));
    pointer-events: none;
}
.post-text-wrapper.expanded .read-more-overlay {
    display: none;
}
.read-more-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 500;
    padding: 5px 0;
    margin-top: 5px;
    margin-bottom: 15px;
    cursor: pointer;
    display: none; /* Скрыта по умолчанию */
    font-size: 14px;
}
.read-more-btn:hover {
    text-decoration: underline;
}

/* --- ЖЕСТКАЯ МОБИЛЬНАЯ АДАПТАЦИЯ (ФИКС НАЛОЖЕНИЙ) --- */
@media (max-width: 600px) {
    /* 1. Перестраиваем шапку сайта в колонку */
    .header-bottom { height: auto !important; padding: 12px 15px !important; }
    .header-content { flex-direction: column !important; gap: 10px !important; align-items: flex-start !important; }
    
    /* 2. Блок авторизации: кнопки могут переноситься, длинное имя обрезается троеточием */
    #authBlock { width: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start !important; gap: 8px; }
    #authBlock span { max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; }
    .nav-btn { font-size: 13px !important; padding: 6px 10px !important; margin: 0 !important; }

    /* 3. Шапка поста: разносим текст и кнопки действий на разные уровни */
    .post-header { flex-direction: column !important; align-items: flex-start !important; gap: 10px !important; }
    
    /* Текст с названием заведения и датой теперь может занимать несколько строк */
    .post-header > div:first-child { width: 100%; display: flex; flex-wrap: wrap; line-height: 1.5; align-items: center; }
    
    /* Кнопки (📍, ✏️, 💾, 🗑️) прижимаем к правому краю под текстом */
    .post-actions { width: 100%; justify-content: flex-end !important; margin-top: 5px !important; }
}
