/* === БАЗОВЫЕ СТИЛИ ДЛЯ МОБИЛЬНЫХ (Mobile-First Approach) === */

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
}

/* === ПРОФИЛЬ - МОБИЛЬНАЯ ВЕРСИЯ === */

.profile-header {
  position: relative;
  width: 100%;
  margin-bottom: 0;
  /* На мобильных все компактнее */
}

.profile-banner {
  position: relative;
  width: 100%;
  height: 140px; /* Сокращено с 250px */
  background-image: url('../img/collage.svg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 1;
}

.profile-header-content {
  position: relative;
  width: 100%;
  padding: 12px 12px 0 12px; /* Компактные отступы */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  z-index: 2;
  margin: 0;
  max-width: none;
}

.profile-avatar-large {
  width: 100px; /* Меньше с 200px */
  height: 100px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 3px solid #f0f0f0;
  flex-shrink: 0;
  margin: -50px 0 0 0; /* Переместили выше баннера */
  position: relative;
  z-index: 3;
}

.profile-main-info {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  color: white;
  width: 100%;
  margin-top: 8px;
  gap: 4px;
}

.profile-username {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px; /* Как в X, не 24px */
  font-weight: 700;
  color: white;
  margin: 0;
  line-height: 1.2;
  word-break: break-word;
}

.profile-level-info {
  margin: 0;
}

.profile-level-text {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px; /* Как в X, компактно */
  font-weight: 400;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.2;
}

/* === ПОЛОСКА МОРАЛИ - ОПТИМИЗИРОВАНА === */

.morale-bar-container {
  width: 100%;
  height: 20px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  margin: 8px 0 0 0;
  flex-shrink: 0;
}

.morale-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, rgba(127, 100, 140, 1) 0%, rgba(83, 8, 158, 1) 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
}

.morale-bar-text {
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
}

/* === БЛОК ПОСТА - МОБИЛЬНЫЙ === */

.post-composer {
  width: 100%;
  margin: 0;
  background-color: transparent;
  border-top: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
  padding: 12px; /* Сокращено с 20px */
  box-sizing: border-box;
  position: relative;
  min-width: auto;
  max-width: none;
}

.post-header {
  display: flex;
  align-items: flex-start;
  gap: 8px; /* Сокращено */
  margin-bottom: 8px;
}

