/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Shimmer loading effect */
.skeleton {
  position: relative;
  overflow: hidden;
  background-color: #f3f4f6;
}

.skeleton::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0,
    rgba(255, 255, 255, 0.2) 20%,
    rgba(255, 255, 255, 0.5) 60%,
    rgba(255, 255, 255, 0)
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

.skeleton-text {
  height: 1rem;
  border-radius: 0.25rem;
  margin-bottom: 0.5rem;
}

.skeleton-text-sm {
  height: 0.875rem;
  border-radius: 0.25rem;
}

.skeleton-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
}

.skeleton-avatar.w-16 {
  width: 4rem;
}

.skeleton-avatar.h-16 {
  height: 4rem;
}

.skeleton-badge {
  height: 1.5rem;
  width: 5rem;
  border-radius: 9999px;
}

.skeleton-content {
  height: 4rem;
  border-radius: 0.5rem;
}

/* Fixed background div for cracks overlay (iOS compatible) */
.fixed-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #f9fafb;
  background-image: url("/cracks.jpg");
  background-size: auto 100vh;
  background-position: 20% center;
  background-repeat: no-repeat;
  z-index: -1;
  pointer-events: none;
}

/* Hashtag Editor Styles */
.hashtag-editor {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  outline: none;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: inherit;
  font-size: inherit;
  line-height: 1.5;
}

.hashtag-editor:focus {
  border-color: #3b82f6;
  ring: 2px;
  ring-color: rgba(59, 130, 246, 0.5);
}

.hashtag-editor:empty:before {
  content: attr(data-placeholder);
  color: #9ca3af;
  pointer-events: none;
}

.hashtag-editor .hashtag {
  font-weight: 600;
  color: #2563eb;
}

.hashtag-editor .link-text {
  color: #2563eb;
  text-decoration: underline;
  font-weight: normal;
}

/* Make sure hashtags don't break formatting */
.hashtag-editor .hashtag {
  font-weight: 600;
}

.hashtag-editor br {
  display: block;
  content: '';
}

/* Clickable Hashtag Links (for displayed content) */
a.hashtag-link {
  font-weight: 600 !important;
  color: #2563eb !important;
  text-decoration: none !important;
  cursor: pointer;
  transition: color 0.2s ease;
}

a.hashtag-link:hover {
  color: #1d4ed8 !important;
  text-decoration: none !important;
}

/* Clickable Content Links (for displayed content) */
a.content-link {
  color: #2563eb !important;
  text-decoration: underline !important;
  cursor: pointer;
  transition: color 0.2s ease;
}

a.content-link:hover {
  color: #1d4ed8 !important;
}

/* Textarea and button wrapper - keeps button positioned with textarea */
.textarea-button-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Inner wrapper for textarea and button - isolates positioning from progress container */
.textarea-inner-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

/* Attachment Button Styles - positioned relative to textarea inner wrapper */
.attachment-button {
  position: absolute;
  bottom: 8px;
  left: 8px;
  padding: 6px;
  background-color: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #6b7280;
  z-index: 10;
}

.attachment-button:hover {
  background-color: #e5e7eb;
  color: #374151;
}

.attachment-button:active {
  background-color: #d1d5db;
}

/* Attachment Preview Styles */
.attachment-preview {
  margin-top: 8px;
  display: none;
}

.attachment-preview.has-files {
  display: block;
}

.attachment-preview-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  margin-bottom: 6px;
}

.attachment-preview-item:last-child {
  margin-bottom: 0;
}

.attachment-preview-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.attachment-preview-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: #6b7280;
}

.attachment-preview-name {
  font-size: 0.875rem;
  color: #374151;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-preview-size {
  font-size: 0.75rem;
  color: #6b7280;
  margin-left: 8px;
  flex-shrink: 0;
}

.attachment-preview-remove {
  flex-shrink: 0;
  padding: 4px;
  color: #ef4444;
  cursor: pointer;
  transition: color 0.2s ease;
}

.attachment-preview-remove:hover {
  color: #dc2626;
}

.attachment-preview-image {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 0.375rem;
  margin-right: 8px;
}

/* Upload Progress Styles */
.upload-progress-container {
  margin-top: 8px;
}

.upload-progress-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  margin-bottom: 6px;
}

.upload-progress-item:last-child {
  margin-bottom: 0;
}

.upload-progress-info {
  flex: 1;
  min-width: 0;
}

