/* ── Add Image Section ── */
.add-image-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  max-width: 1200px;
  width: calc(100% - 4rem);
  margin: 0.75rem auto 0;
  box-shadow: var(--shadow-sm);
  animation: slideDown 0.22s ease forwards;
}

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

.add-image-form {
  max-width: 1200px;
  margin: 0 auto;
  gap: 0.75rem 1rem;
  align-items: end;
}

/* button uses col-auto (flex:1) — cap it so it doesn't stretch too wide */
.add-image-form button[type="submit"] {
  max-width: fit-content;
}

/* Labels sit above their input */
.add-image-form label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

/* Wrap each label+input pair */
.add-image-form .field {
  display: flex;
  flex-direction: column;
}

.add-image-form input[type="text"],
.add-image-form input[type="url"],
.add-image-form input[type="file"] {
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: "DM Sans", sans-serif;
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
  outline: none;
}

.add-image-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* File picker button */
.add-image-form input[type="file"] {
  padding: 0.35rem 0.5rem;
  cursor: pointer;
}

.add-image-form input[type="file"]::file-selector-button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.3rem 0.85rem;
  border-radius: calc(var(--radius) - 2px);
  font-family: "DM Sans", sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  margin-right: 0.75rem;
  transition: background 0.15s ease;
}

.add-image-form input[type="file"]::file-selector-button:hover {
  background: var(--accent-hover);
}

.add-image-form input::placeholder {
  color: #bbb7b2;
}

.add-image-form button[type="submit"] {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.58rem 1.4rem;
  border-radius: var(--radius);
  font-family: "DM Sans", sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.18s ease,
    transform 0.12s ease;
  align-self: flex-end;
}

.add-image-form button[type="submit"]:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.add-image-form button[type="submit"]:active {
  transform: translateY(0);
}

/* ----------------------------------------- */
.image-comment-form {
  max-width: 1200px;
  margin: 0 auto;
  gap: 0.75rem 1rem;
  align-items: start;
  display: flex;
  flex-direction: column;
}

/* Labels sit above their input */
.image-comment-form label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

/* Wrap each label+input pair */
.image-comment-form .field {
  display: flex;
  flex-direction: column;
}

.image-comment-form input[type="text"],
.image-comment-form input[type="url"] {
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: "DM Sans", sans-serif;
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
  outline: none;
}

.image-comment-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.image-comment-form input::placeholder {
  color: #bbb7b2;
}

.image-comment-form button[type="submit"] {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.58rem 1.4rem;
  border-radius: var(--radius);
  font-family: "DM Sans", sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.18s ease,
    transform 0.12s ease;
}

.image-comment-form button[type="submit"]:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.image-comment-form button[type="submit"]:active {
  transform: translateY(0);
}

/* Inline sign-in / sign-up forms that drop down from the header */
.auth-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  box-shadow: var(--shadow-md);
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 2rem;
  z-index: 200;
  min-width: 280px;
}

.auth-form input[type="text"],
.auth-form input[type="password"] {
  flex: 1;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  font-family: "DM Sans", sans-serif;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--bg);
  outline: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.auth-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.auth-form button[type="submit"] {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.45rem 1rem;
  border-radius: calc(var(--radius) - 2px);
  font-family: "DM Sans", sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.auth-form button[type="submit"]:hover {
  background: var(--accent-hover);
}

@media (max-width: 576px) {
  header {
    padding: 0 1rem;
  }

  header .row {
    min-height: auto;
    padding: 0.75rem 0;
    gap: 0.5rem;
  }

  header h1 {
    font-size: 1.2rem;
  }

  .header-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Gallery */
  .image-gallery {
    margin: 1rem auto;
    padding: 0 1rem;
  }

  /* Image card */
  .imageCard {
    margin-bottom: 1.25rem;
    border-radius: calc(var(--radius) / 2);
  }

  .image-card-body {
    padding: 1rem;
  }

  .image-card-title {
    font-size: 1.05rem;
  }

  .image-card-comment-list {
    padding-left: 0;
    padding-top: 1.25rem;
    border-left: none;
    border-top: 1px solid var(--border);
    margin-top: 1.25rem;
  }

  .comments-prev,
  .comments-next {
    width: 100%;
    text-align: center;
  }

  /* Footer */
  footer {
    padding: 1.25rem 1rem;
  }
}

@media (min-width: 577px) and (max-width: 768px) {
  header {
    padding: 0 1.25rem;
  }

  .image-gallery {
    padding: 0 1.25rem;
  }

  .image-card-body {
    padding: 1rem 1.25rem 1.25rem;
  }
}

@media (max-width: 576px) {
  /* Add image section */
  .add-image-section {
    padding: 1rem;
    width: calc(100% - 2rem);
  }

  /* Stack all form fields full-width (fields have no col-sm-* classes) */
  .add-image-form .field,
  .add-image-form button[type="submit"] {
    flex-basis: 100%;
    max-width: 100%;
  }

  .add-image-form button[type="submit"] {
    width: 100%;
  }

  .add-image-form input[type="file"]::file-selector-button {
    width: 100%;
    margin-right: 0;
    margin-bottom: 0.4rem;
    border-radius: var(--radius);
  }

  /* Auth form goes full width on mobile */
  .auth-form {
    position: static;
    flex-wrap: wrap;
    width: 100%;
    min-width: unset;
    margin-top: 0.5rem;
  }

  .auth-form input {
    flex-basis: 100%;
  }

  .auth-form button[type="submit"] {
    flex-basis: 100%;
  }

  /* Comment form */
  .image-comment-form {
    gap: 0.5rem;
  }

  .image-comment-form input[type="text"],
  .image-comment-form textarea {
    font-size: 1rem; /* prevent iOS auto-zoom on focus */
  }

  .image-comment-form button[type="submit"] {
    width: 100%;
  }
}

@media (min-width: 577px) and (max-width: 768px) {
  .add-image-section {
    padding: 1.25rem;
  }

  /* 2 fields per row on tablet */
  .add-image-form .field {
    flex-basis: calc(50% - 0.5rem);
  }

  .add-image-form button[type="submit"] {
    flex-basis: 100%;
    max-width: fit-content;
  }
}