.post-avatar {
  width: 48px; /* Меньше с 64px */
  height: 48px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.post-user-info {
  display: flex;
  align-items: baseline;
  gap: 6px; /* Сокращено */
  flex: 1;
  min-width: 0;
}

.post-username {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px; /* Как в X */
  font-weight: 700;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.post-user-details {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 12px; /* Как в X */
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === ТЕКСТОВАЯ ОБЛАСТЬ === */

.post-text-area {
  width: 100%;
  min-height: 50px;
  border: none;
  outline: none;
  resize: none;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px; /* Оптимально для мобильных */
  font-weight: 400;
  line-height: 1.4;
  color: white;
  background: transparent;
  padding: 0;
  margin: 8px 0 0 0;
  overflow-y: auto;
  word-wrap: break-word;
  box-sizing: border-box;
  transition: height 0.1s ease;
}

.post-text-area::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

/* === ФУТЕР ПОСТА - ОПТИМИЗИРОВАН === */

.post-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 0;
  height: auto;
  position: relative;
}

.post-char-counter {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 11px; /* Компактнее */
  color: #999;
  order: 1;
}

.post-char-counter.warning {
  color: #ff9800;
}

.post-char-counter.danger {
  color: #f44336;
}

/* === КНОПКА ПОДЕЛИТЬСЯ === */

.post-share-btn {
  background: #2C2C2C;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 16px; /* Как в X - круглая кнопка */
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px; /* Компактнее */
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s ease;
  order: 2;
  margin-left: auto;
  position: static;
  right: auto;
  bottom: auto;
}

.post-share-btn:hover:not(:disabled) {
  background: #363636;
}

.post-share-btn:disabled {
  background: #555;
  cursor: not-allowed;
  opacity: 0.5;
}

/* === КНОПКИ МОДЕРАЦИИ === */

/* Стили для кнопок модерации */
.icon-button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.icon-button img {
    filter: brightness(0) invert(1); /* Делает иконки белыми */
    transition: all 0.3s ease;
}

/* Специфичные цвета для разных кнопок */
.approve-btn:hover {
    background: rgba(39, 174, 96, 0.3);
    border-color: rgba(39, 174, 96, 0.5);
}

.approve-btn:hover img {
    filter: brightness(0) invert(1) drop-shadow(0 0 4px rgba(39, 174, 96, 0.8));
}

.edit-btn:hover {
    background: rgba(52, 152, 219, 0.3);
    border-color: rgba(52, 152, 219, 0.5);
}

.edit-btn:hover img {
    filter: brightness(0) invert(1) drop-shadow(0 0 4px rgba(52, 152, 219, 0.8));
}

.reject-btn:hover {
    background: rgba(231, 76, 60, 0.3);
    border-color: rgba(231, 76, 60, 0.5);
}

.reject-btn:hover img {
    filter: brightness(0) invert(1) drop-shadow(0 0 4px rgba(231, 76, 60, 0.8));
}

/* Стили для popup редактирования */
.edit-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.edit-popup-overlay {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.edit-popup-content {
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.edit-popup-content h3 {
    color: #fff;
    margin-bottom: 20px;
    font-size: 24px;
}

.edit-textarea {
    width: 100%;
    min-height: 150px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #fff;
    padding: 12px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 10px;
}

.edit-textarea:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
}

.edit-char-counter {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 20px;
    text-align: right;
}

.edit-char-counter.warning {
    color: #f39c12;
}

.edit-char-counter.danger {
    color: #e74c3c;
}

.edit-popup-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.edit-approve-btn,
.edit-cancel-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.edit-approve-btn {
    background: #27ae60;
    color: white;
}

.edit-approve-btn:hover {
    background: #229954;
    transform: translateY(-2px);
}

.edit-approve-btn:disabled {
    background: rgba(39, 174, 96, 0.3);
    cursor: not-allowed;
    transform: none;
}

.edit-cancel-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.edit-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .icon-button {
        padding: 6px;
    }
    
    .icon-button img {
        width: 20px;
        height: 20px;
    }
    
    .edit-popup-content {
        padding: 20px;
    }
    
    .edit-popup-content h3 {
        font-size: 20px;
    }
}

/* Конец кнопок модерации */

@media (max-width: 768px) {
  
  .profile-header {
    position: relative;
    width: 100%;
    margin-bottom: 0;
  }
  
  .profile-banner {
    position: relative;
    width: 100%;
    height: 140px;
    background-image: url('../img/collage.svg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1;
  }
  
  /* === КОНТЕЙНЕР - ВСЕ ПО ЦЕНТРУ === */
  .profile-header-content {
    position: relative;
    width: 100%;
    padding: 12px 12px 0 12px;
    display: flex;
    flex-direction: column;
    align-items: center;        /* ← АВАТАРКА ПО ЦЕНТРУ */
    justify-content: flex-start;
    z-index: 2;
    margin: 0;
    max-width: none;
    text-align: center;
  }
  
  /* === АВАТАРКА ПО ЦЕНТРУ === */
  .profile-avatar-large {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    border: 3px solid #f0f0f0;
    flex-shrink: 0;
    margin: -50px 0 0 0;
    position: relative;
    z-index: 3;
  }
  
  /* === ИНФОРМАЦИЯ ПРОФИЛЯ === */
  .profile-main-info {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    color: white;
    width: 100%;
    margin-top: 8px;
    gap: 0;
    align-items: center;
    text-align: center;
  }
  
  .profile-username {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: white;
    margin: 0;
    line-height: 1.2;
    word-break: break-word;
  }
  
  /* === ДОПОЛНИТЕЛЬНАЯ ИНФОРМАЦИЯ - ВЫСОТОЙ С АВАТАРКУ === */
  .profile-level-info {
    margin: 0;
    height: 100px;  /* ← РАВНА ВЫСОТЕ АВАТАРКИ */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
    width: 100%;
  }
  
  .profile-level-text {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.2;
    margin: 0;
  }
  
  /* === ПОЛОСКА МОРАЛИ - ЦЕНТРИРОВАНА И 2x АВАТАРКИ === */
  .morale-bar-container {
    width: 200px;  /* ← 2 × 100px (ширина аватарки) */
    height: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    margin: -64px auto 8px auto;  /* ← ЦЕНТР + 8px ОТСТУП СНИЗУ */
    flex-shrink: 0;
  }
  
  .morale-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, rgba(127, 100, 140, 1) 0%, rgba(83, 8, 158, 1) 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
  }
  
  .morale-bar-text {
    color: #fff;
    font-weight: 700;
    font-size: 11px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    white-space: nowrap;
  }
}

@media (min-width: 1024px) {
  .profile-avatar-large {
    width: 160px;
    height: 160px;
    margin: -80px 0 0 30px;
  }

  .profile-username {
    font-size: 24px;
  }

  .profile-level-text {
    font-size: 16px;
  }

  .post-username {
    font-size: 16px;
  }

  .post-user-details {
    font-size: 14px;
  }
}

/* === УТИЛИТЫ === */

.morale-bar-container {
  display: block !important;
}

.post-footer > * {
  flex-shrink: 0;
}

/* Убедимся что кнопки не обрезаются */
.icon-button {
  min-width: 32px;
  min-height: 32px;
}

/* Гибкий контейнер постов */
#postsContainer,
#pendingPostsContainer,
#myPostsList,
#my-posts {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 0;
}

/* === POPUP РЕДАКТИРОВАНИЯ === */

.edit-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
}

