body {
  margin: 0;
  font-family: "Inter", "DM Sans", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.3s, color 0.3s;
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 220px;
  height: 100vh;
  background: var(--sidebar-bg);
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  z-index: 10;
}

.logo {
  width: 80px;
  margin-bottom: 2rem;
}

.sidebar nav ul {
  list-style: none;
  padding: 0;
  width: 100%;
}

.sidebar nav ul li {
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  text-align: center;
  font-weight: 500;
  transition: background 0.2s;
}

.sidebar nav ul li:hover {
  background: var(--sidebar-hover);
}

.theme-toggle {
  display: flex;
  gap: 0.5rem;
}

.theme-toggle button {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}

main {
  margin-left: 240px;
  padding: 2rem;
}

.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}

.landing-logo {
  width: 120px;
  margin-bottom: 1.5rem;
}

h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

p {
  font-size: 1.2rem;
  color: var(--text-secondary);
}

/* Tweet Editor Styles */
.tweet-editor {
  max-width: 1200px;
  margin: 0 auto;
}

.section-description {
  margin-bottom: 2rem;
  color: var(--text-secondary);
  text-align: center;
}

.editor-container {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.centered-layout {
  justify-content: center;
}

.preview-container {
  flex: 0 1 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tweet-preview {
  width: 100%;
  max-width: 500px;
  background: var(--bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  position: relative;
  margin-bottom: 1rem;
  /* Add fixed dimensions for consistent export */
  box-sizing: border-box;
  overflow: hidden;
}

.tweet-header {
  display: flex;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.profile-image {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  margin-right: 12px;
  flex-shrink: 0;
}

.profile-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-info {
  flex: 1;
}

.name-container {
  display: flex;
  align-items: center;
}

.display-name {
  font-weight: bold;
  margin-right: 4px;
}

.username {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.dot {
  color: var(--text-secondary);
  margin: 0 4px;
}

.time {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.tweet-actions {
  margin-left: auto;
  color: var(--text-secondary);
}

.tweet-content {
  margin-bottom: 12px;
  line-height: 1.4;
}

.tweet-content p {
  margin: 0.5rem 0;
  color: var(--text);
}

.show-more {
  color: #1d9bf0;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-block;
}

.tweet-image-container {
  margin: 0.5rem 0 1rem;
  border-radius: 16px;
  overflow: hidden;
  max-height: 500px;
  position: relative;
}

.tweet-image-container img {
  width: 100%;
  object-fit: cover;
}

.remove-image {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Add export container styles */
.export-container {
  position: fixed;
  top: -9999px;
  left: -9999px;
  width: 500px;
  visibility: hidden;
  z-index: -1;
  background: var(--bg);
  border-radius: 12px;
  overflow: hidden;
  object-fit: cover;
}

/* Image cropper styles */
.image-cropper-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.cropper-container {
  width: 80%;
  max-width: 600px;
  height: 60vh;
  background: var(--bg);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

.cropper-controls {
  width: 80%;
  max-width: 600px;
  padding: 1rem;
  background: var(--bg);
  border-radius: 12px;
  margin-top: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cropper-controls button {
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  font-weight: bold;
}

.cropper-controls .cancel-crop {
  background: var(--bg-secondary);
  color: var(--text);
}

.cropper-controls .apply-crop {
  background: #1d9bf0;
  color: white;
}

.aspect-ratio-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.aspect-ratio-toggle button {
  background: var(--bg-secondary);
  color: var(--text);
  padding: 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.aspect-ratio-toggle button.active {
  background: #1d9bf0;
  color: white;
  border-color: #1d9bf0;
}

.edit-image-button {
  position: absolute;
  bottom: 8px;
  left: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s;
}

.grid-image-container:hover .edit-image-button {
  opacity: 1;
}

/* Tweet stats styling */
.tweet-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-top: 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
  font-size: 13px;
  position: relative;
  z-index: 1;
  max-height: none;
  overflow: visible;
  font-size: 13.5px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-secondary);
  cursor: pointer;
  margin-right: 1rem;
  flex: 0 0 auto;
}

.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon svg {
  fill: var(--text-secondary);
}

.stat:hover .stat-icon svg {
  fill: #1d9bf0;
}

.stat[data-stat="likes"]:hover .stat-icon svg {
  fill: #f91880;
}

.stat[data-stat="retweets"]:hover .stat-icon svg {
  fill: #00ba7c;
}

/* Liked and retweeted states */
.stat[data-stat="likes"].liked .stat-icon svg {
  fill: #f91880 !important;
}

.stat[data-stat="likes"].liked .stat-count {
  color: #f84c9c !important;
}

.stat[data-stat="retweets"].retweeted .stat-icon svg {
  fill: #00ba7c !important;
}

.stat[data-stat="retweets"].retweeted .stat-count {
  color: #2bc592 !important;
}

/* Fix for the watermark container and export controls */
.watermark-container {
  width: 100%;
  text-align: center;
  margin: 0.5rem 0;
}

.watermark {
  font-size: 0.8rem;
  color: var(--text-secondary);
  opacity: 0.7;
}

.tweet-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1.5rem 0;
  width: 100%;
  max-width: 500px;
}

.option-group {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
}

.option-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.option-button {
  padding: 0.5rem 1rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.option-button:hover {
  background-color: var(--bg-hover);
}

.export-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 500px;
  margin-top: 1rem;
}

.primary-button {
  padding: 0.75rem 1.5rem;
  background-color: #1d9bf0;
  color: white;
  border: none;
  border-radius: 9999px;
  font-weight: bold;
  cursor: pointer;
  font-size: 1rem;
  width: 100%;
  max-width: 300px;
}

.primary-button:hover {
  background-color: #1a8cd8;
}

.free-tier-note {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

#upgrade-link {
  color: #1d9bf0;
  text-decoration: none;
}

#upgrade-link:hover {
  text-decoration: underline;
}

/* Editable elements styling */
.editable {
  position: relative;
  cursor: text;
  transition: background-color 0.2s;
}

.editable:hover::after {
  content: "✏️";
  position: absolute;
  right: -20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  opacity: 0.5;
}

.profile-image.editable {
  cursor: pointer;
}

.profile-image.editable:hover::after {
  content: "📷";
  position: absolute;
  right: 0;
  bottom: 0;
  top: auto;
  transform: none;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

[contenteditable="true"]:focus {
  outline: 2px solid #1d9bf0;
  border-radius: 4px;
  padding: 0 2px;
}

.stat-count[contenteditable="true"]:focus {
  min-width: 30px;
}

/* Watermark for exported images */
.export-watermark {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 12px;
  color: rgba(83, 100, 113, 0.7);
  font-style: italic;
  pointer-events: none;
  display: none; /* Hidden by default, only shown during export */
  z-index: 10;
  text-shadow: 0 0 1px var(--bg);
}

.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 2px;
  color: #1d9bf0;
  font-size: 14px;
  background: var(--bg);
  border-radius: 50%;
  padding: 0 4px;
  margin-left: 2px;
}

.verified-badge svg {
  fill: #1d9bf0;
  width: 16px;
  height: 16px;
}

/* For dark mode compatibility */
body.theme-dim .verified-badge svg,
body.theme-dark .verified-badge svg {
  fill: #1d9bf0;
}

.tweet-image-grid {
  width: 100%;
  display: grid;
  gap: 2px;
  border-radius: 16px;
  overflow: hidden;
  max-height: 500px;
}

.grid-1 {
  grid-template-columns: 1fr;
}

.grid-2 {
  grid-template-columns: 1fr 1fr;
}

.grid-3 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(2, 1fr);
  height: 100%;
  max-height: 500px;
}

.grid-3 .grid-image-container:first-child {
  grid-row: 1 / span 2;
  height: 100%;
}

.grid-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.grid-image-container {
  position: relative;
  overflow: hidden !important; /* Force overflow hidden */
  cursor: move;
  min-height: 100px;
  max-height: 500px;
}

/* First image in a 1-image layout can maintain natural aspect ratio */
.grid-1 .grid-image-container {
  aspect-ratio: auto;
  max-height: 500px;
}

/* For 2-image layout, set consistent height */
.grid-2 .grid-image-container {
  aspect-ratio: 1/1;
}

/* For 3-image layout */
.grid-3 .grid-image-container:not(:first-child) {
  height: 100%;
}

.grid-3 .grid-image-container:first-child img {
  height: 100%;
  object-fit: cover;
}

/* For 4-image layout, make all squares */
.grid-4 .grid-image-container {
  aspect-ratio: 1/1;
}

.grid-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
  object-position: center; /* Center the image within container */
  max-width: 100%; /* Ensure image doesn't exceed container width */
  max-height: 100%; /* Ensure image doesn't exceed container height */
}

/* For single images, prefer contain if it fits well */
.grid-1 .grid-image {
  max-height: 500px;
}
/* Apply different border radius to corners based on position */
.grid-1 .grid-image-container {
  border-radius: 16px;
}

.grid-2 .grid-image-container:first-child {
  border-top-left-radius: 16px;
  border-bottom-left-radius: 16px;
}

.grid-2 .grid-image-container:last-child {
  border-top-right-radius: 16px;
  border-bottom-right-radius: 16px;
}

.grid-3 .grid-image-container:first-child {
  border-top-left-radius: 16px;
  border-bottom-left-radius: 16px;
}

.grid-3 .grid-image-container:nth-child(2) {
  border-top-right-radius: 16px;
}

.grid-3 .grid-image-container:last-child {
  border-bottom-right-radius: 16px;
}

.grid-4 .grid-image-container:first-child {
  border-top-left-radius: 16px;
}

.grid-4 .grid-image-container:nth-child(2) {
  border-top-right-radius: 16px;
}

.grid-4 .grid-image-container:nth-child(3) {
  border-bottom-left-radius: 16px;
}

.grid-4 .grid-image-container:last-child {
  border-bottom-right-radius: 16px;
}

.remove-single-image {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s;
}

.grid-image-container:hover .remove-single-image {
  opacity: 1;
}

.potential-drop-target {
  transition: transform 0.15s ease;
  opacity: 0.8;
}

.drag-over {
  border: 2px dashed #1da1f2;
  transform: scale(1.02);
  opacity: 1;
}

.dragging {
  opacity: 0.6;
  transform: scale(0.98);
}

/* Improve cursor feedback */
.grid-image-container {
  cursor: grab;
}

.grid-image-container.dragging {
  cursor: grabbing;
}

.grid-image-container.potential-drop-target {
  cursor: copy;
}

/* Position the main remove button at the top right of the entire grid */
.remove-image {
  position: absolute;
  top: -10px;
  right: -10px;
  z-index: 10;
}

/* Animation Export Styles */
.animation-controls {
  width: 100%;
  max-width: 500px;
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.animation-controls h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.2rem;
  color: var(--text);
}

.animation-option {
  margin-bottom: 1rem;
}

.animation-option label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.animation-option .slider-container {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.animation-option input[type="range"] {
  flex: 1;
}

.animation-option .value-display {
  min-width: 50px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.speed-presets {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.speed-preset {
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--border-color);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.speed-preset.active {
  background: #1d9bf0;
  color: white;
  border-color: #1d9bf0;
}

.format-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.format-toggle button {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  background: var(--bg);
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
}

.format-toggle button.active {
  background: #1d9bf0;
  color: white;
  border-color: #1d9bf0;
}

.animation-preview-container {
  width: 100%;
  height: 300px;
  background: var(--bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  margin: 1rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.animation-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.animation-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.animation-actions button {
  flex: 1;
  padding: 0.75rem;
  border-radius: 9999px;
  border: none;
  font-weight: bold;
  cursor: pointer;
}

.preview-animation-btn {
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--border-color);
}

.export-animation-btn {
  background: #1d9bf0;
  color: white;
}

.premium-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(45deg, #f6b73c, #e6855e);
  color: white;
  font-size: 0.7rem;
  font-weight: bold;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  margin-left: 0.5rem;
  text-transform: uppercase;
}

.premium-feature-note {
  background: rgba(246, 183, 60, 0.1);
  border: 1px solid rgba(246, 183, 60, 0.3);
  border-radius: 8px;
  padding: 0.75rem;
  margin: 1rem 0;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.premium-feature-note svg {
  color: #f6b73c;
  flex-shrink: 0;
}

/* Animation rendering canvas */
.animation-render-container {
  position: fixed;
  top: -9999px;
  left: -9999px;
  visibility: hidden;
  z-index: -1;
}
