:root {
  --bg-primary: #0a0e17;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f0f4fc;
  --text-secondary: #94a3b8;
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-red: #ef4444;
  --accent-green: #10b981;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Tajawal', 'Outfit', sans-serif;
  background-color: var(--tg-theme-bg-color, var(--bg-primary));
  color: var(--tg-theme-text-color, var(--text-primary));
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px 12px;
  position: relative;
  overflow-x: hidden;
}

/* إضاءة محيطية في الخلفية */
.ambient-glow {
  position: fixed;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}

.glow-1 {
  top: -40px;
  right: -40px;
  background: radial-gradient(circle, var(--accent-cyan), transparent);
}

.glow-2 {
  bottom: 40px;
  left: -40px;
  background: radial-gradient(circle, var(--accent-purple), transparent);
}

/* الحاوية الرئيسية */
.app-container {
  width: 100%;
  max-width: 440px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* الشريط العلوي */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px;
}

.badge-lock {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-cyan);
  backdrop-filter: blur(8px);
}

.btn-close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--bg-card-border);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.btn-close:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.12);
}

/* الكروت الزجاجية */
.card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 22px 18px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.hidden {
  display: none !important;
}

/* 1. تصميم شاشة التحميل */
.lock-orb {
  position: relative;
  width: 84px;
  height: 84px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 10px 0;
}

.orb-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px dashed rgba(6, 182, 212, 0.4);
  animation: spinRing 6s linear infinite;
}

.orb-core {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--accent-cyan);
  box-shadow: 0 0 24px rgba(6, 182, 212, 0.4);
  animation: pulseCore 2s ease-in-out infinite;
}

.svg-lock {
  width: 26px;
  height: 26px;
}

@keyframes spinRing {
  100% { transform: rotate(360deg); }
}

@keyframes pulseCore {
  0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(6, 182, 212, 0.3); }
  50% { transform: scale(1.08); box-shadow: 0 0 32px rgba(6, 182, 212, 0.6); }
}

.state-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.state-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 280px;
}

.loading-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 6px;
}

.loading-progress {
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
  border-radius: 10px;
  animation: indeterminate 1.5s infinite ease-in-out;
}

@keyframes indeterminate {
  0% { transform: translateX(250%); }
  100% { transform: translateX(-150%); }
}

/* 2. شاشة فك التشفير الناجحة */
.sender-info {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--bg-card-border);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  text-align: right;
}

.avatar-ring {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(59, 130, 246, 0.3));
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.sender-details {
  display: flex;
  flex-direction: column;
}

.meta-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.sender-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* منفذ عرض الوسائط */
.media-viewport {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--bg-card-border);
}

.media-box {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.media-img {
  width: 100%;
  max-height: 380px;
  object-fit: contain;
  display: block;
  border-radius: var(--radius-md);
}

.media-video {
  width: 100%;
  max-height: 380px;
  border-radius: var(--radius-md);
  background: #000;
}

.audio-card {
  width: 100%;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.audio-icon {
  font-size: 2.2rem;
}

.media-audio {
  width: 100%;
  filter: invert(0.85) hue-rotate(180deg);
}

.doc-download-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent-cyan);
  text-decoration: none;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: background 0.2s;
}

.doc-download-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* كرت الوصف والنص */
.caption-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--bg-card-border);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  text-align: right;
}

.caption-text {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #e2e8f0;
  word-break: break-word;
  white-space: pre-wrap;
}

/* عداد الوقت */
.timer-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.timer-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.timer-seconds {
  color: var(--accent-cyan);
  font-weight: 700;
}

.timer-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
}

.timer-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
  border-radius: 10px;
  transition: width 1s linear;
}

/* الأزرار */
.btn-action {
  width: 100%;
  padding: 13px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  transition: transform 0.15s ease, opacity 0.2s ease;
}

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

.btn-confirm {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  color: #fff;
  box-shadow: 0 4px 16px rgba(6, 182, 212, 0.35);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--bg-card-border);
}

/* 3. شاشة الرفض */
.denied-icon-wrap {
  position: relative;
  font-size: 3.5rem;
  margin: 10px 0;
}

.denied-shield {
  filter: drop-shadow(0 0 16px rgba(239, 68, 68, 0.4));
}

.denied-cross {
  position: absolute;
  font-size: 1.8rem;
  bottom: -4px;
  left: -4px;
}

.denied-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent-red);
}

.denied-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.denied-target-badge {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: #fca5a5;
  display: flex;
  gap: 6px;
}
