/* YouCast.me Design System */

/* CSS Custom Properties (Tokens) */
:root {
  /* Primary Colors */
  --yc-blue: #007AFF;
  --yc-blue-hover: #0056CC;
  --yc-blue-light: #E5F1FF;

  /* Neutral Colors */
  --yc-silver: #F5F5F7;
  --yc-gray-text: #86868B;
  --yc-gray-border: #D2D2D7;
  --yc-gray-dark: #1D1D1F;

  /* Semantic Colors */
  --yc-success: #34C759;
  --yc-error: #FF3B30;
  --yc-warning: #FF9500;

  /* Shadows */
  --yc-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --yc-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --yc-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

  /* Transitions */
  --yc-transition: 200ms ease;
}

/* Base Reset */
* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  color: var(--yc-gray-dark);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 24px;
  background-color: var(--yc-blue);
  color: white;
  font-weight: 500;
  font-size: 16px;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color var(--yc-transition), transform var(--yc-transition);
}

.btn-primary:hover {
  background-color: var(--yc-blue-hover);
}

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

.btn-primary:disabled {
  background-color: var(--yc-gray-border);
  cursor: not-allowed;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 24px;
  background-color: white;
  color: var(--yc-blue);
  font-weight: 500;
  font-size: 16px;
  border: 1.5px solid var(--yc-blue);
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color var(--yc-transition), transform var(--yc-transition);
}

.btn-secondary:hover {
  background-color: var(--yc-blue-light);
}

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

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background-color: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color var(--yc-transition);
}

.btn-icon:hover {
  background-color: var(--yc-silver);
}

/* Cards */
.card {
  background-color: white;
  border-radius: 16px;
  box-shadow: var(--yc-shadow-sm);
  padding: 20px;
}

.card-bordered {
  background-color: white;
  border: 1px solid var(--yc-gray-border);
  border-radius: 16px;
  padding: 20px;
}

/* Inputs */
.input {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  font-size: 16px;
  border: 1.5px solid var(--yc-gray-border);
  border-radius: 12px;
  background-color: white;
  transition: border-color var(--yc-transition), box-shadow var(--yc-transition);
}

.input:focus {
  outline: none;
  border-color: var(--yc-blue);
  box-shadow: 0 0 0 3px var(--yc-blue-light);
}

.input::placeholder {
  color: var(--yc-gray-text);
}

.input-error {
  border-color: var(--yc-error);
}

.input-error:focus {
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.2);
}

textarea.input {
  min-height: 120px;
  resize: vertical;
}

/* Labels */
.label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--yc-gray-dark);
  margin-bottom: 6px;
}

.label-hint {
  font-size: 13px;
  color: var(--yc-gray-text);
  margin-top: 4px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 9999px;
  background-color: var(--yc-silver);
  color: var(--yc-gray-text);
}

.badge-blue {
  background-color: var(--yc-blue-light);
  color: var(--yc-blue);
}

.badge-success {
  background-color: rgba(52, 199, 89, 0.15);
  color: var(--yc-success);
}

/* Progress Steps */
.progress-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.progress-step {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--yc-gray-border);
  transition: background-color var(--yc-transition), transform var(--yc-transition);
}

.progress-step.active {
  background-color: var(--yc-blue);
  transform: scale(1.25);
}

.progress-step.completed {
  background-color: var(--yc-blue);
}

/* Episode Card */
.episode-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  background-color: white;
  border-radius: 12px;
  border: 1px solid var(--yc-gray-border);
  transition: box-shadow var(--yc-transition);
}

.episode-card:hover {
  box-shadow: var(--yc-shadow-sm);
}

.episode-card-info {
  flex: 1;
  min-width: 0;
}

.episode-card-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--yc-gray-dark);
  margin: 0 0 2px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.episode-card-author {
  font-size: 14px;
  color: var(--yc-gray-text);
  margin: 0 0 4px 0;
}

.episode-card-meta {
  font-size: 12px;
  color: var(--yc-gray-text);
}

.episode-card-actions {
  display: flex;
  gap: 4px;
}

.feedback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background-color: var(--yc-silver);
  cursor: pointer;
  font-size: 18px;
  transition: background-color var(--yc-transition), transform var(--yc-transition);
}

.feedback-btn:hover {
  background-color: var(--yc-gray-border);
}

.feedback-btn:active {
  transform: scale(0.95);
}

.feedback-btn.selected-up {
  background-color: rgba(52, 199, 89, 0.2);
}

.feedback-btn.selected-down {
  background-color: rgba(255, 59, 48, 0.2);
}

/* Book Queue Item */
.book-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--yc-silver);
}

.book-item:last-child {
  border-bottom: none;
}

.book-item-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 12px;
  font-weight: 600;
  color: var(--yc-gray-text);
  background-color: var(--yc-silver);
  border-radius: 50%;
  flex-shrink: 0;
}

