/* ============ تأثيرات الحركة والانتقالات ============ */
@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}

/* ============ أداة YouTube الرئيسية ============ */
.youtube-container {
  max-width: 900px;
  margin: 40px auto;
  padding: 0 20px;
  animation: slideInDown 0.5s ease-out;
}

.tool-header {
  text-align: center;
  margin-bottom: 40px;
  animation: slideInDown 0.6s ease-out;
}

.tool-icon-big {
  font-size: 64px;
  display: inline-block;
  margin-bottom: 15px;
  animation: pulse 2s ease-in-out infinite;
}

.tool-header h1 {
  font-size: 36px;
  font-weight: 800;
  color: var(--text);
  margin: 10px 0;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tool-desc {
  color: var(--muted);
  font-size: 16px;
  margin-top: 10px;
}

/* ============ البطاقة الرئيسية ============ */
.youtube-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  animation: slideInUp 0.6s ease-out;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.youtube-card:hover {
  border-color: var(--accent);
  box-shadow: 0 12px 48px rgba(255, 122, 26, 0.15);
}

/* ============ قسم الإدخال ============ */
.youtube-input-section {
  margin-bottom: 30px;
  animation: slideInDown 0.7s ease-out 0.1s both;
}

.input-wrapper {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
}

.youtube-input {
  flex: 1;
  padding: 14px 18px;
  background: var(--panel-2);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  transition: all 0.3s ease;
  font-family: inherit;
}

.youtube-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel);
  box-shadow: 0 0 16px rgba(255, 122, 26, 0.2);
}

.youtube-input::placeholder {
  color: var(--muted);
}

.btn-search {
  padding: 14px 28px;
  background: var(--accent-grad);
  border: none;
  border-radius: 10px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(255, 122, 26, 0.3);
}

.btn-search:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 122, 26, 0.4);
}

.btn-search:active {
  transform: translateY(0);
}

.btn-icon {
  font-size: 16px;
}

.input-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

/* ============ حالة التحميل ============ */
.loading-state {
  text-align: center;
  padding: 40px;
  animation: slideInUp 0.4s ease-out;
}

.loading-state.hidden {
  display: none;
}

.spinner {
  width: 50px;
  height: 50px;
  margin: 0 auto 20px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ============ معلومات المقطع ============ */
.video-info {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  margin: 30px 0;
  padding: 24px;
  background: var(--panel-2);
  border-radius: 12px;
  animation: slideInUp 0.5s ease-out;
}

.video-info.hidden {
  display: none;
}

.video-thumbnail {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: var(--border);
  aspect-ratio: 16/9;
}

.video-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.duration-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.video-details {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.video-details h3 {
  margin: 0 0 12px 0;
  font-size: 18px;
  color: var(--text);
  font-weight: 700;
  line-height: 1.4;
}

.video-channel,
.video-description {
  margin: 8px 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.video-channel span {
  color: var(--accent);
  font-weight: 600;
}

/* ============ خيارات التحميل ============ */
.download-options {
  animation: slideInUp 0.5s ease-out;
}

.download-options.hidden {
  display: none;
}

.options-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab-btn {
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-btn:hover:not(.active) {
  color: var(--text);
}

.tab-content {
  display: none;
  animation: slideInUp 0.3s ease-out;
}

.tab-content.active {
  display: block;
}

.tab-content h4 {
  margin: 0 0 16px 0;
  font-size: 16px;
  color: var(--text);
  font-weight: 700;
}

/* ============ شبكة الجودات ============ */
.quality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.quality-card {
  padding: 12px;
  background: var(--panel-2);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  transition: all 0.3s ease;
  animation: slideInUp 0.4s ease-out;
}

.quality-card:hover {
  border-color: var(--accent);
  background: var(--panel);
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(255, 122, 26, 0.15);
}

.quality-card.selected {
  border-color: var(--accent);
  background: var(--panel);
  box-shadow: 0 0 16px rgba(255, 122, 26, 0.3);
}

.quality-label {
  font-weight: 700;
  color: var(--text);
  font-size: 14px;
  display: block;
  margin-bottom: 4px;
}

.quality-info {
  font-size: 12px;
  color: var(--muted);
}

/* ============ خيارات الصوت والصورة ============ */
.audio-options,
.image-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.option-card {
  padding: 18px;
  background: var(--panel-2);
  border: 2px solid var(--border);
  border-radius: 12px;
  text-align: center;
  transition: all 0.3s ease;
  animation: slideInUp 0.4s ease-out;
  display: flex;
  flex-direction: column;
}

.option-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(255, 122, 26, 0.2);
}

.option-title {
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  font-size: 14px;
}

.option-card p {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
  flex-grow: 1;
}

.btn-download {
  padding: 10px 16px;
  background: var(--accent-grad);
  border: none;
  border-radius: 8px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.3s ease;
}

.btn-download:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(255, 122, 26, 0.3);
}

.btn-download:active {
  transform: scale(0.98);
}

/* ============ أزرار الإجراءات ============ */
.download-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.btn-primary,
.btn-secondary {
  flex: 1;
  min-width: 150px;
  padding: 14px 24px;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent-grad);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 122, 26, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 122, 26, 0.4);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 2px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  background: var(--panel);
}

