/**
 * Video Library Management
 * Professional video upload and library interface for instructors
 * Uses production studio aesthetic with refined typography
 */

/* Import distinctive fonts */
@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:wght@400;600;700&family=Work+Sans:wght@400;500;600&display=swap');

/* =============================================================================
   VIDEO TAB CONTAINER
   ============================================================================= */

#videos-tab-content {
  font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  animation: fadeSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Alpine.js cloak */
[x-cloak] {
  display: none !important;
}

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


/* =============================================================================
   UPLOAD CARD (IN GRID)
   ============================================================================= */

.video-card--upload {
  border: 3px dashed var(--color-border-base);
  cursor: pointer;
  transition: all var(--transition-base);
  background: var(--ctp-base);
  display: flex;
  align-items: stretch;
}

.video-card--upload:hover {
  border-color: var(--ctp-peach);
  background: var(--color-bg-base);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.video-card__upload-area {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  cursor: pointer;
  padding: var(--space-8);
}

.video-card__upload-icon {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  background: var(--ctp-peach);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-base);
  flex-shrink: 0;
}

.video-card--upload:hover .video-card__upload-icon {
  transform: scale(1.1);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.video-card__upload-icon i {
  font-size: 2.25rem;
  color: white;
}

.video-card__upload-text {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--ctp-text);
  text-align: center;
}

/* =============================================================================
   PROGRESS SECTION
   ============================================================================= */

.progress-section {
  background: var(--color-bg-base);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border-base);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-6);
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.progress-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--color-border-base);
}

.progress-section__title {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--ctp-text);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.progress-section__dismiss {
  background: transparent;
  border: none;
  color: var(--ctp-subtext0);
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.progress-section__dismiss:hover {
  background: var(--ctp-surface0);
  color: var(--ctp-text);
}

.progress-section__dismiss:active {
  transform: scale(0.95);
}

.file-progress-item {
  background: var(--ctp-base);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4) !important;
  transition: all var(--transition-base);
}

.file-progress-item:last-child {
  margin-bottom: 0 !important;
}

.file-progress-item:hover {
  box-shadow: var(--shadow-sm);
}

/* Override JavaScript-generated Bulma progress bars */
.file-progress-item .progress {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--ctp-surface0);
  margin: var(--space-3) 0;
  width: 100%;
}

.file-progress-item .progress::-webkit-progress-bar {
  background: var(--ctp-surface0);
  border-radius: var(--radius-full);
}

.file-progress-item .progress::-webkit-progress-value {
  background: var(--ctp-blue);
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
}

.file-progress-item .progress::-moz-progress-bar {
  background: var(--ctp-blue);
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
}

.file-progress-item .progress.is-warning::-webkit-progress-value {
  background: var(--ctp-yellow);
}

.file-progress-item .progress.is-warning::-moz-progress-bar {
  background: var(--ctp-yellow);
}

.file-progress-item .progress.is-danger::-webkit-progress-value {
  background: var(--ctp-red);
}

.file-progress-item .progress.is-danger::-moz-progress-bar {
  background: var(--ctp-red);
}

.file-progress-item .has-text-weight-bold {
  font-weight: var(--font-weight-semibold);
  color: var(--ctp-text);
  margin-bottom: var(--space-2);
}

.file-progress-item .has-text-grey {
  color: var(--ctp-subtext1);
  font-size: var(--font-size-sm);
}

.file-progress-item .has-text-success {
  color: var(--ctp-green);
  font-weight: var(--font-weight-medium);
}

.file-progress-item .has-text-danger {
  color: var(--ctp-red);
  font-weight: var(--font-weight-medium);
}

.file-progress-item .has-text-warning {
  color: var(--ctp-yellow);
  font-weight: var(--font-weight-medium);
}


/* =============================================================================
   VIDEO LIBRARY SECTION
   ============================================================================= */

.library-section {
  margin-top: var(--space-12);
}

.library-section__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
}

.library-section__title {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 2rem;
  font-weight: var(--font-weight-bold);
  color: var(--ctp-text);
  letter-spacing: -0.02em;
}

.library-section__count {
  background: var(--ctp-peach);
  color: white;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
}

/* Video Grid */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-6);
}

/* Video Card */
.video-card {
  background: var(--color-bg-base);
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--color-border-base);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-slow);
  cursor: pointer;
}

.video-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
  border-color: var(--color-border-strong);
}

.video-card__thumbnail {
  background: var(--ctp-crust);
  aspect-ratio: 16 / 9;
  position: relative;
  overflow: hidden;
}

.video-card__player {
  border: 0;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.video-card__duration {
  position: absolute;
  bottom: var(--space-3);
  right: var(--space-3);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  z-index: 2;
}

.video-card__info {
  padding: var(--space-5);
}

.video-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.video-card__title {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--ctp-text);
  line-height: var(--line-height-tight);
  flex: 1;
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-card__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.video-card__action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--ctp-surface0);
  color: var(--ctp-subtext0);
  transition: all var(--transition-base);
  cursor: pointer;
  border: 1px solid transparent;
}

.video-card__action-btn:hover {
  background: var(--ctp-surface1);
  color: var(--ctp-text);
  border-color: var(--color-border-base);
  transform: translateY(-1px);
}

.video-card__action-btn--rename:hover {
  background: var(--ctp-blue);
  color: white;
  border-color: var(--ctp-blue);
}

.video-card__action-btn--delete:hover {
  background: var(--ctp-red);
  color: white;
  border-color: var(--ctp-red);
}

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

.video-card__action-btn i {
  font-size: var(--font-size-sm);
}

.video-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--ctp-subtext1);
}

.video-card__meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.video-card__meta-icon {
  font-size: var(--font-size-sm);
  color: var(--ctp-overlay0);
}


