/* ==========================================================================
   APEX - UI COMPONENTS & INTERACTION STYLES
   Tweet Cards, Compose Box, DMs, Modals, Character Creator, & Widgets
   ========================================================================== */

/* ==========================================================================
   1. COMPOSE TWEET BOX
   ========================================================================== */
.compose-card {
  display: flex;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
  background-color: var(--bg-primary);
  width: 100%;
  box-sizing: border-box;
}

.compose-avatar {
  width: 42px !important;
  height: 42px !important;
  min-width: 42px !important;
  max-width: 42px !important;
  min-height: 42px !important;
  max-height: 42px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  aspect-ratio: 1 / 1 !important;
  flex-shrink: 0 !important;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  display: block;
}

.compose-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.compose-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 17px;
  line-height: 1.4;
  resize: none;
  min-height: 64px;
}

.compose-textarea::placeholder {
  color: var(--text-secondary);
}

.compose-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
  width: 100%;
}

.compose-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.compose-tool-btn {
  background: transparent;
  border: none;
  color: var(--color-accent);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.compose-tool-btn:hover {
  background-color: var(--color-accent-light);
}

.compose-tool-btn svg {
  width: 19px;
  height: 19px;
}

.btn-post-tweet {
  background-color: var(--color-accent);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 8px 18px;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn-post-tweet:hover {
  background-color: var(--color-accent-hover);
}

.btn-post-tweet:active {
  transform: scale(0.96);
}

/* Character Quick Mention Pill Bar */
.mention-pills-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 6px 0;
  max-width: 100%;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.mention-pills-bar::-webkit-scrollbar {
  display: none;
}

.mention-pill {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 9999px;
  white-space: nowrap;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.mention-pill:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background-color: var(--color-accent-light);
}

/* ==========================================================================
   2. TWEET / POST CARDS & THREADS (Twitter/X Style)
   ========================================================================== */
.tweet-thread-group {
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.tweet-item {
  display: flex;
  padding: 14px 16px;
  gap: 12px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  position: relative;
}

.tweet-item:hover {
  background-color: var(--bg-hover);
}

/* Thread connector line between parent tweet and replies */
.tweet-item.has-reply-below::after {
  content: '';
  position: absolute;
  left: 36px;
  top: 62px;
  bottom: 0;
  width: 2px;
  background-color: #333639;
  z-index: 1;
}

.tweet-item.is-thread-reply {
  padding-top: 6px;
  position: relative;
}

.tweet-item.is-thread-reply::before {
  content: '';
  position: absolute;
  left: 36px;
  top: 0;
  height: 24px;
  width: 2px;
  background-color: #333639;
  z-index: 1;
}

.replying-to-tag {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.replying-to-tag span {
  color: var(--color-accent);
  font-weight: 600;
}

.tweet-avatar-wrapper {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.tweet-avatar {
  width: 42px !important;
  height: 42px !important;
  min-width: 42px !important;
  max-width: 42px !important;
  min-height: 42px !important;
  max-height: 42px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  aspect-ratio: 1 / 1 !important;
  flex-shrink: 0 !important;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  display: block;
}

.tweet-content-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.tweet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.tweet-author-info {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  min-width: 0;
}

.tweet-author-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.verified-icon {
  width: 17px;
  height: 17px;
  fill: var(--color-accent);
  flex-shrink: 0;
}

.verified-icon-gold {
  fill: #ffd700;
}

.tweet-author-handle {
  color: var(--text-secondary);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tweet-time-dot {
  color: var(--text-secondary);
  font-size: 12px;
}

.tweet-time {
  color: var(--text-secondary);
  font-size: 14px;
}

.tweet-body {
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-primary);
  word-break: break-word;
  white-space: pre-wrap;
}

.tweet-body .mention-highlight {
  color: var(--color-accent);
  font-weight: 600;
}

.tweet-body .hashtag-highlight {
  color: var(--color-accent);
  font-weight: 500;
}

/* Quote Tweet Box */
.quote-tweet-box {
  margin-top: 8px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background-color: rgba(255, 255, 255, 0.02);
  transition: border-color 0.2s ease;
}

.quote-tweet-box:hover {
  border-color: var(--text-secondary);
}

.quote-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.quote-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

.quote-author {
  font-weight: 700;
  font-size: 14px;
}

.quote-handle {
  font-size: 13px;
  color: var(--text-secondary);
}

.quote-text {
  font-size: 14px;
  color: var(--text-primary);
}

/* Tweet Action Buttons (Reply, Retweet, Like, Share) */
.tweet-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 440px;
  margin-top: 6px;
  padding-right: 12px;
}

.tweet-action-btn {
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  padding: 6px;
  border-radius: 9999px;
  transition: all 0.2s ease;
}

.tweet-action-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
}

/* Hover States for Tweet Actions */
.tweet-action-btn.action-reply:hover {
  color: var(--color-reply);
  background-color: var(--color-reply-bg);
}

.tweet-action-btn.action-retweet:hover, .tweet-action-btn.action-retweet.active {
  color: var(--color-retweet);
  background-color: var(--color-retweet-bg);
}

.tweet-action-btn.action-retweet.active svg {
  stroke: var(--color-retweet);
}

.tweet-action-btn.action-like:hover, .tweet-action-btn.action-like.active {
  color: var(--color-like);
  background-color: var(--color-like-bg);
}

.tweet-action-btn.action-like.active svg {
  fill: var(--color-like);
  stroke: var(--color-like);
}

.tweet-action-btn.action-view:hover {
  color: var(--color-accent);
  background-color: var(--color-accent-light);
}

/* Thread Replies Section */
.thread-container {
  border-left: 2px solid var(--border-color);
  margin-left: 22px;
  padding-left: 12px;
}

/* ==========================================================================
   3. DIRECT MESSAGES / LOCKER ROOM CHAT (Authentic Twitter 2-Pane Messenger)
   ========================================================================== */
.dm-view-container {
  display: flex;
  height: 100vh;
  width: 990px;
  max-width: 990px;
  overflow: hidden;
  background-color: var(--bg-primary);
}

.dm-sidebar {
  width: 390px;
  min-width: 390px;
  max-width: 390px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  background-color: var(--bg-primary);
}

.dm-sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background-color: var(--bg-primary);
  z-index: 10;
}

.dm-convo-list-scroll {
  flex: 1;
  overflow-y: auto;
}

.dm-convo-item {
  display: flex;
  padding: 14px 16px;
  gap: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color 0.2s ease;
  align-items: center;
}

.dm-convo-item:hover {
  background-color: var(--bg-hover);
}

.dm-convo-item.active {
  background-color: var(--bg-secondary);
  border-right: 3px solid var(--color-accent);
}

.dm-chat-window {
  width: 600px;
  min-width: 600px;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--bg-primary);
  position: relative;
  flex-shrink: 0;
}

.dm-chat-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.dm-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dm-message-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.45;
  position: relative;
  word-break: break-word;
}

