/* PRX11 – نسخه پیشرفته کامل با تمام قابلیت‌ها */

/* متغیرهای CSS برای تم‌های مختلف */
:root {
  --color-primary: #0f172a;
  --color-secondary: #1e293b;
  --color-accent: #38bdf8;
  --color-text: #e2e8f0;
  --color-border: rgba(148, 163, 184, 0.3);
  --color-backdrop: rgba(0, 0, 0, 0.7);
  --shadow-medium: 0 10px 25px rgba(15, 23, 42, 0.4);
  --shadow-large: 0 20px 40px rgba(15, 23, 42, 0.3);
  --border-radius: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark {
  --color-primary: #0f172a;
  --color-secondary: #1e293b;
  --color-accent: #38bdf8;
  --color-text: #e2e8f0;
}

body.light {
  --color-primary: #f8fafc;
  --color-secondary: #f1f5f9;
  --color-accent: #3b82f6;
  --color-text: #334155;
  --color-border: rgba(148, 163, 184, 0.4);
  --shadow-medium: 0 8px 25px rgba(15, 23, 42, 0.15);
  --shadow-large: 0 12px 30px rgba(15, 23, 42, 0.2);
}

body.midnight {
  --color-primary: #0a0a0a;
  --color-secondary: #1a1a1a;
  --color-accent: #8b5cf6;
  --color-text: #f5f5f5;
  --color-border: rgba(148, 163, 184, 0.2);
}

body.nature {
  --color-primary: #1a3c2c;
  --color-secondary: #2d5a45;
  --color-accent: #10b981;
  --color-text: #d1fae5;
  --color-border: rgba(16, 185, 129, 0.3);
}

body.ocean {
  --color-primary: #0f3460;
  --color-secondary: #1e4a7c;
  --color-accent: #3b82f6;
  --color-text: #dbeafe;
  --color-border: rgba(59, 130, 246, 0.3);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: Vazir, Tahoma, sans-serif;
  direction: rtl;
  transition: var(--transition);
  background-color: var(--color-primary);
  color: var(--color-text);
  line-height: 1.6;
}

/* بهبودهای دسترسی - اصلاح شده */
.skip-link {
  position: fixed;
  top: -50px;
  right: 10px;
  background: var(--color-accent);
  color: white;
  padding: 12px 16px;
  text-decoration: none;
  border-radius: 8px;
  z-index: 10000;
  font-weight: 600;
  transition: var(--transition);
  border: 2px solid transparent;
  font-size: 14px;
}

.skip-link:focus {
  top: 10px;
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
  border-color: white;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.4);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.keyboard-navigation .btn:focus,
.keyboard-navigation input:focus,
.keyboard-navigation select:focus,
.keyboard-navigation a:focus {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 8px;
}

/* بوم ذرات */
#particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* صفحه اصلی */
.page-wrapper {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

/* هدر */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  padding: 20px 0;
  border-bottom: 2px solid var(--color-border);
}

.header-center {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: nowrap;
  justify-content: center;
  flex: 1;
}

.logo {
  width: 64px;
  height: 64px;
  border-radius: var(--border-radius);
  object-fit: cover;
  box-shadow: var(--shadow-medium);
  border: 2px solid var(--color-accent);
}

.header-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
}

.title {
  font-size: 22px;
  margin: 0;
  font-weight: 700;
  color: var(--color-accent);
  white-space: nowrap;
}

.subtitle {
  font-size: 14px;
  margin: 0;
  opacity: 0.9;
  white-space: nowrap;
}

/* کنترل‌های پیشرفته */
.advanced-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--color-secondary);
  border-radius: var(--border-radius);
  border: 2px solid var(--color-border);
}

