/* =====================================================
   COMPONENTS - TECH BLOGGERS
   =====================================================
   Reusable component styles:
   - Navbar
   - Global Buttons
   - Global Form Controls
   - Footer
===================================================== */

/* ==========================
   NAVBAR
========================== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #161b22;
  padding: 1rem 0;
  border-bottom: 1px solid #30363d;
}

.nav-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #161b22;
  flex-wrap: wrap;
}

.nav-logo {
  font-size: 1.5rem;
  font-weight: bold;
  color: #58a6ff;
  transition: text-shadow 0.3s ease;
}

.nav-logo:hover {
  text-shadow: 0 0 8px #58a6ff;
}

/* Nav menu */
.nav-menu {
  display: flex;
  align-items: center;
  gap: 5rem;
  flex-wrap: nowrap;
}

/* Center nav-links when no authenticated user elements */
.nav-content--guest {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 2rem;
  min-height: 60px; /* Ensure proper height */
}

.nav-menu--guest {
  display: contents; /* Make the nav-menu transparent to grid */
}

.nav-menu--guest .nav-links {
  display: flex;
  gap: 3.5rem;
  justify-content: center;
  grid-column: 2; /* Place in middle column */
}

.nav-menu--guest .nav-buttons {
  display: flex;
  gap: 1rem;
  grid-column: 3; /* Place in right column */
  justify-content: flex-end;
}

.nav-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: nowrap;
  font-size: 1.2rem;
  margin-left: 2rem;
}

.nav-links a {
  color: #c9d1d9;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

.nav-links a:hover {
  color: #58a6ff;
  text-shadow: 0 0 6px #58a6ff;
}

.nav-buttons {
  display: flex;
  gap: 1rem;
  flex-shrink: 0;
  white-space: nowrap;
}

.nav-buttons .btn {
  margin-left: 0.5rem;
}

/* User Greeting */
.user-greeting {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 1rem;
  padding: 0.5rem 1rem;
  background: rgba(88, 166, 255, 0.1);
  border: 1px solid rgba(88, 166, 255, 0.2);
  border-radius: 2rem;
  transition: all 0.3s ease;
}

.user-greeting:hover {
  background: rgba(88, 166, 255, 0.15);
  border-color: rgba(88, 166, 255, 0.3);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #58a6ff;
}

.user-avatar--default {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #30363d;
  color: #58a6ff;
  font-size: 0.875rem;
}

.user-name {
  color: #c9d1d9;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  cursor: pointer;
  gap: 4px;
  padding: 0.5rem;
  z-index: 1001;
}

.hamburger span {
  width: 25px;
  height: 3px;
  background: #fff;
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* Hamburger Animation */
.hamburger.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.go-to-all-btn-container {
  display: flex;
  justify-content: center;
  margin: 3rem;
}

/* ==========================
   GLOBAL BUTTON STYLES
========================== */

/* Base Button */
.btn {
  display: inline-block;
  padding: 0.7rem 1.3rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  text-decoration: none;
  border: 1px solid transparent;
}

.btn--primary {
  background: #58a6ff;
  color: #fff;
  border-color: #58a6ff;
}

.btn--primary:hover {
  background: #1f6feb;
  border-color: #1f6feb;
  color: #fff;
}

.btn--outline {
  background: transparent;
  color: #58a6ff;
  border-color: #58a6ff;
}

.btn--outline:hover {
  background: rgba(88, 166, 255, 0.1);
  color: #fff;
}

.btn--action {
  background: #30363d;
  color: #fff;
  border-color: #30363d;
}

.btn--action:hover {
  background: #58a6ff;
  border-color: #58a6ff;
}

.btn--icon {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn--warning {
  background: #ffc107;
  color: #000;
  border: 1px solid #ffc107;
}

.btn--warning:hover {
  background: #ffca2c;
  border-color: #ffca2c;
  color: #000;
}

.btn--danger {
  background: #f85149;
  color: #fff;
  border-color: #f85149;
}

.btn--danger:hover {
  background: #da3633;
  border-color: #da3633;
  color: #fff;
}

.btn--secondary {
  background: #30363d;
  color: #c9d1d9;
  border-color: #30363d;
}

.btn--secondary:hover {
  background: #484f58;
  border-color: #484f58;
  color: #fff;
}

/* ============================
   GLOBAL FORM CONTROLS
   ============================ */

.form-control {
  width: 100%;
  padding: 0.8rem 1rem;
  border-radius: 6px;
  border: 1px solid #30363d;
  background: #0d1117;
  color: #c9d1d9;
  font-size: 1rem !important;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif !important;
  line-height: 1.6;
  resize: vertical;
  box-sizing: border-box; /* prevents overflow */
}

/* Browser-specific fixes for consistent textarea rendering */
.form-control::-webkit-input-placeholder {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  font-size: 1rem;
}

.form-control::-moz-placeholder {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  font-size: 1rem;
}

.form-control:-ms-input-placeholder {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  font-size: 1rem;
}

.form-control::placeholder {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  font-size: 1rem;
}

/* Additional textarea-specific fixes for Chrome */
textarea.form-control {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif !important;
  font-size: 1rem !important;
}

/* Force font styling on all textarea elements */
textarea {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif !important;
  font-size: 1rem !important;
}

/* Specific targeting for create post form textarea */
.create-post-form textarea#id_content {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif !important;
  font-size: 1rem !important;
}

/* Target any textarea with id_content */
#id_content {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif !important;
  font-size: 1rem !important;
}

/* Additional Chrome-specific fix for textarea font rendering */
textarea.form-control,
textarea[class*="form-control"] {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif !important;
  font-size: 1rem !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Ultra-specific targeting for the content textarea */
textarea#id_content.form-control {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif !important;
  font-size: 1rem !important;
  font-weight: normal !important;
  font-style: normal !important;
  -webkit-font-smoothing: antialiased !important;
  -moz-osx-font-smoothing: grayscale !important;
}

/* Nuclear option - target by attribute */
textarea[id="id_content"] {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif !important;
  font-size: 1rem !important;
}

/* Chrome-specific fix for textarea font rendering bug */
@supports (-webkit-appearance: none) {
  textarea#id_content {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    font-size: 1rem !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
  }
}

