/**
 * 📰 Articles System Styles
 */

/* Page Layout */
.articles-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 80px 20px 40px;
}

.articles-container {
  max-width: 800px;
  margin: 0 auto;
}

/* Header */
.articles-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.articles-header h1 {
  margin: 0 0 8px 0;
  color: #2d3748;
  font-size: 2em;
}

.articles-header p {
  margin: 0;
  color: #718096;
}

.create-article-btn {
  padding: 12px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

.create-article-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Article Feed */
.article-feed {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Article Card */
.article-card {
  background: white;
  border-radius: 12px;
  overflow: visible; /* Allow content to be fully visible */
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  min-height: auto; /* Let card size naturally */
}

.article-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

/* Article Header */
.article-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}

.author-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.author-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e2e8f0;
}

.author-avatar-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  border: 2px solid #e2e8f0;
}

.author-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.author-name {
  font-weight: 600;
  color: #2d3748;
}

.article-time {
  font-size: 0.85em;
  color: #718096;
}

.delete-article-btn {
  background: none;
  border: none;
  font-size: 1.2em;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.delete-article-btn:hover {
  opacity: 1;
}

/* Article Image */
.article-image {
  width: 100%;
  max-height: 500px;
  overflow: hidden;
  background: #f7fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px 12px 0 0; /* Round top corners only */
}

.article-image img {
  width: 100%;
  height: auto;
  max-height: 500px;
  object-fit: contain;
  display: block;
}

/* Article Content */
.article-content {
  padding: 20px;
  flex: 1; /* Allow content to grow */
}

.article-title {
  margin: 0 0 12px 0;
  font-size: 1.5em;
  color: #2d3748;
  line-height: 1.3;
}

.article-text {
  margin: 0;
  color: #4a5568;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  /* Removed max-height to show full content */
}

/* Poll */
.article-poll {
  padding: 20px;
  background: #f7fafc;
  border-top: 1px solid #e2e8f0;
}

.poll-question {
  margin: 0 0 16px 0;
  font-size: 1.1em;
  color: #2d3748;
}

.poll-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.poll-option {
  padding: 12px;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.poll-option:hover {
  border-color: #667eea;
  background: #f0f4ff;
}

.poll-option.selected {
  border-color: #667eea;
  background: #e6f2ff;
}

.poll-option-text {
  margin-bottom: 8px;
  font-weight: 500;
  color: #2d3748;
}

.poll-option-bar {
  position: relative;
  height: 24px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.poll-option-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  transition: width 0.5s ease;
}

.poll-option-percentage {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85em;
  font-weight: 600;
  color: #2d3748;
  z-index: 1;
}

.poll-total-votes {
  margin: 0;
  font-size: 0.9em;
  color: #718096;
  text-align: center;
}

/* Interactions */
.article-interactions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid #e2e8f0;
  margin-top: auto; /* Push to bottom of card */
  background: white; /* Ensure visible */
}

.vote-buttons {
  display: flex;
  gap: 12px;
}

.vote-btn {
  padding: 8px 16px;
  background: #f7fafc;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.vote-btn:hover {
  background: #e6f2ff;
  border-color: #667eea;
}

.vote-btn.support.active {
  background: #48bb78;
  border-color: #48bb78;
  color: white;
}

.vote-btn.oppose.active {
  background: #f56565;
  border-color: #f56565;
  color: white;
}

.comment-toggle-btn {
  padding: 8px 16px;
  background: none;
  border: none;
  font-weight: 600;
  color: #667eea;
  cursor: pointer;
  transition: color 0.2s;
}

.comment-toggle-btn:hover {
  color: #764ba2;
}

/* Comments */
.article-comments {
  padding: 20px;
  background: #f7fafc;
  border-top: 1px solid #e2e8f0;
  display: block; /* Ensure always visible when present */
  border-radius: 0 0 12px 12px; /* Round bottom corners */
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

.comment {
  padding: 12px;
  background: white;
  border-radius: 8px;
  border-left: 3px solid #667eea;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.comment-author {
  font-weight: 600;
  color: #2d3748;
}

.comment-time {
  font-size: 0.85em;
  color: #718096;
}

.comment-text {
  margin: 0;
  color: #4a5568;
  line-height: 1.5;
}

.no-comments {
  text-align: center;
  color: #718096;
  font-style: italic;
}

.comment-input-container {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.comment-input {
  flex: 1;
  padding: 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95em;
  resize: vertical;
  min-height: 60px;
  transition: border-color 0.2s;
}

.comment-input:focus {
  outline: none;
  border-color: #667eea;
}

.submit-comment-btn {
  padding: 12px 24px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.submit-comment-btn:hover {
  background: #764ba2;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.article-modal {
  padding: 30px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-header h2 {
  margin: 0;
  color: #2d3748;
}

.close-modal {
  background: none;
  border: none;
  font-size: 2em;
  color: #718096;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.close-modal:hover {
  color: #2d3748;
}

/* Form */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #2d3748;
}

.form-group input[type="text"],
.form-group input[type="file"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1em;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #667eea;
}

.form-group small {
  display: block;
  margin-top: 6px;
  color: #718096;
  font-size: 0.85em;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.image-preview {
  margin-top: 12px;
  text-align: center;
}

/* Poll Options List */
.poll-options-container {
  padding: 20px;
  background: #f7fafc;
  border-radius: 8px;
  margin-bottom: 20px;
}

.poll-options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.poll-option-input {
  display: flex;
  gap: 8px;
}

.poll-option-input input {
  flex: 1;
}

.remove-option-btn {
  width: 36px;
  height: 36px;
  background: #fed7d7;
  color: #c53030;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.2em;
  transition: background 0.2s;
}

.remove-option-btn:hover {
  background: #fc8181;
  color: white;
}

.add-option-btn {
  padding: 8px 16px;
  background: white;
  border: 2px dashed #cbd5e0;
  border-radius: 6px;
  color: #667eea;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.add-option-btn:hover {
  border-color: #667eea;
  background: #f0f4ff;
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

.btn-primary,
.btn-secondary {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: #e2e8f0;
  color: #2d3748;
}

.btn-secondary:hover {
  background: #cbd5e0;
}

/* Loading & Empty States */
.loading-state,
.empty-state,
.error-state {
  text-align: center;
  padding: 60px 20px;
  background: white;
  border-radius: 12px;
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 16px;
  border: 4px solid #e2e8f0;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.empty-state p,
.error-state p {
  color: #718096;
  font-size: 1.1em;
}

/* Responsive */
@media (max-width: 768px) {
  .articles-header {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

  .create-article-btn {
    width: 100%;
  }

  .article-interactions {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .vote-buttons {
    justify-content: space-between;
  }

  .form-actions {
    flex-direction: column;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
  }
}
