/* ==========================================================================
   Buttons
   ========================================================================== */

/* Button Base Styles */
.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--border-radius-sm);
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background-color var(--transition-fast),
    box-shadow var(--transition-fast);
  text-decoration: none;
}

/* Block Button (Full Width) */
.btn-block {
  width: 100%;
  display: flex;
}

/* Primary Button Styles */
.btn-primary,
button.primary {
  background-color: var(--color-primary);
  color: var(--color-primary-button-text);
}

.btn-primary:hover,
button.primary:hover {
  background-color: var(--color-primary-dark);
  color: var(--color-primary-button-text);
}

/* Google Button Styles */
.btn-google {
  background-color: #ffffff;
  color: #1f2937;
  border: 1px solid #d1d5db;
  position: relative;
  transition: all var(--transition-fast);
}

.btn-google:hover {
  background-color: #f9fafb;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  color: #1f2937;
  text-decoration: none;
}

.btn-google:focus {
  box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.3);
  outline: none;
}

.btn-google i {
  margin-right: 0.75rem;
  font-size: 1.1em;
  color: #4285f4;
}

/* Dark mode adjustments for Google button */
@media (prefers-color-scheme: dark) {
  .btn-google {
    background-color: #1f2937;
    color: #ffffff;
    border-color: #374151;
  }

  .btn-google:hover {
    background-color: #374151;
    color: #ffffff;
  }
}

/* OR Divider Styling */
.or-divider {
  display: flex;
  align-items: center;
  margin: 1.5rem 0;
  position: relative;
}

.or-divider::before {
  content: '';
  flex: 1;
  height: 1px;
  background-color: var(--color-border);
}

.or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: var(--color-border);
}

.or-text {
  padding: 0 1rem;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  background-color: var(--color-background);
}

/* Secondary Button Styles */
.btn-secondary,
button.secondary {
  background-color: var(--color-background);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.btn-secondary:hover,
button.secondary:hover {
  background-color: var(--color-surface);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-pill);
  border: 1px solid transparent;
  color: var(--color-text);
  background: transparent;
  font-weight: 500;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.btn-ghost:hover {
  border-color: var(--color-border);
  color: var(--color-primary);
}

/* Disabled State */
.btn:disabled,
button:disabled {
  background-color: var(--color-secondary);
  color: var(--color-primary-button-text);
  cursor: not-allowed;
}

.btn-danger {
  background-color: var(--color-error);
  color: var(--color-primary-button-text);
}

.btn-danger:hover {
  background-color: var(--color-error);
  opacity: 0.9;
}

/* Spinner Animation */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-right: 8px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: var(--color-primary-button-text);
  animation: spin 1s ease-in-out infinite;
  vertical-align: middle;
}

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

/* Ensure spinner is visible on disabled buttons */
.btn:disabled .spinner,
button:disabled .spinner {
  opacity: 1;
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background-color: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--color-text);
  font-weight: 500;
}

.form-control {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  background-color: var(--color-surface);
  color: var(--color-text);
  font-size: 1rem;
  transition: border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

.form-control:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
  outline: none;
}

input,
textarea,
select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  background-color: var(--color-surface);
  color: var(--color-text);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
  outline: none;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
  width: auto;
}

.checkbox-group label {
  margin-bottom: 0;
}

.auth-form .flash-message {
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius-md);
  background-color: var(--color-primary);
  color: var(--color-primary-button-text);
  margin: 1rem 0;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.auth-form .flash-message.error {
  background-color: var(--color-error);
}

.auth-form .flash-message.success {
  background-color: var(--dstla-graphite);
  color: var(--dstla-signal-green);
  border: 1px solid var(--dstla-signal-green);
}

/* ==========================================================================
   Flash Messages
   ========================================================================== */

.flash-messages {
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.flash-message {
  padding: 1rem 1.5rem;
  border-radius: var(--border-radius-md);
  background-color: var(--dstla-graphite);
  color: var(--dstla-cloud);
  border: 1px solid var(--color-border);
  margin-bottom: 1rem;
  font-size: 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 600px;
}

.flash-message .close-flash {
  background: none;
  border: none;
  color: var(--dstla-cloud);
  font-size: 1.25rem;
  cursor: pointer;
  opacity: 0.7;
}

.flash-message .close-flash:hover {
  opacity: 1;
}

.flash-message.success {
  color: var(--dstla-signal-green);
  border-color: var(--dstla-signal-green);
}

.flash-message.error {
  color: var(--dstla-error);
  border-color: var(--dstla-error);
}

/* ==========================================================================
   Modals
   ========================================================================== */

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(31, 41, 55, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.1s ease-in-out;
  overflow: hidden;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.modal.fadeOut {
  animation: fadeOut 0.1s ease-in-out;
}

.modal-content {
  background-color: var(--color-background);
  margin: 5% auto;
  padding: 2rem;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--color-border);
  max-width: 800px;
  min-width: min(90vw, 600px);
  width: 90%;
  position: relative;
  box-shadow: var(--shadow-lg);
  max-height: 85vh;
  overflow-y: auto;
}

.modal .close {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 1010;

  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--color-background);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);

  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;

  /* Text styling */
  color: var(--color-text-light);
  font-size: 1.5rem;
  line-height: 1;

  transition: all var(--transition-fast);
}

.modal .close:hover {
  background-color: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-md);
}

/* Danger Zone Button */
.btn-danger {
  background-color: var(--color-error);
  color: #ffffff;
}

.btn-danger:hover {
  background-color: #b91c1c;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
}

.pagination a {
  display: inline-block;
  padding: 0.5rem 1rem;
  margin: 0 0.25rem;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  transition: background-color var(--transition-fast);
}

.pagination a:hover {
  background-color: var(--color-surface);
}

.pagination .current-page {
  background-color: var(--color-primary);
  color: var(--color-primary-button-text);
  border-color: var(--color-primary);
}

/* ==========================================================================
   Dropdowns
   ========================================================================== */

/* Already defined in layout.css for nav */

.error-message {
  background-color: var(--color-surface);
  border: 1px solid var(--color-error);
  border-radius: var(--border-radius-md);
  padding: 1.5rem;
  text-align: center;
}

.error-message .error-icon {
  font-size: 2rem;
  margin-bottom: 1rem;
  display: block;
}

.error-message p {
  margin: 0.5rem 0;
  color: var(--color-text);
}

.error-support {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--color-text-light);
}

.error-support a {
  color: var(--color-primary);
  text-decoration: underline;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}

.link-button:hover {
  color: var(--color-primary-dark);
}

.prompt-preview {
  background-color: var(--color-surface);
  padding: 1.25rem;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--color-border);
  white-space: pre-wrap;
  font-family: var(--font-family-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  overflow-x: auto;
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

.streaming-response {
  white-space: pre;
  overflow-y: auto;
  height: 300px;
  font-family: monospace;
}

/* Image lightbox */
body.lightbox-open {
  overflow: hidden;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
}

.image-lightbox__content {
  position: relative;
  max-width: min(90vw, 960px);
  max-height: 90vh;
  padding: 1rem;
  background: var(--color-background);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-lightbox__content img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--border-radius-md);
  object-fit: contain;
}

.image-lightbox__close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  border: none;
  background: transparent;
  color: var(--color-text-light);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--transition-fast);
  z-index: 10;
}

.image-lightbox__close:hover {
  background-color: var(--color-surface);
  color: var(--color-text);
}

.image-lightbox__close svg {
  width: 24px;
  height: 24px;
}