.control-group {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.control-btn {
  padding: 8px 16px;
  border-radius: 12px;
  border: 2px solid var(--color-border);
  background: var(--color-primary);
  color: inherit;
  cursor: pointer;
  transition: var(--transition);
  font-size: 13px;
  font-weight: 500;
}

.control-btn:hover {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

/* راهنمای پینگ */
.ping-help {
  font-size: 11px;
  opacity: 0.7;
  cursor: help;
  padding: 6px 10px;
  background: rgba(148, 163, 184, 0.1);
  border-radius: 6px;
  border: 1px solid var(--color-border);
}

/* دکمه‌ها */
.btn {
  padding: 10px 18px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-family: Vazir, Tahoma, sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  white-space: nowrap;
  font-weight: 500;
}

.btn.small {
  font-size: 12px;
  padding: 8px 14px;
}

.btn-primary {
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--color-border);
  color: inherit;
  font-weight: 500;
}

.btn-outline:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: rgba(56, 189, 248, 0.1);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.btn:disabled:hover {
  border-color: var(--color-border);
  color: inherit;
  background: transparent;
}

/* کنترل‌های اصلی */
.controls {
  border-radius: var(--border-radius);
  padding: 20px;
  margin-bottom: 24px;
  border: 2px solid var(--color-border);
  backdrop-filter: blur(12px);
  background: var(--color-secondary);
}

.controls-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 20px;
  margin-bottom: 0;
  align-items: center;
  justify-content: space-between;
}

.field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  flex: 1;
  min-width: 0;
}

.field label {
  opacity: 0.9;
  white-space: nowrap;
  min-width: 70px;
}

input,
select {
  background: var(--color-primary);
  border: 2px solid var(--color-border);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-family: Vazir, Tahoma, sans-serif;
  min-width: 0;
  flex: 1;
  color: inherit;
  transition: var(--transition);
}

input::placeholder {
  color: #94a3b8;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

/* انتخابگر تم */
.theme-selector {
  background: var(--color-primary);
  border: 2px solid var(--color-border);
  border-radius: 12px;
  padding: 10px 14px;
  color: inherit;
  font-family: inherit;
  min-width: 150px;
  cursor: pointer;
}

.theme-selector:focus {
  outline: none;
  border-color: var(--color-accent);
}

/* لودینگ */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 30px 0;
  font-size: 14px;
  color: #64748b;
}

.hidden {
  display: none !important;
}

.loader {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 4px solid rgba(148, 163, 184, 0.3);
  border-top-color: var(--color-accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* گرید کارت‌ها */
.proxy-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
  flex: 1;
}

@media (min-width: 768px) {
  .proxy-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* کارت پروکسی */
.proxy-card {
  border-radius: var(--border-radius);
  padding: 20px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  cursor: default;
  transition: var(--transition);
  border: 2px solid transparent;
  background: var(--color-secondary);
  box-shadow: var(--shadow-medium);
  animation: slideIn 0.3s ease-out;
}

.proxy-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--color-accent);
  box-shadow: var(--shadow-large);
}

/* هدر کارت */
.proxy-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.proxy-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.flag {
  width: 28px;
  height: 21px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--color-border);
  flex-shrink: 0;
}

.country-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-accent);
}

.provider {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 2px;
}

/* پینگ */
.ping-badge {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 2px solid;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  order: 3;
}

.ping-indicator {
  font-size: 10px;
  margin-left: 4px;
  cursor: help;
  order: 2;
}

.ping-good {
  border-color: #10b981;
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
}

.ping-mid {
  border-color: #f59e0b;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
}

.ping-bad {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.ping-unknown {
  border-color: #64748b;
  color: #94a3b8;
  background: rgba(100, 116, 139, 0.1);
}

.ping-live {
  border-color: #10b981;
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  animation: ping-pulse 2s infinite;
}

@keyframes ping-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0);
  }
}

/* جزئیات کارت */
.proxy-details {
  font-size: 13px;
  line-height: 1.8;
  display: grid;
  gap: 8px;
}

.proxy-details .label {
  color: #64748b;
  font-weight: 500;
}

/* دکمه‌ها و هاست کوتاه */
.proxy-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  gap: 12px;
}

.proxy-buttons {
  display: flex;
  gap: 8px;
}