.upload-progress-filename {
  font-size: 0.875rem;
  color: #374151;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}

.upload-progress-bar-container {
  width: 100%;
  height: 4px;
  background-color: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  background-color: #3b82f6;
  transition: width 0.2s ease;
  border-radius: 2px;
}

.upload-progress-bar.complete {
  background-color: #10b981;
}

.upload-progress-cancel {
  flex-shrink: 0;
  padding: 4px;
  color: #ef4444;
  cursor: pointer;
  transition: color 0.2s ease;
}

.upload-progress-cancel:hover {
  color: #dc2626;
}

.upload-progress-status {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 2px;
}

/* Circular Upload Progress Styles */
.upload-progress-item-circular {
  position: relative;
  display: inline-block;
  width: 100px;
  height: 100px;
  margin: 4px;
}

.circular-progress-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.circular-progress {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.circular-progress-bg {
  fill: none;
  stroke: #e5e7eb;
  stroke-width: 3;
}

.circular-progress-bar {
  fill: none;
  stroke: #3b82f6;
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dasharray 0.3s ease;
}

.circular-progress-bar.complete {
  stroke: #10b981;
}

.circular-progress-percent {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
}

.upload-progress-cancel-circular {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background-color: rgba(239, 68, 68, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: background-color 0.2s;
  border: none;
  padding: 0;
}

.upload-progress-cancel-circular:hover {
  background-color: rgb(220, 38, 38);
}

/* Attachment Preview Styles */
.attachment-preview-grid {
  display: grid;
  gap: 1px;
  border-radius: 1rem;
  overflow: hidden;
  background-color: rgb(229, 231, 235);
  max-width: 100%;
  margin-top: 8px;
}

.attachment-preview-grid.count-1 {
  grid-template-columns: 1fr;
  max-width: 150px;
  aspect-ratio: 1;
}

.attachment-preview-grid.count-2 {
  grid-template-columns: 1fr 1fr;
  max-width: 300px;
  aspect-ratio: 1 / 1;
}

.attachment-preview-grid.count-3 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  max-width: 300px;
  aspect-ratio: 1;
}

.attachment-preview-grid.count-3 .attachment-preview-item:first-child {
  grid-row: 1 / 3;
}

.attachment-preview-grid.count-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  max-width: 300px;
  aspect-ratio: 1;
}

.attachment-preview-item {
  position: relative;
  overflow: hidden;
  background-color: rgb(243, 244, 246);
}

.attachment-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  transition: opacity 0.2s;
}

.attachment-preview-item img:hover {
  opacity: 0.9;
}

.attachment-preview-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  background-color: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: background-color 0.2s;
  border: none;
  padding: 0;
  z-index: 10;
}

.attachment-preview-delete:hover {
  background-color: rgba(220, 38, 38, 0.9);
}

.attachment-preview-video {
  position: relative;
  max-width: 400px;
  margin-top: 8px;
  border-radius: 0.5rem;
  overflow: hidden;
  background-color: #000;
}

.attachment-preview-video video {
  width: 100%;
  max-height: 300px;
  display: block;
}

.attachment-preview-document {
  position: relative;
  max-width: 400px;
  margin-top: 8px;
}

.attachment-preview-doc-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background-color: rgb(243, 244, 246);
  border: 1px solid rgb(229, 231, 235);
  border-radius: 0.5rem;
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

.attachment-preview-doc-link:hover {
  background-color: rgb(229, 231, 235);
}

.attachment-preview-doc-icon {
  width: 32px;
  height: 32px;
  color: rgb(107, 114, 128);
  flex-shrink: 0;
}

.attachment-preview-doc-info {
  flex: 1;
  min-width: 0;
}

.attachment-preview-doc-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: rgb(31, 41, 55);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-preview-doc-size {
  font-size: 0.75rem;
  color: rgb(107, 114, 128);
  margin-top: 2px;
}

/* Dark mode support for attachment previews */
@media (prefers-color-scheme: dark) {
  .attachment-preview-grid {
    background-color: rgb(64, 64, 64);
  }

  .attachment-preview-item {
    background-color: rgb(64, 64, 64);
  }

  .circular-progress-bg {
    stroke: #525252;
  }

  .circular-progress-percent {
    color: #e5e5e5;
  }

  .attachment-preview-doc-link {
    background-color: rgb(38, 38, 38);
    border-color: rgb(64, 64, 64);
  }

  .attachment-preview-doc-link:hover {
    background-color: rgb(64, 64, 64);
  }

  .attachment-preview-doc-icon {
    color: rgb(163, 163, 163);
  }

  .attachment-preview-doc-name {
    color: rgb(212, 212, 212);
  }

  .attachment-preview-doc-size {
    color: rgb(163, 163, 163);
  }
}

