:root {
  /* رنگ‌های دارک مود */
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-card: #212121;
  --bg-overlay: rgba(0, 0, 0, 0.95);
  --text-primary: #ffffff;
  --text-secondary: #aaaaaa;
  --text-muted: #717171;
  --accent: #ff3b30;
  --accent-hover: #ff6b6b;
  --accent-light: rgba(255, 59, 48, 0.1);
  --border: rgba(255, 255, 255, 0.1);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  --glass: rgba(255, 255, 255, 0.05);
  --glass-hover: rgba(255, 255, 255, 0.08);
  --safe-area-top: env(safe-area-inset-top);
  --safe-area-bottom: env(safe-area-inset-bottom);
  
  /* انیمیشن‌ها */
  --transition-fast: 0.15s ease;
  --transition-medium: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* حالت لایت مود */
[data-theme="light"] {
  --bg-primary: #f8f9fa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-overlay: rgba(255, 255, 255, 0.98);
  --text-primary: #000000;
  --text-secondary: #606770;
  --text-muted: #8a8d91;
  --accent: #ff3b30;
  --accent-hover: #ff6b6b;
  --accent-light: rgba(255, 59, 48, 0.1);
  --border: rgba(0, 0, 0, 0.1);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  --glass: rgba(0, 0, 0, 0.03);
  --glass-hover: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .player-header {
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.9), transparent) !important;
  color: #000000 !important;
}

[data-theme="light"] .player-header .player-username,
[data-theme="light"] .player-header .player-date {
  color: #000000 !important;
}

[data-theme="light"] .player-header .player-btn {
  color: #000000 !important;
  background: rgba(0, 0, 0, 0.1) !important;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color var(--transition-medium), color var(--transition-medium);
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

body {
  padding: 0;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-area-top);
  padding-bottom: var(--safe-area-bottom);
}

/* هدر */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all var(--transition-medium);
  padding-top: calc(12px + var(--safe-area-top));
  backdrop-filter: blur(10px);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-img {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-weight: 700;
  font-size: 18px;
  background: linear-gradient(135deg, #ff3b30, #ff6b6b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle, .refresh-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.theme-toggle::before, .refresh-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--glass);
  border-radius: 50%;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.theme-toggle:hover::before, .refresh-btn:hover::before {
  opacity: 1;
}

.refresh-btn.rotating {
  animation: rotate 1s linear infinite;
}

/* گرید کارت‌ها */
.container {
  flex: 1;
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  flex: 1;
}

@media (max-width: 768px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
  }
}

.card {
  background-color: var(--bg-card);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: transform var(--transition-medium), box-shadow var(--transition-medium);
  box-shadow: var(--shadow);
  aspect-ratio: 9/16;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}

.card-thumb {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.card-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background-color: #000;
  transition: transform var(--transition-medium);
}

.card:hover .card-thumb video {
  transform: scale(1.05);
}

.card-overlay {
  position: absolute;
  bottom: 0;
  right: 0;
  left: 0;
  padding: 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-user {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.card-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.2);
  -webkit-user-drag: none;
  -webkit-user-select: none;
  pointer-events: none;
}

.card-user-info {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.card-username {
  font-weight: 600;
  font-size: 14px;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-verified {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}

.card-duration {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0, 0, 0, 0.7);
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: white;
}

/* مودال پخش ویدیو */
.player-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-color: var(--bg-overlay);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity var(--transition-medium);
  overflow: hidden;
}

.player-overlay.active {
  display: flex;
  opacity: 1;
}

.player-container {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  transform: scale(0.95);
  transition: transform var(--transition-medium);
}

.player-overlay.active .player-container {
  transform: scale(1);
}

@media (min-width: 768px) {
  .player-container {
    width: 90%;
    height: 90%;
    max-width: 800px;
    max-height: 90vh;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  }
}

.player-header {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent);
  padding-top: calc(16px + var(--safe-area-top));
  color: white;
  flex-direction: row-reverse;
}

.player-user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-direction: row-reverse;
}

.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.2);
  -webkit-user-drag: none;
  -webkit-user-select: none;
  pointer-events: none;
}

.player-user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.player-username-container {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-direction: row-reverse;
}

.player-username {
  font-weight: 600;
  font-size: 16px;
  color: white;
}

.verified-badge {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  -webkit-user-drag: none;
}

.player-date {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  direction: rtl;
  unicode-bidi: plaintext;
}

.player-actions {
  display: flex;
  gap: 8px;
}

.player-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--transition-fast);
  font-size: 18px;
}

.player-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

.player-video-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.player-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #000;
}

.player-controls {
  position: absolute;
  bottom: 0;
  right: 0;
  left: 0;
  padding: 16px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
  z-index: 10;
  padding-bottom: calc(16px + var(--safe-area-bottom));
}

.progress-container {
  width: 100%;
  height: 4px;
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  margin-bottom: 16px;
  cursor: pointer;
  position: relative;
  direction: ltr;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(to right, var(--accent), var(--accent-hover));
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
}

.player-main-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-direction: row-reverse;
}

.player-left-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-direction: row-reverse;
}

.player-right-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-direction: row-reverse;
}

.control-btn {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast);
  padding: 8px;
  border-radius: 50%;
}

.control-btn:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.1);
}

