/* style.css - استایل اصلی VoiceRoom - تم تیره، گلس‌مورفیسم، گرادینت آبی-بنفش */

:root {
  --bg-dark: #0d0e1a;
  --bg-dark-2: #14152a;
  --purple: #6c5ce7;
  --purple-dark: #4834d4;
  --blue: #00b4d8;
  --cyan: #00cec9;
  --danger: #ff5e6c;
  --success: #2ecc71;
  --text-main: #f2f2f7;
  --text-dim: #a0a3bd;
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.12);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Vazirmatn', 'Tahoma', sans-serif;
  background: radial-gradient(circle at 20% 0%, #241e4e 0%, var(--bg-dark) 45%, #0a0b14 100%);
  color: var(--text-main);
  direction: rtl;
  min-height: 100vh;
  position: relative;
}

button, input {
  font-family: inherit;
  direction: rtl;
}

button {
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
  color: inherit;
}

img {
  display: block;
}

/* ==================== ساختار صفحه‌ها ==================== */
.screen {
  display: none;
  min-height: 100vh;
  width: 100%;
  animation: fadeIn 0.35s ease;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== گلس‌مورفیسم ==================== */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

/* ==================== صفحه اسپلش ==================== */
#screen-splash {
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #1a1440 0%, var(--bg-dark) 60%);
}

.splash-wrap {
  text-align: center;
}

.logo-glow {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-img {
  width: 130px;
  height: 130px;
  filter: drop-shadow(0 0 30px rgba(108, 92, 231, 0.6));
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.sound-wave {
  position: absolute;
  bottom: -18px;
  display: flex;
  gap: 4px;
  align-items: flex-end;
}

.sound-wave span {
  width: 4px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--cyan), var(--purple));
  animation: wave 1.1s ease-in-out infinite;
}

.sound-wave span:nth-child(1) { animation-delay: 0s; }
.sound-wave span:nth-child(2) { animation-delay: 0.12s; }
.sound-wave span:nth-child(3) { animation-delay: 0.24s; }
.sound-wave span:nth-child(4) { animation-delay: 0.36s; }
.sound-wave span:nth-child(5) { animation-delay: 0.48s; }

@keyframes wave {
  0%, 100% { height: 8px; }
  50% { height: 26px; }
}

.brand-title {
  font-size: 30px;
  font-weight: 800;
  background: linear-gradient(90deg, #a29bfe, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 6px;
}

.brand-sub {
  color: var(--text-dim);
  font-size: 14px;
}

/* ==================== فرم‌های احراز هویت ==================== */
#screen-login, #screen-register {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  border-radius: var(--radius-lg);
  padding: 30px 24px;
  text-align: center;
}

.auth-logo {
  width: 60px;
  margin: 0 auto 16px;
}

.auth-card h2 {
  font-size: 20px;
  margin-bottom: 20px;
  font-weight: 700;
}

.auth-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin-bottom: 6px;
}

.input-group {
  text-align: right;
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.input-group input {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  font-size: 14px;
  transition: border 0.2s;
}

.input-group input:focus {
  border-color: var(--purple);
}

.input-group input::placeholder {
  color: #6c6e8a;
}

.btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  transition: transform 0.15s, opacity 0.2s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(90deg, var(--purple), var(--purple-dark));
  color: #fff;
  box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
  margin-top: 6px;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--glass-border);
  margin-top: 10px;
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255, 94, 108, 0.5);
  margin-top: 12px;
}

.auth-switch {
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-dim);
}

.auth-switch a {
  color: var(--cyan);
  text-decoration: none;
  font-weight: 700;
}

/* آواتار در ثبت‌نام و پروفایل */
.avatar-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 18px;
}

.avatar-preview, .avatar-lg {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--purple);
  margin-bottom: 10px;
}

.avatar-lg {
  width: 100px;
  height: 100px;
}

.avatar-upload-btn {
  font-size: 13px;
  color: var(--cyan);
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(0, 206, 201, 0.1);
}

.avatar-sm {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--purple);
}

/* ==================== نوار بالا / صفحه اصلی ==================== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
}

.top-bar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-username {
  font-weight: 700;
  font-size: 15px;
}

.home-status {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
}

.dot-online {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  box-shadow: 0 0 6px var(--success);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-main {
  flex: 1;
  padding: 6px 20px 100px;
  overflow-y: auto;
}

.section-title {
  font-size: 20px;
  font-weight: 800;
  margin: 10px 0 16px;
}

.section-title-sm {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dim);
  margin: 26px 0 12px;
}

.home-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.action-card {
  border-radius: var(--radius-lg);
  padding: 22px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
}

.gradient-card {
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  box-shadow: 0 10px 25px rgba(108, 92, 231, 0.35);
}

.gradient-card-alt {
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  box-shadow: 0 10px 25px rgba(0, 180, 216, 0.35);
}

.action-card.glass {
  border-radius: var(--radius-lg);
}

.action-icon {
  font-size: 26px;
}

.rooms-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-hint {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

.room-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
}

.room-list-item .room-name {
  font-weight: 700;
  font-size: 14px;
}

.room-list-item .room-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
}

.room-list-item .join-mini-btn {
  background: linear-gradient(90deg, var(--purple), var(--purple-dark));
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

/* ==================== نوار پایین ==================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  display: flex;
  justify-content: space-around;
  padding: 12px 0 18px;
  background: rgba(13, 14, 26, 0.85);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--glass-border);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
}

.nav-item.active {
  color: var(--cyan);
}

/* ==================== سربرگ صفحات فرعی ==================== */
.sub-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
}

