body { font-family: Arial, sans-serif; margin:0; padding:0; }

/* Стили для header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
  min-height: 60px; /* Фиксированная высота */
}

.header-left {
  display: flex;
  align-items: center;
  gap: 15px;
  flex: 1; /* Занимает доступное пространство */
  min-width: 0; /* Позволяет тексту обрезаться при нехватке места */
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0; /* Не сжимается */
}

.header-logo {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.2);
  padding: 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  cursor: pointer;
  flex-shrink: 0; /* Не сжимается */
}

.header-logo:hover {
  transform: scale(1.1) rotate(5deg);
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

h1 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 600;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  background: linear-gradient(45deg, #fff, #f8f9fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap; /* Не переносится на новую строку */
  overflow: hidden; /* Обрезается если не помещается */
  text-overflow: ellipsis; /* Добавляет ... если текст не помещается */
}

#loginBtn {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: white;
  padding: 10px 25px;
  border-radius: 25px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  white-space: nowrap; /* Текст не переносится */
  min-width: 100px; /* Минимальная ширина кнопки */
  text-align: center;
  flex-shrink: 0; /* Не сжимается */
}

#loginBtn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

#addPostBtn {
  /* Стиль для кнопки "Добавить пост" */
  background: rgba(46, 204, 113, 0.8);
  border: 2px solid rgba(46, 204, 113, 0.5);
  min-width: 140px; /* Ширина под более длинный текст */
}

#addPostBtn:hover {
  background: rgba(46, 204, 113, 0.9);
  border-color: #2ecc71;
}

/* Кнопка выхода */
#logoutBtn {
  background: rgba(231, 76, 60, 0.8);
  border: 2px solid rgba(231, 76, 60, 0.5);
  color: white;
  padding: 10px 25px;
  border-radius: 25px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  white-space: nowrap;
  min-width: 100px;
  text-align: center;
  flex-shrink: 0;
  border: none;
}

#logoutBtn:hover {
  background: rgba(231, 76, 60, 0.9);
  border-color: #e74c3c;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

main { padding:10px; }
.post { border:1px solid #ccc; margin-bottom:10px; padding:15px; max-width:800px; border-radius:8px; background:#fff; box-shadow:0 2px 5px rgba(0,0,0,0.1); }
.post h3 { margin-top:0; border-bottom:1px solid #eee; padding-bottom:8px; }
.post h3 small { color:#777; font-size:0.9em; margin-left:10px; }
.post p { margin:10px 0; line-height:1.5; }
img { max-width:100%; cursor:pointer; border-radius:5px; margin-top:10px; }
footer { text-align:center; margin:20px 0; font-size:12px; color:#555; padding:20px; }

/* Модальное окно */
.modal { 
  display:none; 
  position:fixed; 
  top:0; 
  left:0; 
  width:100%; 
  height:100%; 
  background:rgba(0,0,0,0.5); 
  z-index:1000;
  justify-content: center;
  align-items: center;
}
.modal-content { 
  background:#fff; 
  padding:25px; 
  width:350px; 
  border-radius:10px; 
  box-shadow:0 5px 20px rgba(0,0,0,0.2);
}
.modal-content h3 { margin-top:0; color:#333; text-align:center; margin-bottom:20px; }
.modal-content input { 
  width:100%; 
  padding:12px; 
  margin-bottom:15px; 
  border:1px solid #ddd; 
  border-radius:5px; 
  box-sizing:border-box; 
  font-size:16px;
}
.modal-content input:focus { 
  outline:none; 
  border-color:#007bff; 
  box-shadow:0 0 0 2px rgba(0,123,255,0.2);
}

/* Блок загрузки поста (выровнен по центру) */
#uploadSection { 
  margin:30px auto; 
  max-width:500px;
  display: none; /* По умолчанию скрыт */
}

.upload-block {
    padding: 25px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.upload-block h2 {
    margin-top: 0;
    color: #333;
    text-align: center;
    font-size: 1.5em;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.upload-block label {
    font-weight: 600;
    color: #444;
    margin-bottom: -10px;
}

.upload-block input[type="text"],
.upload-block textarea,
.upload-block input[type="date"],
.upload-block input[type="file"] {
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    width: 100%;
    box-sizing: border-box;
    font-size: 16px;
    transition: border-color 0.3s;
}

.upload-block input[type="text"]:focus,
.upload-block textarea:focus,
.upload-block input[type="date"]:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.2);
}

.upload-block textarea {
    min-height: 120px;
    resize: vertical;
    font-family: Arial, sans-serif;
}

.upload-block input[type="file"] {
    padding: 8px;
    background: #f8f8f8;
}

.upload-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.upload-buttons button {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

#uploadBtn {
    background: #007bff;
    color: #fff;
}

#uploadBtn:hover {
    background: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,123,255,0.3);
}

.btn-secondary {
    background: #6c757d;
    color: #fff;
}

.btn-secondary:hover {
    background: #545b62;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(108,117,125,0.3);
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.modal-buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
}

.modal-buttons #loginSubmit {
    background: #28a745;
    color: white;
    font-weight: 600;
}

.modal-buttons #loginSubmit:hover {
    background: #218838;
    transform: translateY(-2px);
}

/* Центрирование ленты */
#postsContainer {
  max-width: 700px;
  margin: 20px auto;
}