.like-btn {
  color: white;
}

.like-btn.liked {
  color: var(--accent);
}

.player-time {
  font-size: 14px;
  color: white;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: plaintext;
}

/* کپشن ویدیو */
.player-caption {
  position: absolute;
  bottom: 80px;
  right: 0;
  left: 0;
  padding: 16px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  z-index: 9;
}

.caption-text {
  font-size: 14px;
  color: white;
  line-height: 1.5;
  text-align: right;
  direction: rtl;
  unicode-bidi: plaintext;
}

/* منوی بیشتر */
.player-menu {
  position: absolute;
  top: 70px;
  left: 16px;
  background-color: var(--bg-secondary);
  border-radius: 12px;
  padding: 8px 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 20;
  display: none;
  min-width: 160px;
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.player-menu.active {
  display: block;
  animation: fadeInUp 0.2s ease;
}

.menu-item {
  padding: 12px 16px;
  background: none;
  border: none;
  width: 100%;
  text-align: right;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background-color var(--transition-fast);
  flex-direction: row-reverse;
}

.menu-item:hover {
  background-color: var(--glass);
}

.menu-item i {
  font-size: 16px;
  width: 20px;
}

/* انیمیشن‌های جدید برای انتقال بین ویدیوها */
.video-transition {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.video-transition.active {
  opacity: 1;
  pointer-events: all;
}

.transition-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-left: 4px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* انیمیشن‌های سوایپ */
.swipe-indicator {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--glass);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  z-index: 15;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.swipe-indicator.left {
  left: 20px;
}

.swipe-indicator.right {
  right: 20px;
}

.swipe-indicator.active {
  opacity: 1;
  transform: translateY(-50%) scale(1.1);
}

/* انیمیشن‌ها */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutLeft {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(-100%);
    opacity: 0;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes rotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

.slide-in {
  animation: slideIn 0.4s ease;
}

.slide-in-left {
  animation: slideInLeft 0.4s ease;
}

.slide-in-right {
  animation: slideInRight 0.4s ease;
}

.slide-out-left {
  animation: slideOutLeft 0.4s ease;
}

.slide-out-right {
  animation: slideOutRight 0.4s ease;
}

/* اسکرول بار سفارشی */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* دسترسی و فوکوس */
button:focus-visible,
.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* نمایش وضعیت لودینگ */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 16px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--glass);
  border-left: 4px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* استایل‌های موبایل */
@media (max-width: 768px) {
  .player-header {
    padding: 12px;
    padding-top: calc(12px + var(--safe-area-top));
  }
  
  .player-controls {
    padding: 12px;
    padding-bottom: calc(12px + var(--safe-area-bottom));
  }
  
  .player-left-controls {
    gap: 12px;
  }
  
  .control-btn {
    font-size: 20px;
  }
  
  .player-time {
    font-size: 12px;
  }
  
  .swipe-indicator {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }
  
  .swipe-indicator.left {
    left: 10px;
  }
  
  .swipe-indicator.right {
    right: 10px;
  }
  
  .player-caption {
    bottom: 70px;
    padding: 12px;
  }
  
  .caption-text {
    font-size: 13px;
  }
}

/* استایل‌های لمسی */
@media (hover: none) and (pointer: coarse) {
  .card:hover {
    transform: none;
  }
  
  .player-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
  }
  
  .menu-item:hover {
    background-color: transparent;
  }
}

/* استایل‌های نوتیفیکیشن */
.notification {
  position: fixed;
  top: 100px;
  right: 20px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 300px;
  animation: slideInRight 0.3s ease;
  backdrop-filter: blur(10px);
}

.notification.success {
  border-right: 4px solid #4CAF50;
}

.notification.error {
  border-right: 4px solid var(--accent);
}

.notification.info {
  border-right: 4px solid #2196F3;
}

.notification-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  margin-right: auto;
}

/* بهبودهای UX */
.card-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.card-loading .spinner {
  width: 30px;
  height: 30px;
}

/* انیمیشن‌های پیشرفته */
@keyframes heartBeat {
  0% { transform: scale(1); }
  14% { transform: scale(1.3); }
  28% { transform: scale(1); }
  42% { transform: scale(1.3); }
  70% { transform: scale(1); }
}

.heart-beat {
  animation: heartBeat 1.3s ease-in-out;
}

/* استایل‌های جدید برای UI بهبود یافته */
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 59, 48, 0.1), transparent);
  opacity: 0;
  transition: opacity var(--transition-medium);
  z-index: 1;
  pointer-events: none;
}

.card:hover::before {
  opacity: 1;
}

.card-content {
  position: relative;
  z-index: 2;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 16px;
  text-align: center;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.empty-state i {
  font-size: 48px;
  opacity: 0.5;
}

/* استایل‌های جدید برای دکمه‌ها */
.btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

/* جلوگیری از دانلود تصاویر */
img {
  -webkit-user-drag: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  pointer-events: none;
}

.player-avatar, .card-avatar {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* جلوگیری از راست کلیک */
.player-overlay {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* استایل‌های جدید برای کارت‌های ویدیو */
.card-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  z-index: 3;
}

/* بهبود نمایش در مرورگرهای مختلف */
.card-thumb {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* استایل برای جلوگیری از انتخاب متن */
.no-select {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}