/* Note: Attachment Display Styles (post-attachments, attachment-grid, attachment-item, lightbox)
 * are now defined in app/assets/tailwind/application.css with X/Twitter-style layout */

/* iOS-styled Toggle Switch for Notifications */
#notify-post-reveal:checked + .block {
  background-color: #3b82f6; /* blue-500 */
}

#notify-post-reveal:checked + .block .dot {
  transform: translateX(1.5rem); /* Move dot to right */
}

#notify-post-reveal:disabled + .block {
  opacity: 0.5;
  cursor: not-allowed;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Dark Mode Styles */
@media (prefers-color-scheme: dark) {
  /* Skeleton loaders */
  .skeleton {
    background-color: #404040; /* neutral-700 */
  }

  .skeleton::after {
    background: linear-gradient(
      90deg,
      rgba(0, 0, 0, 0) 0,
      rgba(255, 255, 255, 0.1) 20%,
      rgba(255, 255, 255, 0.2) 60%,
      rgba(0, 0, 0, 0)
    );
  }

  /* Fixed background */
  .fixed-background {
    opacity: 0.8;
    filter: invert(1);
  }

  /* Hashtag Editor */
  .hashtag-editor {
    background-color: #262626; /* neutral-800 */
    border-color: #525252; /* neutral-600 */
    color: #e5e5e5; /* neutral-200 */
  }

  .hashtag-editor:focus {
    border-color: #60a5fa; /* blue-400 */
    ring-color: rgba(96, 165, 250, 0.5);
  }

  .hashtag-editor:empty:before {
    color: #737373; /* neutral-500 */
  }

  .hashtag-editor .hashtag {
    color: #60a5fa; /* blue-400 */
  }

  .hashtag-editor .link-text {
    color: #60a5fa; /* blue-400 */
  }

  /* Clickable Hashtag Links */
  a.hashtag-link {
    color: #60a5fa !important; /* blue-400 */
  }

  a.hashtag-link:hover {
    color: #93c5fd !important; /* blue-300 */
  }

  /* Clickable Content Links */
  a.content-link {
    color: #60a5fa !important; /* blue-400 */
  }

  a.content-link:hover {
    color: #93c5fd !important; /* blue-300 */
  }

  /* Attachment Button */
  .attachment-button {
    background-color: #404040; /* neutral-700 */
    border-color: #525252; /* neutral-600 */
    color: #a3a3a3; /* neutral-400 */
  }

  .attachment-button:hover {
    background-color: #525252; /* neutral-600 */
    color: #d4d4d4; /* neutral-300 */
  }

  .attachment-button:active {
    background-color: #737373; /* neutral-500 */
  }

  /* Attachment Preview */
  .attachment-preview-item {
    background-color: #262626; /* neutral-800 */
    border-color: #404040; /* neutral-700 */
  }

  .attachment-preview-icon {
    color: #a3a3a3; /* neutral-400 */
  }

  .attachment-preview-name {
    color: #d4d4d4; /* neutral-300 */
  }

  .attachment-preview-size {
    color: #a3a3a3; /* neutral-400 */
  }

  /* Upload Progress */
  .upload-progress-item {
    background-color: #262626; /* neutral-800 */
    border-color: #404040; /* neutral-700 */
  }

  .upload-progress-filename {
    color: #d4d4d4; /* neutral-300 */
  }

  .upload-progress-bar-container {
    background-color: #404040; /* neutral-700 */
  }

  .upload-progress-status {
    color: #a3a3a3; /* neutral-400 */
  }

  /* iOS Toggle Switch */
  #notify-post-reveal + .block {
    background-color: #525252; /* neutral-600 - unchecked state */
  }

  #notify-post-reveal:checked + .block {
    background-color: #3b82f6; /* blue-500 - stays same when checked */
  }
}


/* Logo SVG with drop shadow */
.logo-svg {
  filter: brightness(0) drop-shadow(2px 2px 1px rgba(0, 0, 0, 0.3));
}

/* Logo SVG invert for dark theme with drop shadow */
@media (prefers-color-scheme: dark) {
  .logo-svg {
    filter: grayscale(1) brightness(2.5) contrast(1.5) drop-shadow(2px 2px 1px rgba(192, 201, 206, 0.5));
  }
}