/*------*/
/* Стили для поиска и тегов */
.search-container {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-right: 15px;
}

#searchInput {
  padding: 10px 15px;
  border-radius: 25px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 14px;
  min-width: 200px;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

#searchInput::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

#searchInput:focus {
  outline: none;
  border-color: white;
  background: rgba(255, 255, 255, 0.2);
  min-width: 250px;
}

#searchBtn {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: white;
  padding: 10px 20px;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
}

#searchBtn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: white;
  transform: translateY(-2px);
}

#clearSearch {
  background: rgba(231, 76, 60, 0.8);
  border: 2px solid rgba(231, 76, 60, 0.5);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

#clearSearch:hover {
  background: rgba(231, 76, 60, 0.9);
  border-color: #e74c3c;
  transform: rotate(90deg);
}

/* Контейнер для тегов */
.tags-container {
  background: rgba(255, 255, 255, 0.95);
  padding: 15px 20px;
  margin: 0 20px 20px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-left: 4px solid #667eea;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* Стили тегов в поиске и в постах */
.tag {
  display: inline-block;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  margin: 2px;
  user-select: none;
}

.tag:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

.tag.active {
  background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
  box-shadow: 0 4px 8px rgba(46, 204, 113, 0.4);
}

.post-tags {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* Подсветка найденного текста */
.highlight {
  background-color: #ffeaa7;
  padding: 0 2px;
  border-radius: 3px;
  font-weight: bold;
}

/* Стили для поста с тегами */
.post .post-tags {
  margin: 10px 0;
}

/* Адаптивность для поиска */
@media (max-width: 768px) {
  .search-container {
    margin-right: 10px;
  }
  
  #searchInput {
    min-width: 150px;
    padding: 8px 12px;
    font-size: 13px;
  }
  
  #searchInput:focus {
    min-width: 180px;
  }
  
  #searchBtn, #clearSearch {
    padding: 8px 15px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .header-right {
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
  }
  
  .search-container {
    margin-right: 0;
    width: 100%;
    justify-content: flex-end;
  }
  
  #searchInput {
    min-width: 120px;
    flex-grow: 1;
    max-width: 200px;
  }
}
/*------*/

/* Пост */
.post {
  border: 1px solid #ddd;
  padding: 15px;
  margin-bottom: 20px;
  border-radius: 8px;
  background: #fff;
}

/* Кнопки в постах */
.post button {
    padding: 8px 15px;
    margin: 5px 5px 0 0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.post button:nth-child(4) {
    background: #ffc107;
    color: #333;
}

.post button:nth-child(4):hover {
    background: #e0a800;
}

.post button:nth-child(5) {
    background: #dc3545;
    color: white;
}

.post button:nth-child(5):hover {
    background: #c82333;
}

/* Центрируем пагинацию */
#pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin: 30px auto;
  max-width: 700px;
}

#pagination button {
    padding: 10px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

#pagination button:hover {
    background: #0056b3;
}

#pagination button:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

#pageNum {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    min-width: 30px;
    text-align: center;
}

/* Верхняя панель */
#top-bar {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px;
}

/* Добавим кнопку для показа формы добавления поста */
#addPostBtn {
    background: #28a745;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    margin: 10px auto;
    display: block;
    transition: all 0.3s;
}

#addPostBtn:hover {
    background: #218838;
    transform: translateY(-2px);
}

.post-actions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.post-actions button {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.post-actions button:first-child {
    background: #ffc107;
    color: #333;
}

.post-actions button:first-child:hover {
    background: #e0a800;
}

.post-actions button:last-child {
    background: #dc3545;
    color: white;
}

.post-actions button:last-child:hover {
    background: #c82333;
}

.drop-zone {
  border: 2px dashed #aaa;
  border-radius: 10px;
  padding: 30px;
  text-align: center;
  margin-bottom: 10px;
  cursor: pointer;
  transition: 0.2s;
}

.drop-zone.dragover {
  border-color: #007bff;
  background: #eef5ff;
}

/* Стили для панели форматирования */
.formatting-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.format-btn {
    padding: 8px 12px;
    border: 1px solid #ccc;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    min-width: 40px;
    transition: all 0.2s;
}

.format-btn:hover {
    background: #e0e0e0;
    transform: translateY(-1px);
}

.format-btn:active {
    transform: translateY(0);
}

.format-btn b, .format-btn i, .format-btn u {
    font-weight: bold;
}

/* Стили для текста постов */
.post-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.6;
    margin: 15px 0;
    font-family: inherit;
}

/* Подсветка кода */
.post-text code {
    background: #f1f1f1;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.post-text pre {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 10px 0;
}

/* Цитаты */
.post-text blockquote {
    border-left: 4px solid #3498db;
    margin: 10px 0;
    padding-left: 15px;
    color: #555;
    font-style: italic;
}

/* Списки */
.post-text ul, .post-text ol {
    padding-left: 25px;
    margin: 10px 0;
}

.post-text li {
    margin: 5px 0;
}

/* Заголовки в тексте */
.post-text h4, .post-text h5, .post-text h6 {
    margin: 15px 0 10px 0;
    color: #2c3e50;
}

/* Ссылки */
.post-text a {
    color: #2980b9;
    text-decoration: none;
}

.post-text a:hover {
    text-decoration: underline;
}