/* ==================== */
/* Базовые стили */
/* ==================== */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
}

/* Основной контейнер приложения */
.container {
    max-width: 800px;
    margin: 20px auto;
    padding: 20px;
    background-color: #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

/* Заголовки */
h1, h2, h3, h4 {
    color: #333;
}

h1 {
    text-align: center;
}

/* ==================== */
/* Формы и элементы ввода */
/* ==================== */
form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    position: relative;
}

input[type="text"],
input[type="password"],
input[type="email"],
textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

button {
    padding: 8px;
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    width: auto;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #0056b3;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* ==================== */
/* Индикаторы загрузки и ошибки */
/* ==================== */
.loading-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 5px;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top: 4px solid #007bff;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px;
    background: #ff4444;
    color: white;
    border-radius: 5px;
    z-index: 10000;
    max-width: 300px;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.no-posts {
    text-align: center;
    padding: 20px;
    color: #666;
}

/* ==================== */
/* Стили для изображений */
/* ==================== */
.post-image {
    max-width: 100%;
    height: auto;
    display: block;
    transition: opacity 0.3s;
}

.image-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 14px;
    z-index: 10;
    display: none;
}

.swiper-slide {
    position: relative;
}

/* ==================== */
/* Блок авторизации */
/* ==================== */
#auth-forms {
    margin-bottom: 20px;
}

#auth-buttons button {
    margin-right: 10px;
    width: auto;
}

#user-info {
    margin: 10px 0;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 5px;
}

#logout-btn {
    margin-left: 10px;
    background: #ff4444;
    color: white;
    padding: 5px 10px;
    width: auto;
}

/* ==================== */
/* Посты и комментарии */
/* ==================== */
.post {
    border-bottom: 1px solid #ccc;
    padding: 10px 0;
    position: relative;
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.post-actions {
    display: flex;
    gap: 10px;
}

.post-actions button {
    background: none;
    border: none;
    font-size: 1.5em;
    padding: 5px;
    width: auto;
    color: #333;
}

.post-actions button:hover {
    color: #007bff;
    background: none;
}

.comment {
    margin-left: 20px;
    padding: 10px 0;
    border-top: 1px solid #eee;
}

.comment-form {
    margin-top: 10px;
}

.comment-form input[type="text"] {
    width: calc(100% - 22px);
}

/* ==================== */
/* Модальные окна */
/* ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 5px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.current-images {
    margin: 15px 0;
}

.image-container {
    margin-bottom: 10px;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 4px;
}

.image-container img {
    max-width: 100%;
    height: auto;
    display: block;
    margin-bottom: 5px;
}

.delete-image-btn {
    background: #ff4444;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.modal-buttons button {
    flex: 1;
}

/* ==================== */
/* Карусель Swiper */
/* ==================== */
.swiper {
    width: 100%;
    height: 400px;
    max-height: 70vh;
    margin: 20px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.swiper-slide {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
    position: relative;
}

.swiper-slide img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    border-radius: 8px;
    transition: transform 0.3s ease;
}

.swiper-slide img:hover {
    transform: scale(1.03);
}

.swiper-pagination-bullet {
    width: 12px;
    height: 12px;
    background: #fff;
    opacity: 0.6;
}

.swiper-pagination-bullet-active {
    background: #007aff;
    opacity: 1;
}

.swiper-button-next,
.swiper-button-prev {
    color: #fff;
    background: rgba(0,0,0,0.5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.swiper-button-next:hover,
.swiper-button-prev:hover {
    background: rgba(0,0,0,0.8);
}

/* ==================== */
/* Утилиты */
/* ==================== */
.hidden { 
    display: none; 
}

/* ==================== */
/* Стили пагинации */
/* ==================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    gap: 10px;
}

.pagination button {
    padding: 8px 16px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.pagination button:hover {
    background-color: #0056b3;
}

.pagination button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.pagination span {
    font-size: 16px;
    color: #333;
}

/* ==================== */
/* Адаптивность */
/* ==================== */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .swiper {
        height: 300px;
    }
    
    .swiper-button-next,
    .swiper-button-prev {
        display: none;
    }
    
    .error-message {
        max-width: 90%;
        left: 5%;
        right: 5%;
    }
}