/* =============================================================================
   VIDEO RENAME MODAL
   ============================================================================= */

.video-rename-modal {
  font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

.video-rename-modal__form {
  padding: var(--space-8);
}

.video-rename-modal__field {
  margin-bottom: var(--space-5);
}

.video-rename-modal__label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--ctp-subtext1);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.video-rename-modal__input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-base);
  font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ctp-text);
  background: var(--ctp-surface0);
  border: 2px solid var(--color-border-base);
  border-radius: var(--radius-lg);
  transition: all var(--transition-base);
  outline: none;
}

.video-rename-modal__input::placeholder {
  color: var(--ctp-overlay0);
}

.video-rename-modal__input:focus {
  border-color: var(--ctp-blue);
  background: var(--ctp-base);
  box-shadow: 0 0 0 3px rgba(137, 180, 250, 0.15);
}

.video-rename-modal__input:hover:not(:focus) {
  border-color: var(--ctp-overlay0);
}

.video-rename-modal__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-top: var(--space-5);
}

.video-rename-modal__btn--save {
  padding: var(--space-3) var(--space-6);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-lg);
  border: none;
  cursor: pointer;
  transition: all var(--transition-base);
  font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--ctp-blue);
  color: white;
  min-width: 120px;
}

.video-rename-modal__btn--save:hover {
  background: var(--ctp-sapphire);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(137, 180, 250, 0.3);
}

.video-rename-modal__btn--save:active {
  transform: translateY(0);
}

/* =============================================================================
   ANIMATIONS
   ============================================================================= */

.video-card {
  animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.video-card:nth-child(1) { animation-delay: 0.05s; }
.video-card:nth-child(2) { animation-delay: 0.1s; }
.video-card:nth-child(3) { animation-delay: 0.15s; }
.video-card:nth-child(4) { animation-delay: 0.2s; }
.video-card:nth-child(5) { animation-delay: 0.25s; }
.video-card:nth-child(6) { animation-delay: 0.3s; }

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

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 767px) {
  .video-grid {
    grid-template-columns: 1fr;
  }

  .video-library__header {
    font-size: 2rem;
  }

  .library-section__title {
    font-size: 1.5rem;
  }

  .upload-zone {
    padding: var(--space-8) var(--space-4);
  }

  .library-section__header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }
}

/* =============================================================================
   ACCESSIBILITY
   ============================================================================= */

.file-input-button:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.video-card:focus {
  outline: 2px solid var(--ctp-blue);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* =============================================================================
   PUBLIC VIDEO LIBRARY (VIDEO_WUI)
   ============================================================================= */

/* Catppuccin Latte Color Variables */
:root {
  --ctp-latte-rosewater: #dc8a78;
  --ctp-latte-flamingo: #dd7878;
  --ctp-latte-pink: #ea76cb;
  --ctp-latte-mauve: #8839ef;
  --ctp-latte-red: #d20f39;
  --ctp-latte-maroon: #e64553;
  --ctp-latte-peach: #fe640b;
  --ctp-latte-yellow: #df8e1d;
  --ctp-latte-green: #40a02b;
  --ctp-latte-teal: #179299;
  --ctp-latte-sky: #04a5e5;
  --ctp-latte-sapphire: #209fb5;
  --ctp-latte-blue: #1e66f5;
  --ctp-latte-lavender: #7287fd;
  --ctp-latte-text: #4c4f69;
  --ctp-latte-subtext1: #5c5f77;
  --ctp-latte-subtext0: #6c6f85;
  --ctp-latte-overlay2: #7c7f93;
  --ctp-latte-overlay1: #8c8fa1;
  --ctp-latte-overlay0: #9ca0b0;
  --ctp-latte-surface2: #acb0be;
  --ctp-latte-surface1: #bcc0cc;
  --ctp-latte-surface0: #ccd0da;
  --ctp-latte-base: #eff1f5;
  --ctp-latte-mantle: #e6e9ef;
  --ctp-latte-crust: #dce0e8;
}

/* Main Video Player Pulse Animation */
@keyframes video-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  }
  50% {
    transform: scale(1.01);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  }
}

.video-pulse {
  animation: video-pulse 1s ease;
}

/* Video Thumbnail Cards */
.video-thumbnail-card {
  transition: all 0.2s ease;
}

.video-thumbnail-card__wrapper {
  background: var(--ctp-latte-mantle);
  border: 2px solid var(--ctp-latte-surface0);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  box-sizing: border-box;
}

.video-thumbnail-card__wrapper--selected {
  border: 3px solid var(--ctp-latte-mauve);
  box-shadow: 0 6px 20px rgba(136, 57, 239, 0.3);
  margin: -1px;
}

.video-thumbnail-card__info {
  padding: 16px 20px;
  background: var(--ctp-latte-base);
}

.video-thumbnail-card__info--selected {
  background: linear-gradient(to bottom, rgba(136, 57, 239, 0.15), rgba(136, 57, 239, 0.08));
}

/* Playing Icon Animation */
@keyframes icon-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

.playing-icon {
  animation: icon-pulse 1.5s ease-in-out infinite;
}

/* Mobile Responsive for Public Video Library */
@media (max-width: 768px) {
  .video-thumbnail-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  .video-thumbnail-card__wrapper {
    display: flex !important;
    align-items: flex-start;
    gap: 12px;
  }

  .video-preview {
    width: 120px !important;
    min-width: 120px;
    height: 67.5px;
    flex-shrink: 0;
  }

  .video-thumbnail-card__info {
    flex: 1;
    padding: 4px 16px 4px 0;
    height: 67.5px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }

  .video-thumbnail-card__info h4 {
    font-size: 13px !important;
    font-weight: 500 !important;
  }

  .video-thumbnail-card__info p {
    font-size: 11px !important;
  }
}