/* ============ شريط التقدم ============ */
.progress-bar {
  margin-top: 20px;
  padding: 16px;
  background: var(--panel-2);
  border-radius: 10px;
  animation: slideInUp 0.4s ease-out;
}

.progress-bar.hidden {
  display: none;
}

.progress-fill {
  height: 6px;
  background: var(--accent-grad);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
  margin-bottom: 8px;
}

.progress-text {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  display: block;
}

/* ============ رسالة الخطأ ============ */
.error-message {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(239, 68, 68, 0.15);
  border: 2px solid #ef4444;
  border-radius: 10px;
  color: #fca5a5;
  margin-top: 20px;
  animation: slideInUp 0.4s ease-out;
}

.error-message.hidden {
  display: none;
}

.error-icon {
  font-size: 20px;
}

.error-message p {
  margin: 0;
}

/* ============ قسم المعلومات ============ */
.info-section {
  margin-top: 40px;
  padding: 24px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 12px;
  animation: slideInUp 0.7s ease-out 0.2s both;
}

.info-section h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  color: var(--text);
}

.info-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.info-list li {
  padding: 10px 0;
  color: var(--muted);
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  transition: all 0.3s ease;
}

.info-list li:last-child {
  border-bottom: none;
}

.info-list li:hover {
  color: var(--text);
  transform: translateX(-8px);
}

/* ============ Modal ============ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease-out;
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--panel);
  padding: 32px;
  border-radius: 16px;
  max-width: 500px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideInUp 0.4s ease-out;
  border: 1px solid var(--border);
}

.modal-content h3 {
  margin: 0 0 12px 0;
  font-size: 20px;
  color: var(--text);
}

.modal-content p {
  color: var(--muted);
  margin: 12px 0 24px;
}

.modal-buttons {
  display: flex;
  gap: 12px;
}

/* ============ إشعارات SweetAlert2 المخصصة ============ */
.swal2-popup {
  background: var(--panel) !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5) !important;
}

.swal2-title {
  color: var(--text) !important;
  font-family: inherit !important;
}

.swal2-html-container {
  color: var(--muted) !important;
  font-family: inherit !important;
}

.swal2-confirm {
  background: var(--accent-grad) !important;
  color: white !important;
  border: none !important;
  box-shadow: 0 4px 12px rgba(255, 122, 26, 0.3) !important;
}

.swal2-confirm:hover {
  box-shadow: 0 6px 20px rgba(255, 122, 26, 0.4) !important;
}

.swal2-cancel {
  background: var(--panel-2) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}

.swal2-cancel:hover {
  background: var(--border) !important;
}

/* ============ التوافقية والمحمول ============ */
@media (max-width: 768px) {
  .youtube-card {
    padding: 20px;
  }

  .input-wrapper {
    flex-direction: column;
  }

  .video-info {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .video-thumbnail {
    width: 100%;
  }

  .quality-grid,
  .audio-options,
  .image-options {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .download-actions {
    flex-direction: column;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
  }

  .tool-header h1 {
    font-size: 24px;
  }

  .options-tabs {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .youtube-card {
    padding: 16px;
  }

  .tool-icon-big {
    font-size: 48px;
  }

  .tool-header h1 {
    font-size: 20px;
  }

  .quality-grid,
  .audio-options,
  .image-options {
    grid-template-columns: 1fr;
  }

  .btn-search {
    width: 100%;
  }

  .video-details h3 {
    font-size: 16px;
  }
}