.host-short {
  font-size: 12px;
  font-family: 'Courier New', monospace;
  color: #64748b;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
  text-align: left;
  background: rgba(148, 163, 184, 0.1);
  padding: 4px 8px;
  border-radius: 8px;
}

/* صفحه‌بندی */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin: 30px 0;
  padding: 16px;
}

.pagination-btn {
  min-width: 90px;
  font-weight: 600;
}

.page-info {
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.1);
  border: 2px solid var(--color-border);
  font-weight: 600;
}

/* پیام عدم وجود پروکسی */
.no-proxies {
  text-align: center;
  font-size: 16px;
  opacity: 0.7;
  padding: 60px 20px;
  grid-column: 1 / -1;
  color: #64748b;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
  border: 2px solid var(--color-border);
  backdrop-filter: blur(16px);
  background: var(--color-secondary);
  color: var(--color-text);
  z-index: 9999;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -8px);
}

.toast.success {
  border-color: #10b981;
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
}

.toast.error {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.toast.info {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: rgba(56, 189, 248, 0.1);
}

/* فوتر */
.footer {
  margin-top: auto;
  padding: 20px 0;
}

.footer-box {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), rgba(59, 130, 246, 0.1));
  border: 2px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--border-radius);
  padding: 24px;
  text-align: center;
  backdrop-filter: blur(10px);
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

.footer-heart {
  font-size: 16px;
  font-weight: 700;
  color: #ef4444;
  display: flex;
  align-items: center;
  gap: 8px;
}

.telegram-channel {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-accent);
  padding: 10px 20px;
  background: rgba(56, 189, 248, 0.1);
  border-radius: 50px;
  border: 2px solid rgba(56, 189, 248, 0.3);
  transition: var(--transition);
  text-decoration: none;
}

.telegram-channel:hover {
  background: rgba(56, 189, 248, 0.2);
  transform: translateY(-2px);
  text-decoration: none;
}

.telegram-icon {
  width: 20px;
  height: 20px;
}

.footer a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
}

.footer a:hover {
  text-decoration: underline;
}

/* اسکلتون لودینگ */
.skeleton {
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  background: var(--color-secondary);
  border-radius: var(--border-radius);
  padding: 20px;
}

.skeleton-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.skeleton-flag {
  width: 28px;
  height: 21px;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.3);
}

.skeleton-text {
  flex: 1;
}

.skeleton-title {
  height: 16px;
  background: rgba(148, 163, 184, 0.3);
  border-radius: 4px;
  margin-bottom: 6px;
  width: 80%;
}

.skeleton-subtitle {
  height: 12px;
  background: rgba(148, 163, 184, 0.3);
  border-radius: 4px;
  width: 60%;
}

.skeleton-badge {
  width: 60px;
  height: 24px;
  background: rgba(148, 163, 184, 0.3);
  border-radius: 12px;
}

.skeleton-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-line {
  height: 12px;
  background: rgba(148, 163, 184, 0.3);
  border-radius: 4px;
}

.skeleton-line:nth-child(2) {
  width: 70%;
}

.skeleton-line:nth-child(3) {
  width: 50%;
}

@keyframes skeleton-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.fade-out {
  animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* نوتیفیکیشن پیشرفته */
.notification {
  position: fixed;
  top: 20px;
  left: 20px;
  right: 20px;
  max-width: 400px;
  background: var(--color-secondary);
  border: 2px solid;
  border-radius: 12px;
  padding: 0;
  margin: 0 auto;
  z-index: 10000;
  transform: translateY(-100px);
  opacity: 0;
  transition: var(--transition);
  box-shadow: var(--shadow-large);
}

.notification.show {
  transform: translateY(0);
  opacity: 1;
}

.notification-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.notification-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.notification-message {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.notification-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: inherit;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.notification-close:hover {
  background: rgba(148, 163, 184, 0.2);
}

.notification-info {
  border-color: var(--color-accent);
  background: rgba(56, 189, 248, 0.1);
}

.notification-success {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.1);
}

.notification-warning {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
}

.notification-error {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.notification-test {
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.1);
}

/* مودال فیدبک */
.feedback-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
  backdrop-filter: blur(5px);
}