.sub-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.back-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  font-size: 18px;
  transform: scaleX(-1); /* فلش برای راست‌چین */
}

.form-card, .profile-card, .settings-list {
  margin: 10px 20px;
  padding: 22px;
  border-radius: var(--radius-lg);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0;
  font-size: 14px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 26px;
  transition: 0.25s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  right: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.25s;
}

.switch input:checked + .slider {
  background: linear-gradient(90deg, var(--purple), var(--purple-dark));
}

.switch input:checked + .slider::before {
  transform: translateX(-20px);
}

/* ==================== پروفایل ==================== */
.profile-card {
  text-align: center;
}

.profile-card h3 {
  font-size: 18px;
  margin-top: 4px;
}

.profile-id {
  color: var(--text-dim);
  font-size: 12px;
  margin: 6px 0;
  direction: ltr;
  display: inline-block;
}

.profile-status {
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
}

/* ==================== تنظیمات ==================== */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px;
  font-size: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

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

.settings-value {
  color: var(--text-dim);
  font-size: 13px;
}

.settings-logout {
  margin: 20px 20px 0;
  width: calc(100% - 40px);
}

/* ==================== روم صوتی ==================== */
#screen-voice-room {
  background: linear-gradient(180deg, #171334 0%, var(--bg-dark) 100%);
}

.room-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--glass-border);
}

.room-header-info {
  flex: 1;
  text-align: center;
}

.room-header-info h3 {
  font-size: 16px;
  font-weight: 700;
}

.room-header-info span {
  font-size: 12px;
  color: var(--text-dim);
  direction: ltr;
  display: inline-block;
}

.room-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.members-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 18px;
  overflow-y: auto;
  max-height: 34vh;
}

.member-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.member-avatar-wrap {
  position: relative;
  width: 58px;
  height: 58px;
}

.member-avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--glass-border);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.member-tile.speaking .member-avatar {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(0, 206, 201, 0.25), 0 0 18px rgba(0, 206, 201, 0.5);
  animation: speakPulse 1s ease-in-out infinite;
}

@keyframes speakPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.member-muted-badge {
  position: absolute;
  bottom: -2px;
  left: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  border: 2px solid var(--bg-dark);
}

.member-tile.muted .member-muted-badge {
  display: flex;
}

.member-name {
  font-size: 11px;
  color: var(--text-dim);
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.member-tile.is-owner .member-name {
  color: var(--cyan);
}

.crown {
  font-size: 10px;
}

/* بخش چت داخل روم */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--glass-border);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
}

.chat-msg .msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-msg-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-msg-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 11px;
  color: var(--text-dim);
}

.chat-msg-meta .msg-username {
  font-weight: 700;
  color: var(--cyan);
}

.chat-msg-bubble {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13.5px;
  line-height: 1.7;
  word-break: break-word;
  position: relative;
}

.chat-msg.own {
  flex-direction: row-reverse;
  margin-right: auto;
}

.chat-msg.own .chat-msg-bubble {
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.35), rgba(72, 52, 212, 0.35));
}

.chat-msg-reply {
  font-size: 11px;
  color: var(--text-dim);
  border-right: 2px solid var(--purple);
  padding-right: 6px;
  margin-bottom: 4px;
  opacity: 0.8;
}

.chat-msg-actions {
  display: flex;
  gap: 8px;
  font-size: 11px;
  margin-top: 2px;
  color: var(--text-dim);
}

.chat-msg-actions span {
  cursor: pointer;
}

.chat-msg-actions span:hover {
  color: var(--cyan);
}

.reply-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(108, 92, 231, 0.12);
  font-size: 12px;
  border-top: 1px solid var(--glass-border);
}

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--glass-border);
}

.chat-input-bar input {
  flex: 1;
  padding: 11px 14px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  font-size: 13.5px;
}

.icon-btn-sm {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.send-btn {
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  transform: scaleX(-1);
}

.emoji-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--glass-border);
  max-height: 120px;
  overflow-y: auto;
}

.emoji-panel span {
  font-size: 20px;
  padding: 4px;
  cursor: pointer;
}

/* کنترل‌های پایین روم صوتی */
.room-controls {
  display: flex;
  justify-content: center;
  gap: 22px;
  padding: 16px 0 26px;
  border-top: 1px solid var(--glass-border);
  background: rgba(13, 14, 26, 0.85);
  backdrop-filter: blur(20px);
}

.control-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
}

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

.control-btn.active-off {
  background: linear-gradient(135deg, var(--danger), #c0392b);
}

.control-btn.danger {
  background: linear-gradient(135deg, var(--danger), #c0392b);
}

/* ==================== نوتیفیکیشن Toast ==================== */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20, 21, 42, 0.95);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 999;
  max-width: 85%;
  text-align: center;
}

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

/* ==================== ریسپانسیو ==================== */
@media (min-width: 480px) {
  .auth-card, .form-card, .profile-card {
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
  }
}

::-webkit-scrollbar {
  width: 5px;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}
