/* History Page Styles */
html.history-page,
html.history-page body {
  /* overflow-x: hidden; */
}

.history-container {
  max-width: 1000px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.history-header h1 {
  font-size: 1.75rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.btn-new-clip {
  padding: 0.625rem 1.25rem;
  font-size: 0.9rem;
  border-radius: 10px;
  text-decoration: none;
}

.back-link {
  color: var(--orchid);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.back-link:hover {
  background: var(--glass-bg);
  border-color: var(--glass-border);
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  border: 1px solid var(--glass-border);
}

.empty-state h2 {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 0.875rem 1rem;
  text-align: center;
  transition: all 0.3s;
}

.stat-card:hover {
  border-color: var(--orchid);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(217, 70, 239, 0.1);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.125rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-item {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.25rem;
  align-items: center;
  transition: all 0.3s;
  position: relative;
  z-index: 1;
}

.history-item:hover {
  border-color: var(--orchid);
  box-shadow: 0 10px 40px rgba(217, 70, 239, 0.1);
  transform: translateY(-2px);
}

.history-item.dropdown-active {
  z-index: 50;
}

.history-item.expired {
  opacity: 0.5;
}

.format-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.format-icon.mp4 {
  background: linear-gradient(135deg, #818cf8, #6366f1);
}

.format-icon.mp3 {
  background: linear-gradient(135deg, #34d399, #10b981);
}

.format-icon.m4a {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.format-icon svg {
  width: 26px;
  height: 26px;
  color: white;
}

.format-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  background: var(--surface-hover);
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}

.clip-info {
  min-width: 0;
}

.clip-info h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.clip-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.clip-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.time-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 0.5rem;
}

.time-badge.available {
  background: rgba(52, 211, 153, 0.1);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.2);
}

.time-badge.warning {
  background: rgba(251, 191, 36, 0.1);
  color: var(--warning);
  border: 1px solid rgba(251, 191, 36, 0.2);
}

.time-badge.expired {
  background: rgba(248, 113, 113, 0.1);
  color: var(--error);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.action-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.action-btn:hover {
  border-color: var(--orchid);
  color: var(--orchid);
  transform: translateY(-2px);
}

.action-btn.download {
  background: var(--gradient-button);
  border-color: transparent;
  color: white;
}

.action-btn.download:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(217, 70, 239, 0.4);
}

.action-btn.delete:hover {
  border-color: var(--error);
  color: var(--error);
}

.action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.dropdown {
  position: relative;
}

.dropdown.open {
  z-index: 100;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem;
  min-width: 190px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.15s;
  white-space: nowrap;
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.875rem;
}

.dropdown-item:hover {
  background: var(--surface-hover);
}

.dropdown-item.danger {
  color: var(--error);
}

.dropdown-item.danger:hover {
  background: rgba(248, 113, 113, 0.1);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  overflow: hidden;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.25rem;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: var(--surface-hover);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--border);
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  gap: 1rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
}

.modal-footer .btn {
  flex: 1;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.detail-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  background: var(--surface-hover);
  border-radius: 12px;
}

.detail-row.full-width {
  grid-column: span 2;
}

.detail-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-value {
  font-weight: 500;
  word-break: break-word;
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface);
  border-color: var(--orchid);
}

.confirm-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  background: rgba(248, 113, 113, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--error);
}

.confirm-text {
  text-align: center;
  margin-bottom: 1rem;
}

.confirm-text h3 {
  margin-bottom: 0.5rem;
}

.confirm-text p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Video Player Modal */
.video-player-wrapper {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.video-player-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-player-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.video-player-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.video-player-meta span {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Audio Player - WhatsApp style */
.audio-player-wrapper {
  width: 100%;
  background: var(--gradient-subtle);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--glass-border);
}

.audio-player-content {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.audio-play-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient-button);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(217, 70, 239, 0.3);
}

.audio-play-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(217, 70, 239, 0.4);
}

.audio-play-btn svg {
  width: 24px;
  height: 24px;
}

.audio-play-btn .play-icon {
  display: block;
}

.audio-play-btn .pause-icon {
  display: none;
}

.audio-play-btn.playing .play-icon {
  display: none;
}

.audio-play-btn.playing .pause-icon {
  display: block;
}

.audio-waveform-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.audio-waveform {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  position: relative;
}

.audio-waveform .wave-bar {
  flex: 1;
  background: var(--border);
  border-radius: 2px;
  transition: background 0.1s;
  min-width: 3px;
  max-width: 5px;
}

.audio-waveform .wave-bar.active {
  background: var(--orchid);
}

.audio-waveform .wave-bar.playing {
  animation: waveAnimate 0.5s ease-in-out infinite alternate;
}

@keyframes waveAnimate {
  0% {
    opacity: 0.6;
  }

  100% {
    opacity: 1;
  }
}

.audio-time-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'SF Mono', monospace;
}

/* Responsive - Tailwind breakpoints: sm(640px), md(768px), lg(1024px) */
@media (max-width: 767px) {
  .history-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .history-header h1 {
    font-size: 1.5rem;
  }

  .btn-new-clip {
    width: 100%;
    justify-content: center;
  }

  .history-item {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .format-icon {
    width: 48px;
    height: 48px;
  }

  .action-buttons {
    justify-content: flex-start;
  }

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .stat-card {
    padding: 0.75rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .stat-label {
    font-size: 0.7rem;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-row.full-width {
    grid-column: span 1;
  }

  .history-container {
    padding: 0 1rem;
  }

  /* Hide dropdown menu on mobile - use bottomsheet instead */
  .dropdown-menu {
    display: none !important;
  }

  .dropdown.open .dropdown-menu {
    display: none !important;
  }
}