/* ========================================
   CHAT COMPONENT
   Universal chat styles for all pages
   ======================================== */

/* Container */
#comments-container {
  max-width: 100%;
  margin: 0;
  padding: 16px;
  font-family: inherit;
}

#comments-container h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 16px 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border-light, #333);
  display: flex;
  align-items: center;
  gap: 8px;
}

#comments-container h2::before {
  content: '\f075';
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  font-size: 16px;
  color: var(--color-primary, #f5a623);
}

/* ========================================
   COMMENT FORM
   ======================================== */

#comment-form {
  margin-bottom: 24px;
  background-color: var(--color-bg-card, #252525);
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid var(--color-border-light, #333);
}

#message-input {
  width: 100%;
  min-height: 80px;
  padding: 12px 14px;
  border: 1px solid var(--color-border-medium, #444);
  border-radius: var(--radius-md);
  background-color: var(--color-bg-element, #1a1a1a);
  color: var(--color-text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

#message-input:focus {
  outline: none;
  border-color: var(--color-primary, #f5a623);
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.15);
}

#message-input::placeholder {
  color: var(--color-text-muted, #666);
}

.comment-buttons {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.comment-buttons button,
#post-comment {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-primary, #f5a623);
  color: #000;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.comment-buttons button:hover,
#post-comment:hover {
  background: var(--color-primary-hover, #e6991a);
  transform: translateY(-1px);
}

.comment-buttons button:active,
#post-comment:active {
  transform: translateY(0);
}

/* ========================================
   MESSAGES CONTAINER
   ======================================== */

#messages {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Empty state */
#messages:empty::after {
  content: 'Пока нет комментариев. Будьте первым!';
  display: block;
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted, #666);
  font-size: 14px;
}

/* ========================================
   SINGLE COMMENT/MESSAGE
   ======================================== */

.comment {
  padding: 16px;
  margin: 0;
  background-color: var(--color-bg-card, #252525);
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--color-border-light, #2a2a2a);
  transition: background-color 0.2s;
}

.comment:first-child {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.comment:last-child {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  border-bottom: none;
}

.comment:only-child {
  border-radius: var(--radius-lg);
}

.comment:hover {
  background-color: var(--color-bg-hover, #2d2d2d);
}

/* Reply styling */
.comment.reply {
  margin-left: 0;
  padding-left: 32px;
  background-color: var(--color-bg-tertiary, #1f1f1f);
  border-left: 3px solid var(--color-primary, #f5a623);
  position: relative;
}

.comment.reply::before {
  content: '';
  position: absolute;
  left: 16px;
  top: 24px;
  width: 8px;
  height: 8px;
  border-left: 2px solid var(--color-border-medium, #444);
  border-bottom: 2px solid var(--color-border-medium, #444);
  border-radius: 0 0 0 4px;
}

/* ========================================
   COMMENT HEADER
   ======================================== */

.comment-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.user-avatar {
  flex-shrink: 0;
}

.user-avatar .avatar-image {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background-color: var(--color-bg-element, #1a1a1a);
  border: 2px solid var(--color-border-light, #333);
}

.comment.reply .user-avatar .avatar-image {
  width: 32px;
  height: 32px;
}

.comment-use-date {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: 0;
  flex: 1;
  min-width: 0;
}

.comment-username {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.comment-username:hover {
  color: var(--color-primary, #f5a623);
}

.comment-timestamp {
  font-size: 12px;
  color: var(--color-text-muted, #666);
}

/* ========================================
   COMMENT CONTENT
   ======================================== */

.comment-content {
  margin: 0 0 10px 52px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text-secondary);
  word-wrap: break-word;
  white-space: pre-wrap;
}

.comment.reply .comment-content {
  margin-left: 44px;
}

/* ========================================
   COMMENT ACTIONS
   ======================================== */

.comment-actions {
  margin-left: 52px;
  display: flex;
  gap: 16px;
}

.comment.reply .comment-actions {
  margin-left: 44px;
}

.comment-actions button {
  background: none;
  border: none;
  color: var(--color-text-muted, #666);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.comment-actions button::before {
  content: '\f3e5';
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  font-size: 11px;
}

.comment-actions button:hover {
  color: var(--color-primary, #f5a623);
  background-color: rgba(245, 166, 35, 0.1);
}

/* ========================================
   REPLY INPUT
   ======================================== */

.reply-input-container {
  margin: 12px 0 0 52px;
  animation: slideDown 0.2s ease-out;
}

.comment.reply .reply-input-container {
  margin-left: 44px;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.reply-input {
  width: 100%;
  min-height: 60px;
  padding: 10px 12px;
  border: 1px solid var(--color-border-medium, #444);
  border-radius: var(--radius-md);
  background-color: var(--color-bg-element, #1a1a1a);
  color: var(--color-text-primary);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.reply-input:focus {
  outline: none;
  border-color: var(--color-primary, #f5a623);
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.15);
}

.reply-input::placeholder {
  color: var(--color-text-muted, #666);
}

.reply-buttons {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.reply-buttons button {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.reply-buttons button:first-child {
  background: var(--color-primary, #f5a623);
  color: #000;
}

.reply-buttons button:first-child:hover {
  background: var(--color-primary-hover, #e6991a);
}

.reply-buttons button:last-child {
  background: var(--color-bg-tertiary, #333);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border-medium, #444);
}

.reply-buttons button:last-child:hover {
  background: var(--color-bg-hover, #3a3a3a);
}

/* ========================================
   LOADING & STATES
   ======================================== */

.comment-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--color-text-muted, #666);
}

.comment-loading::before {
  content: '\f110';
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  margin-right: 10px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ========================================
   NEW MESSAGE HIGHLIGHT
   ======================================== */

.comment.new-message {
  animation: highlightNew 2s ease-out;
}

@keyframes highlightNew {
  0% {
    background-color: rgba(245, 166, 35, 0.2);
  }
  100% {
    background-color: var(--color-bg-card, #252525);
  }
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  #comments-container {
    padding: 12px;
  }

  #comment-form {
    padding: 12px;
  }

  #message-input {
    min-height: 60px;
    padding: 10px 12px;
    font-size: 16px; /* Prevent zoom on iOS */
  }

  .comment {
    padding: 12px;
  }

  .comment.reply {
    padding-left: 20px;
  }

  .comment.reply::before {
    left: 8px;
  }

  .user-avatar .avatar-image {
    width: 36px;
    height: 36px;
  }

  .comment.reply .user-avatar .avatar-image {
    width: 28px;
    height: 28px;
  }

  .comment-content {
    margin-left: 48px;
    font-size: 14px;
  }

  .comment.reply .comment-content {
    margin-left: 40px;
  }

  .comment-actions {
    margin-left: 48px;
  }

  .comment.reply .comment-actions {
    margin-left: 40px;
  }

  .reply-input-container {
    margin-left: 48px;
  }

  .comment.reply .reply-input-container {
    margin-left: 40px;
  }

  .reply-input {
    font-size: 16px; /* Prevent zoom on iOS */
  }

  .comment-buttons {
    flex-direction: column;
  }

  .comment-buttons button,
  #post-comment {
    width: 100%;
    justify-content: center;
  }
}

/* ========================================
   DARK MODE ADJUSTMENTS
   (Already using CSS variables, but explicit overrides if needed)
   ======================================== */

/* Links in comments */
.comment-content a {
  color: var(--color-primary, #f5a623);
  text-decoration: none;
}

.comment-content a:hover {
  text-decoration: underline;
}

/* Code in comments */
.comment-content code {
  background-color: var(--color-bg-element, #1a1a1a);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}
