/**
 * Базовые стили для всех страниц
 * Вынесено из base.html для оптимизации
 */

/* Стили для подсветки комментариев в уведомлениях */
.comment-highlight {
    background-color: #fff3cd !important;
    border: 2px solid #ffc107 !important;
    border-radius: 8px;
    padding: 12px !important;
    animation: commentHighlight 0.5s ease-in-out;
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
    transition: all 0.3s ease;
}

@keyframes commentHighlight {
    0% {
        background-color: transparent;
        transform: scale(1);
    }
    50% {
        background-color: #fff3cd;
        transform: scale(1.02);
    }
    100% {
        background-color: #fff3cd;
        transform: scale(1);
    }
}

/* Стили для кликабельных ссылок в уведомлениях */
.notification-link {
    color: #007bff;
    text-decoration: none;
    transition: color 0.2s ease;
}

.notification-link:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* Стили для contenteditable div в форме описания поста */
#post-text-editable {
    background-color: #fff;
    color: #212529;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
}

#post-text-editable:focus {
    color: #212529;
    background-color: #fff;
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

#post-text-editable.placeholder {
    color: #6c757d;
}

#post-text-editable.placeholder:focus {
    color: #212529;
}

/* Стили для упоминаний и хештегов в contenteditable */
#post-text-editable .mention-link {
    color: #4B52FF;
    text-decoration: none;
    font-weight: 500;
    pointer-events: none; /* Отключаем клики в поле ввода */
}

#post-text-editable .hashtag-link {
    color: #FF4D7D;
    text-decoration: none;
    font-weight: 500;
    pointer-events: none; /* Отключаем клики в поле ввода */
}

/* Убираем стандартные стили ссылок в contenteditable */
#post-text-editable a {
    color: inherit;
    text-decoration: none;
    cursor: text;
}

#post-text-editable a.mention-link {
    color: #4B52FF;
}

#post-text-editable a.hashtag-link {
    color: #FF4D7D;
}

/* Поле редактирования описания поста в модалке — те же стили, что и при создании */
#edit-post-description-editable.placeholder {
    color: #6c757d;
}

#edit-post-description-editable.placeholder:focus {
    color: #212529;
}

#edit-post-description-editable .mention-link {
    color: #4B52FF;
    text-decoration: none;
    font-weight: 500;
    pointer-events: none;
}

#edit-post-description-editable .hashtag-link {
    color: #FF4D7D;
    text-decoration: none;
    font-weight: 500;
    pointer-events: none;
}

#edit-post-description-editable a {
    color: inherit;
    text-decoration: none;
    cursor: text;
}

#edit-post-description-editable a.mention-link {
    color: #4B52FF;
}

#edit-post-description-editable a.hashtag-link {
    color: #FF4D7D;
}

* {
    font-family: 'Montserrat', sans-serif;
}

body {
    background: linear-gradient(135deg, #4fc3f7 0%, #7b68ee 25%, #c77dff 50%, #ff6b9d 75%, #ff8a80 100%);
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
    font-family: 'Montserrat', sans-serif;
    padding-bottom: 100px; /* Отступ снизу для навигации */
    /* Оптимизация для мобильных */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Предотвращение горизонтальной прокрутки */
    overflow-x: hidden;
    /* Оптимизация touch-событий (но не для input[type="file"]) */
    touch-action: manipulation;
}

/* Исключаем input[type="file"] из touch-action: manipulation для корректной работы на мобильных */
input[type="file"] {
    touch-action: auto !important;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

.main-wrapper {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 auto;
    min-height: calc(100vh - 40px);
}

/* Страницы входа и регистрации: лого + форма гармонично по центру */
.main-wrapper:has(.site-title) {
    min-height: 100vh;
    justify-content: center;
}
.main-wrapper:has(.site-title) .auth-container {
    min-height: auto;
    margin-bottom: 2rem;
    max-width: 450px;
    margin-left: auto;
    margin-right: auto;
}
/* Лого той же ширины, что и форма; высота пропорционально */
.main-wrapper:has(.site-title) .site-title {
    width: 100%;
    max-width: 450px;
}
.main-wrapper:has(.site-title) .site-logo {
    width: 100%;
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

/* Медиа-запросы для адаптивности */
@media (max-width: 480px) {
    body {
        padding: 10px;
        padding-bottom: 90px;
    }
    
    .main-wrapper {
        min-height: calc(100vh - 20px);
    }
    
    /* Лого нижним краем упирается в белую форму (вход/регистрация) */
    .site-title {
        margin-bottom: 0;
    }
    
    .site-logo {
        max-width: 150px;
    }
    
    /* На входе/регистрации лого той же ширины, что и форма, и на мобильных */
    .main-wrapper:has(.site-title) .site-logo {
        width: 100%;
        max-width: 100%;
    }
    
    .auth-container {
        padding: 1rem;
        border-radius: 10px;
        margin-bottom: 90px;
    }
    
    .auth-header {
        margin-bottom: 1.5rem;
    }
    
    .auth-header h2 {
        font-size: 1.5rem;
    }
    
    .alert-container {
        max-width: 100%;
    }
}

@media (min-width: 481px) and (max-width: 767px) {
    body {
        padding: 15px;
    }
    
    .site-logo {
        max-width: 180px;
    }
    
    .main-wrapper:has(.site-title) .site-logo {
        width: 100%;
        max-width: 100%;
    }
    
    .auth-container {
        padding: 1.5rem;
    }
}

@media (min-width: 768px) {
    .main-wrapper {
        max-width: 70%;
    }
}

@media (min-width: 1024px) {
    .main-wrapper {
        max-width: 60%;
    }
}

@media (min-width: 1440px) {
    .main-wrapper {
        max-width: 50%;
    }
}

/* Лого на страницах входа/регистрации — нижним краем упирается в белую форму */
.site-title {
    margin-bottom: 0;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.site-logo {
    max-width: 200px;
    height: auto;
    filter: drop-shadow(0 2px 10px rgba(0,0,0,0.2));
}

/* Показываем логотип сверху на всех устройствах */
.site-title {
    display: flex;
}

.auth-container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 2rem;
    width: 100%;
    min-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    margin-bottom: 100px;
}

/* Убираем padding когда внутри есть .card, чтобы контент занимал всю ширину */
.auth-container:has(.card) {
    padding: 0;
}

/* Для старых браузеров, которые не поддерживают :has() */
.auth-container .card {
    border-radius: 15px;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h2 {
    color: #5B61FF;
    font-weight: 600;
}

.btn-primary {
    background: #5B61FF;
    border: none;
    padding: 0.75rem;
    font-weight: 500;
    color: white;
}

.btn-primary:hover {
    background: #4B52FF;
    color: white;
}

.btn-primary:focus,
.btn-primary:active {
    background: #3F45E6;
    color: white;
    box-shadow: 0 0 0 0.2rem rgba(91, 97, 255, 0.30);
}

.form-control:focus {
    border-color: #5B61FF;
    box-shadow: 0 0 0 0.2rem rgba(91, 97, 255, 0.30);
}

/* Оптимизация форм для мобильных */
@media (max-width: 768px) {
    .form-control,
    .form-select {
        font-size: 16px; /* Предотвращает зум на iOS */
        padding: 0.75rem;
    }
    
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 16px;
        min-height: 44px; /* Минимальный размер для touch */
    }
    
    /* Улучшаем читаемость на маленьких экранах */
    .alert {
        font-size: 14px;
        padding: 0.75rem 1rem;
    }
}

.alert-container {
    width: 100%;
    max-width: 450px;
    margin-bottom: 1rem;
}