/* Force font rendering with CSS transform trick */
textarea#id_content {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform;
}

/* Chrome textarea font bug workaround */
textarea#id_content {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
  font-size: 1rem !important;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background: #0d1117 !important;
  color: #c9d1d9 !important;
}

/* Force re-render on focus */
textarea#id_content:focus {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
  font-size: 1rem !important;
}

/* Tag Selector Interface */
.tag-selector {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 1rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.tag-selector:focus-within {
  border-color: #58a6ff;
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.25);
}

/* Available Tags Container */
.available-tags-container {
  /* Removed border-top and padding-top since it's now the only section */
}

.available-tags-label {
  font-size: 0.9rem;
  color: #c9d1d9;
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.available-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.available-tag {
  display: inline-block;
  background: rgba(48, 54, 61, 0.5);
  color: #c9d1d9;
  padding: 0.25rem 0.9rem;
  border-radius: 15px;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid #30363d;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.available-tag:hover {
  background: rgba(88, 166, 255, 0.1);
  border-color: rgba(88, 166, 255, 0.3);
  color: #58a6ff;
  transform: translateY(-1px);
}

.available-tag.selected {
  background: rgba(88, 166, 255, 0.15);
  border-color: rgba(88, 166, 255, 0.3);
  color: #58a6ff;
  cursor: default;
  transform: none;
}

.available-tag.disabled {
  background: rgba(48, 54, 61, 0.3);
  color: #6e7681;
  border-color: #21262d;
  cursor: not-allowed;
  opacity: 0.6;
}

.available-tag.disabled:hover {
  background: rgba(48, 54, 61, 0.3);
  border-color: #21262d;
  color: #6e7681;
  transform: none;
}

/* Tag Animation - Simplified for toggle functionality */
@keyframes tag-toggle {
  from {
    transform: scale(0.95);
  }
  to {
    transform: scale(1);
  }
}

.available-tag.selected {
  animation: tag-toggle 0.2s ease;
}

/* Hidden File Input */
.hidden-file-input {
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  z-index: -1;
}

/* Hide avatar file input completely */
#avatar-input,
input[type="file"][name="avatar"] {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  position: absolute !important;
  z-index: -999 !important;
  visibility: hidden !important;
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-start;
  align-items: center;
}

.form-control:focus {
  outline: none;
  border-color: #58a6ff;
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.25);
}

.form-control.error {
  border-color: var(--error-color);
}

.form-control.error:focus {
  border-color: var(--error-color);
  box-shadow: 0 0 0 2px rgba(248, 81, 73, 0.25);
}

/* Labels */
.form-group label {
  color: #c9d1d9;
  font-weight: 500;
  margin-bottom: 0.5rem;
  display: block;
}

/* Full-width rows (Contact form) */
.form-group.full-width,
.form-actions.full-width {
  grid-column: 1 / -1;
}

/* Form Spacing Consistency */
form label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #c9d1d9;
}

form .form-control,
form input,
form textarea,
form select {
  margin-bottom: 0.5rem; /* consistent spacing */
}

form button,
form .btn {
  margin-top: 0.5rem; /* small space above buttons */
}

/* Center align form buttons by default */
form button,
form .btn {
  display: block;
}

/* ==========================
   DJANGO MESSAGES FRAMEWORK
========================== */

.messages {
  position: fixed;
  top: 90px; /* Below navbar with small gap */
  left: 20px;
  z-index: 1000;
  width: auto;
  min-width: 300px;
  max-width: calc(100% - 40px);
  opacity: 1;
  transform: translateX(0);
  transition: all 0.5s ease-out;
}

.messages .form-feedback {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  color: #c9d1d9;
}

.messages .form-feedback.success {
  background-color: var(--success-bg);
  border-color: var(--success-color);
  color: var(--success-color);
}

.messages .form-feedback.error {
  background-color: var(--error-bg);
  border-color: var(--error-color);
  color: var(--error-color);
}

.form-feedback {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  min-height: 1.2rem;
}

/* ==========================
   FOOTER
========================== */

.footer {
  text-align: center;
  padding: 1.5rem;
  background: #161b22;
  border-top: 1px solid #30363d;
  font-size: 0.9rem;
  color: #8b949e;
  margin-top: auto;
}

.footer a {
  color: #58a6ff;
  transition: text-shadow 0.3s ease;
}

.footer a:hover {
  text-decoration: underline;
  text-shadow: 0 0 5px #58a6ff;
}