.dm-bubble-received {
  align-self: flex-start;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.dm-bubble-sent {
  align-self: flex-end;
  background-color: var(--color-accent);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.dm-time-tag {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: block;
}

.dm-bubble-sent .dm-time-tag {
  color: rgba(255, 255, 255, 0.75);
  text-align: right;
}

/* Quick Response Pills in DM */
.dm-quick-prompts {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  overflow-x: auto;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-secondary);
  scrollbar-width: none;
  flex-shrink: 0;
}

.dm-quick-prompts::-webkit-scrollbar {
  display: none;
}

.dm-prompt-btn {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 9999px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.dm-prompt-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background-color: var(--color-accent-light);
}

.dm-input-box {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  gap: 10px;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  flex-shrink: 0;
}

.dm-input {
  flex: 1;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  padding: 10px 16px;
  color: var(--text-primary);
  outline: none;
  font-size: 15px;
  font-family: var(--font-family);
}

.dm-input:focus {
  border-color: var(--color-accent);
}

.dm-send-btn {
  background: var(--color-accent);
  color: #fff;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.dm-send-btn:hover {
  background-color: var(--color-accent-hover);
}

.dm-send-btn:active {
  transform: scale(0.92);
}

/* Typing Indicator Animation */
.dm-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background-color: var(--bg-secondary);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  margin-bottom: 4px;
}