.feedback-content {
  background: var(--color-secondary);
  border-radius: var(--border-radius);
  padding: 0;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 2px solid var(--color-accent);
  box-shadow: var(--shadow-large);
}

.feedback-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--color-border);
}

.feedback-header h3 {
  margin: 0;
  color: var(--color-accent);
}

.feedback-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: inherit;
  padding: 4px;
  border-radius: 4px;
}

.feedback-close:hover {
  background: rgba(148, 163, 184, 0.2);
}

.feedback-body {
  padding: 20px;
}

.feedback-rating {
  margin-bottom: 20px;
}

.feedback-rating label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}

.stars {
  display: flex;
  gap: 4px;
  direction: ltr;
}

.star {
  font-size: 24px;
  color: rgba(148, 163, 184, 0.5);
  cursor: pointer;
  transition: var(--transition);
}

.star:hover,
.star.active {
  color: #f59e0b;
  transform: scale(1.2);
}

.feedback-text {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  border: 2px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-primary);
  color: inherit;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 20px;
}

.feedback-text:focus {
  outline: none;
  border-color: var(--color-accent);
}

.feedback-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* تست پینگ */
.testing-indicator {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f59e0b;
  margin-right: 8px;
  animation: testing-pulse 1s infinite;
}

@keyframes testing-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

/* انیمیشن‌ها */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.proxy-card {
  animation: slideIn 0.3s ease-out;
}

.proxy-card:nth-child(even) {
  animation-delay: 0.1s;
}

.proxy-card:nth-child(odd) {
  animation-delay: 0.2s;
}

/* اسکرول‌بار */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 20px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-accent);
}

/* رسپانسیو */
@media (max-width: 1024px) {
  .controls-row {
    flex-wrap: wrap;
    gap: 16px;
  }
  
  .field {
    flex: 1 1 calc(50% - 16px);
    min-width: 200px;
  }
  
  .advanced-controls {
    flex-direction: column;
    gap: 12px;
  }
}

@media (max-width: 768px) {
  .page-wrapper {
    padding: 16px;
  }
  
  .header {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
  
  .header-center {
    order: 1;
  }
  
  .header-right {
    order: 2;
  }
  
  .controls {
    padding: 16px;
  }
  
  .controls-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  .field {
    flex: 1 1 100%;
    justify-content: space-between;
  }
  
  input, select {
    min-width: auto;
    flex: 1;
  }
  
  .pagination {
    flex-wrap: wrap;
    gap: 12px;
  }
  
  .proxy-card {
    padding: 16px;
  }
  
  .footer-box {
    padding: 16px;
  }
  
  .footer-content {
    flex-direction: column;
    gap: 16px;
  }
  
  .telegram-channel {
    font-size: 14px;
    padding: 8px 16px;
  }
  
  .notification {
    left: 10px;
    right: 10px;
    top: 10px;
  }
  
  .feedback-content {
    margin: 10px;
  }
}

@media (max-width: 480px) {
  .page-wrapper {
    padding: 12px;
  }
  
  .header-text .title {
    font-size: 18px;
  }
  
  .header-text .subtitle {
    font-size: 12px;
  }
  
  .logo {
    width: 48px;
    height: 48px;
  }
  
  .proxy-grid {
    grid-template-columns: 1fr;
  }
  
  .skip-link {
    font-size: 12px;
    padding: 10px 14px;
  }
}

/* استایل‌های PWA */
@media (display-mode: standalone) {
  .page-wrapper {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  .header {
    padding-top: calc(20px + env(safe-area-inset-top));
  }
}

/* حالت چاپ */
@media print {
  .advanced-controls,
  .controls,
  .footer {
    display: none;
  }
  
  .proxy-card {
    break-inside: avoid;
    border: 1px solid #000;
    box-shadow: none;
  }
}