/* ========== MODALS ========== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal.is-open {
  opacity: 1;
  visibility: visible;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
}

.modal__dialog {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: min(90vh, 640px);
  display: flex;
  flex-direction: column;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s ease;
  z-index: 1;
}

.modal.is-open .modal__dialog {
  transform: translateY(0) scale(1);
}

.modal__dialog--wide {
  max-width: 560px;
}

.modal__dialog--video {
  max-width: 720px;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal__close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
}

.modal__close:hover {
  background: var(--page-bg);
  color: var(--text-primary);
}

.modal__body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}

.modal__footer {
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ========== SLIDE PANEL ========== */
.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 100vw);
  background: var(--card-bg);
  box-shadow: var(--shadow-lg);
  z-index: 420;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.panel.is-open {
  transform: translateX(0);
}

.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 410;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.panel-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

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

.panel__title {
  font-size: 1.05rem;
  font-weight: 700;
}

.panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* ========== PROFILE DROPDOWN ========== */
.profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: 120;
  display: none;
  overflow: hidden;
}

.profile-menu.is-open {
  display: block;
}

.profile-menu button,
.profile-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-align: left;
  transition: background var(--transition);
}

.profile-menu button:hover,
.profile-menu a:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.profile-menu svg, .profile-menu .icon {
  width: 16px;
  height: 16px;
}

.navbar__avatar-wrap {
  position: relative;
}

/* ========== POST MORE MENU ========== */
.post__menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  z-index: 30;
  display: none;
  overflow: hidden;
}

.post__menu.is-open {
  display: block;
}

.post__menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.post__menu button:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.post__menu button.is-danger:hover {
  background: #fef2f2;
  color: var(--danger);
}

.post__header {
  position: relative;
}

.post__more-wrap {
  position: relative;
}

/* ========== FORM ELEMENTS ========== */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--page-bg);
  font-size: 0.9rem;
  color: var(--text-primary);
  transition: border-color var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ========== LIST ITEMS IN PANELS ========== */
.panel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border-light);
}

.panel-item:hover {
  background: var(--page-bg);
}

.panel-item:last-child {
  border-bottom: none;
}

.panel-item__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.panel-item__info {
  flex: 1;
  min-width: 0;
}

.panel-item__title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.panel-item__sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-item__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.panel-item--unread .panel-item__title {
  color: var(--primary);
}

.panel-item__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

/* Chat thread */
.chat-thread {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 300px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-bubble {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.4;
}

.chat-bubble--them {
  align-self: flex-start;
  background: var(--page-bg);
  color: var(--text-primary);
}

.chat-bubble--me {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.chat-input-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--page-bg);
  font-size: 0.875rem;
}

/* Comments styles live in components.css (.post__comments) */

/* Poll in posts */
.poll-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
  background: var(--page-bg);
}

.poll-card__question {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.poll-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  font-size: 0.875rem;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition);
}

.poll-option:hover:not(:disabled) {
  border-color: var(--primary);
}

.poll-option:disabled {
  cursor: default;
}

.poll-option__bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--primary-light);
  z-index: 0;
  transition: width 0.3s ease;
}

.poll-option__content {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
}

.poll-option--voted {
  border-color: var(--primary);
  font-weight: 600;
}

/* Image post media */
.post__image {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state svg, .empty-state .icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.9rem;
}

/* Join button joined state */
.join-btn.is-joined {
  background: var(--page-bg);
  color: var(--online);
  border: 1px solid var(--online);
}

.post__action--saved {
  color: var(--primary);
}

.post__action--saved svg, .post__action--saved .icon {
  fill: var(--primary);
}

/* Premium plans */
.plan-grid {
  display: grid;
  gap: 12px;
}

.plan-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.plan-card:hover,
.plan-card.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.plan-card__name {
  font-weight: 700;
  font-size: 1rem;
}

.plan-card__price {
  color: var(--primary);
  font-weight: 700;
  font-size: 1.25rem;
  margin: 4px 0;
}

.plan-card__desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Call modal */
.call-ui {
  text-align: center;
  padding: 24px 12px;
}

.call-ui__avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 16px;
  border: 3px solid var(--primary-light);
  animation: pulse-ring 1.5s ease infinite;
}

@keyframes pulse-ring {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.4);
  }
  50% {
    box-shadow: 0 0 0 16px rgba(124, 58, 237, 0);
  }
}

.call-ui__status {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.call-ui__name {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 24px;
}

.call-ui__actions {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.btn--danger {
  background: var(--danger);
  color: #fff;
}

.btn--danger:hover {
  background: #dc2626;
}

/* Video player modal */
.video-player {
  position: relative;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

.video-player img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.7;
}

.video-player__controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
}

.video-player__play {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-player__bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
}

.video-player__progress {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.3s linear;
}

.video-player__progress.is-playing {
  animation: progress-fill 48s linear forwards;
}

@keyframes progress-fill {
  from {
    width: 0%;
  }
  to {
    width: 100%;
  }
}

/* Highlight pulse for live rooms */
.sidebar-right.is-highlight .widget:first-child {
  animation: highlight-pulse 1.2s ease 2;
}

@keyframes highlight-pulse {
  0%,
  100% {
    box-shadow: var(--shadow-sm);
  }
  50% {
    box-shadow: 0 0 0 3px var(--primary-light), var(--shadow-md);
  }
}

.live-room.is-filtered {
  outline: 2px solid var(--primary);
  border-radius: var(--radius-sm);
}

/* Search results hint */
.search-hint {
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn--ghost:hover {
  background: var(--page-bg);
  color: var(--text-primary);
}

.wallet-balance {
  text-align: center;
  padding: 20px;
  background: linear-gradient(145deg, #4c1d95, #7c3aed);
  border-radius: var(--radius-md);
  color: #fff;
  margin-bottom: 16px;
}

.wallet-balance__amount {
  font-size: 2rem;
  font-weight: 800;
}

.wallet-balance__label {
  font-size: 0.8rem;
  opacity: 0.85;
}

.tx-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.875rem;
}

.tx-item__amount--pos {
  color: var(--online);
  font-weight: 600;
}

.tx-item__amount--neg {
  color: var(--danger);
  font-weight: 600;
}

@media (max-width: 480px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .modal__dialog {
    max-height: 95vh;
  }
}