.dm-typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--text-secondary);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.dm-typing-dot:nth-child(1) { animation-delay: 0s; }
.dm-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.dm-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Simulated Voice Note Card */
.simulated-voice-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 8px 12px;
  margin-top: 6px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.simulated-voice-card:hover {
  background: rgba(255, 122, 0, 0.1);
  border-color: var(--color-accent);
}

.voice-play-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.voice-waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 18px;
  flex: 1;
}

.voice-bar {
  width: 3px;
  background: var(--color-accent);
  border-radius: 2px;
  opacity: 0.8;
}

/* Simulated Tap-to-Reveal Photo */
.simulated-photo-wrapper {
  margin-top: 8px;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  max-width: 280px;
  cursor: pointer;
  border: 1px solid var(--border-color);
}

.simulated-photo-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  transition: filter 0.3s ease, transform 0.3s ease;
}

.simulated-photo-img.blurred {
  filter: blur(14px) brightness(0.6);
}

.simulated-photo-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  padding: 12px;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.simulated-photo-wrapper.revealed .simulated-photo-overlay {
  opacity: 0;
}

.simulated-photo-wrapper.revealed .simulated-photo-img.blurred {
  filter: none;
}

/* Relationship & Engine Badges */
.dm-rel-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 9999px;
  background: rgba(255, 122, 0, 0.12);
  color: var(--color-accent);
  border: 1px solid rgba(255, 122, 0, 0.25);
}

.dm-engine-tag {
  font-size: 10px;
  color: var(--text-secondary);
  opacity: 0.7;
  margin-top: 4px;
  font-style: italic;
  display: block;
}

/* Quote Tweet Dropdown Popover */
.repost-dropdown-menu {
  position: absolute;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  flex-direction: column;
  width: 160px;
  overflow: hidden;
  animation: modal-pop 0.15s ease-out;
}

.repost-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.repost-dropdown-item:hover {
  background-color: var(--bg-hover);
}

/* Typing Indicator Animation */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background-color: var(--bg-secondary);
  border-radius: 16px;
  width: fit-content;
  align-self: flex-start;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--text-secondary);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* ==========================================================================
   4. ROSTER & CHARACTER CREATOR
   ========================================================================== */
.roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 16px;
}

.character-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.2s ease, border-color 0.2s ease;
  position: relative;
}

.character-card:hover {
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

.character-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.character-card-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-color);
}

.character-badge-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 9999px;
  text-transform: uppercase;
  width: fit-content;
}

.affinity-meter-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.affinity-meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

.affinity-bar-bg {
  width: 100%;
  height: 6px;
  background-color: var(--bg-tertiary);
  border-radius: 9999px;
  overflow: hidden;
}

.affinity-bar-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.3s ease;
}

/* ==========================================================================
   5. TRENDING / BREAKING NEWS WIDGET
   ========================================================================== */
.trend-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 0;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.trend-item:hover {
  opacity: 0.8;
}

.trend-category {
  font-size: 12px;
  color: var(--text-secondary);
}

.trend-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.trend-count {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ==========================================================================
   6. MODAL DIALOGS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-modal-overlay);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-container {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
  animation: modal-pop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-pop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close-btn:hover {
  background-color: var(--bg-hover);
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font-family);
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-accent);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-height-mobile) + var(--sab) + 24px);
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--color-accent);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 9999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-container.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-10px);
}