.edit-popup-overlay {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.edit-popup-content {
  background: #2C2C2C;
  color: white;
  padding: 16px;
  border-radius: 8px;
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

.edit-popup-content h3 {
  margin: 0 0 12px 0;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  font-weight: 600;
}

.edit-textarea {
  width: 100%;
  min-height: 150px;
  background: #3C3C3C;
  color: white;
  border: 1px solid #555;
  border-radius: 6px;
  padding: 10px;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  resize: vertical;
  box-sizing: border-box;
}

.edit-textarea:focus {
  outline: none;
  border-color: #667eea;
}

.edit-popup-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

.edit-approve-btn,
.edit-cancel-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.edit-approve-btn {
  background: #27ae60;
  color: white;
}

.edit-approve-btn:hover:not(:disabled) {
  background: #229954;
}

.edit-approve-btn:disabled {
  background: #555;
  cursor: not-allowed;
}

.edit-cancel-btn {
  background: #555;
  color: white;
}

.edit-cancel-btn:hover {
  background: #666;
}

/* === ССЫЛКИ В ПОСТАХ === */

.post-username-link,
.post-class-link {
  text-decoration: none;
  transition: color 0.2s ease;
}

.post-username-link {
  font-size: 14px;
  font-weight: 700;
  color: white;
}

.post-username-link:hover {
  color: #cfcfcf;
}

.post-class-link {
  font-size: 12px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.8);
}

.post-class-link:hover {
  color: #dcdcdc;
}

/* === ОЧЕНЬ МАЛЕНЬКИЕ ЭКРАНЫ (320px - 430px) === */

@media (max-width: 430px) {
  
  .profile-header-content {
    padding: 8px 8px 0 8px;
  }
  
  .profile-avatar-large {
    width: 80px;   /* ← МЕНЬШИЙ РАЗМЕР */
    height: 80px;
    margin: -40px 0 0 0;
    border-width: 2px;
  }
  
  .profile-main-info {
    margin-top: 4px;
    gap: 0;
  }
  
  .profile-username {
    font-size: 15px;
    line-height: 1.1;
  }
  
  .profile-level-info {
    height: 80px;  /* ← РАВНА ВЫСОТЕ АВАТАРКИ (80px) */
    gap: 2px;
  }
  
  .profile-level-text {
    font-size: 12px;
  }
  
  .morale-bar-container {
    width: 160px;  /* ← 2 × 80px (ширина аватарки) */
    height: 18px;
    margin: -48px auto 8px auto;  /* ← ЦЕНТР + 8px ОТСТУП СНИЗУ */
    border-radius: 3px;
  }
  
  .morale-bar-text {
    font-size: 10px;
  }
}

/* === Посты занимают всю ширину до 1200px, а потом центрируются === */

#postsContainer,
#pendingPostsContainer,
#myPostsList,
#approvedPostsContainer,
#my-posts {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto; /* центрирование */
    padding: 0;
    box-sizing: border-box;
}

/* На маленьких экранах посты растягиваются на всю ширину */
@media (max-width: 1200px) {
    #postsContainer,
    #pendingPostsContainer,
    #myPostsList,
    #approvedPostsContainer,
    #my-posts {
        width: 100vw;
        max-width: 100vw;
        margin-left: calc(-50vw + 50%);
    }
}

/* Сами посты внутри */
#postsContainer .post-composer,
#pendingPostsContainer .post-composer,
#myPostsList .post-composer,
#approvedPostsContainer,
#my-posts .post-composer {
    width: 100%;
    max-width: none;
    margin: 0;
    border-left: none;
    border-right: none;
    border-radius: 0;
}

@media (max-width: 768px) {
    header .logo img {
        height: 45px; /* Увеличил для мобильных */
    }
    
    .css-text-mask .logo-large {
        width: 90vw;
    }
}

@media (max-width: 480px) {
    header .logo img {
        height: 45px; /* Увеличил для маленьких экранов */
    }
}