.book-item-info {
  flex: 1;
  min-width: 0;
}

.book-item-title {
  font-weight: 500;
  font-size: 15px;
  color: var(--yc-gray-dark);
  margin: 0 0 2px 0;
}

.book-item-author {
  font-size: 13px;
  color: var(--yc-gray-text);
  margin: 0;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--yc-silver);
  border-top-color: var(--yc-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-lg {
  width: 40px;
  height: 40px;
}

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

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background-color: var(--yc-gray-dark);
  color: white;
  font-size: 14px;
  font-weight: 500;
  border-radius: 12px;
  box-shadow: var(--yc-shadow-lg);
  animation: toast-in 0.3s ease, toast-out 0.3s ease 2.7s forwards;
  pointer-events: auto;
}

.toast-success {
  background-color: var(--yc-success);
}

.toast-error {
  background-color: var(--yc-error);
}

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

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

/* File Upload Zone */
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  border: 2px dashed var(--yc-gray-border);
  border-radius: 16px;
  background-color: var(--yc-silver);
  cursor: pointer;
  transition: border-color var(--yc-transition), background-color var(--yc-transition);
}

.upload-zone:hover {
  border-color: var(--yc-blue);
  background-color: var(--yc-blue-light);
}

.upload-zone.dragover {
  border-color: var(--yc-blue);
  background-color: var(--yc-blue-light);
}

.upload-zone-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.upload-zone-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--yc-gray-dark);
  margin-bottom: 4px;
}

.upload-zone-hint {
  font-size: 14px;
  color: var(--yc-gray-text);
}

/* RSS Copy Box */
.rss-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background-color: var(--yc-silver);
  border-radius: 12px;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 13px;
  word-break: break-all;
}

.rss-box-url {
  flex: 1;
  color: var(--yc-gray-dark);
}

/* App Icons Grid */
.app-icons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}

.app-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.app-icon img {
  width: 60px;
  height: 60px;
  border-radius: 12px;
}

.app-icon span {
  font-size: 11px;
  color: var(--yc-gray-text);
}

/* Layout Utilities */
.container {
  width: 100%;
  max-width: 1024px;
  margin: 0 auto;
  padding: 0 16px;
}

.container-sm {
  max-width: 480px;
}

/* Page Header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
}

.page-header-logo {
  height: 32px;
}

.page-header-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Avatar */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-lg {
  width: 64px;
  height: 64px;
}

/* Footer */
.site-footer {
  padding: 16px 0;
  border-top: 1px solid var(--yc-silver);
  background-color: white;
}

.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
}

.site-footer-links a {
  font-size: 13px;
  color: var(--yc-gray-text);
  text-decoration: none;
}

.site-footer-links a:hover {
  color: var(--yc-gray-dark);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--yc-gray-dark);
  margin: 0 0 8px 0;
}

.empty-state-text {
  font-size: 14px;
  color: var(--yc-gray-text);
  margin: 0;
}

/* Error Message */
.error-message {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background-color: rgba(255, 59, 48, 0.1);
  border: 1px solid var(--yc-error);
  border-radius: 12px;
  color: var(--yc-error);
  font-size: 14px;
}

/* Accessibility */
.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;
}

.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--yc-blue);
  color: white;
  padding: 8px 16px;
  z-index: 1001;
  text-decoration: none;
  font-weight: 500;
  border-radius: 0 0 8px 0;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

/* Character counter */
.char-counter {
  font-size: 12px;
  color: var(--yc-gray-text);
  text-align: right;
  margin-top: 4px;
}

.char-counter.text-red-500 {
  color: var(--yc-error);
}

/* Podcast Subscription Icons */
.podcast-icons {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}

.podcast-icon-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  padding: 4px;
  border-radius: 8px;
  transition: background-color var(--yc-transition);
}

.podcast-icon-btn:hover {
  background-color: var(--yc-silver);
}

.podcast-icon-btn span {
  font-size: 10px;
  color: var(--yc-gray-text);
}

/* Responsive */
@media (max-width: 479px) {
  /* Profile card: stack vertically on small screens */
  #profile-section .flex.items-start {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  #profile-section .podcast-icons {
    justify-content: center;
  }

  /* Tighter card padding */
  .card {
    padding: 14px;
  }

  /* Compact episode cards */
  .episode-card {
    padding: 10px 12px;
    gap: 8px;
  }

  .episode-card-title {
    font-size: 14px;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .episode-card-meta {
    font-size: 11px;
  }

  .feedback-btn {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }

  /* Book queue: tighter item padding */
  .book-item {
    padding: 6px 0;
    gap: 8px;
  }

  .book-item-title {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .book-item-author {
    font-size: 11px;
  }

  .book-item-number {
    width: 20px;
    height: 20px;
    font-size: 11px;
  }
}

@media (min-width: 768px) {
  .container {
    padding: 0 24px;
  }

  .card {
    padding: 24px;
  }
}
