* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #E52D1D;
  --primary-dark: #B82218;
  --secondary: #FDC233;
  --danger: #E52D1D;
  --danger-dark: #B82218;
  --background: #F5F5F4;
  --surface: #ffffff;
  --text: #2F1B0D;
  --text-secondary: #191816;
  --border: #e2e8f0;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--background);
  min-height: 100vh;
  color: var(--text);
}

.container {
  max-width: 1400px;
  margin: 0 auto;
}

/* Top Navigation */
.top-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.nav-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.app-logo {
  height: 50px;
  width: auto;
}

.logo-text {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-section h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}

.badge {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.025em;
}

.user-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-edit-profile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--background);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-edit-profile:hover {
  background: var(--surface);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-edit-profile svg {
  width: 14px;
  height: 14px;
}

/* Hero Section */
.hero-section {
  background: linear-gradient(135deg, #E52D1D 0%, #FDC233 100%);
  border-radius: 1.5rem;
  padding: 3rem 2rem;
  margin: 0 2rem 2rem 2rem;
  color: white;
  box-shadow: var(--shadow-lg);
}

.hero-content h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: white;
}

.hero-content > p {
  font-size: 1.125rem;
  opacity: 0.95;
  margin-bottom: 2rem;
}

.share-link-container {
  max-width: 700px;
}

.share-link-wrapper {
  display: flex;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.15);
  padding: 0.5rem;
  border-radius: 0.75rem;
  backdrop-filter: blur(10px);
}

#share-link {
  flex: 1;
  background: white;
  border: none;
  padding: 0.875rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  color: var(--text);
  font-family: 'Monaco', 'Courier New', monospace;
}

.btn-copy {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--secondary);
  color: white;
  border: none;
  padding: 0.875rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-copy:hover {
  background: #E5A31A;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(253, 194, 51, 0.4);
}

/* Content Grid */
.content-grid {
  padding: 0 2rem;
  margin-bottom: 3rem;
}

.card {
  background: var(--surface);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-header h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.card-header p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* Add Video Layout - Two Column */
.add-video-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 2rem;
  align-items: start;
}

.add-video-form {
  display: flex;
  flex-direction: column;
  padding-top: 0.25rem;
}

/* Form Styles */
.form-group {
  margin-bottom: 1.5rem;
}

label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  color: var(--text);
  font-weight: 500;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

label svg {
  color: var(--primary);
}

input[type="text"] {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  font-size: 1rem;
  transition: all 0.2s;
  font-family: inherit;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(229, 45, 29, 0.1);
}

.btn {
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(229, 45, 29, 0.5);
}

.btn-danger {
  background: var(--danger);
  color: white;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-danger:hover {
  background: var(--danger-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* Popular Videos Compact */
.popular-videos-compact {
  display: flex;
  flex-direction: column;
  border-left: 3px solid var(--border);
  padding-left: 2rem;
  margin-top: -0.5rem;
}

.popular-header {
  margin-bottom: 0.875rem;
}

.popular-header h4 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.popular-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.popular-videos-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  overflow-y: auto;
  max-height: 400px;
  padding-right: 0.5rem;
}

.popular-videos-list::-webkit-scrollbar {
  width: 6px;
}

.popular-videos-list::-webkit-scrollbar-track {
  background: var(--background);
  border-radius: 3px;
}

.popular-videos-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.popular-videos-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

.popular-video-item {
  display: grid;
  grid-template-columns: 1.5rem 50px 1fr auto;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem;
  background: var(--background);
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.popular-video-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(229, 45, 29, 0.1);
}

.popular-rank {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
}

.popular-thumbnail {
  width: 50px;
  height: 38px;
  object-fit: cover;
  border-radius: 0.25rem;
  border: 1px solid var(--border);
}

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

.popular-title {
  font-size: 0.813rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.125rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}

.popular-count {
  font-size: 0.688rem;
  color: var(--text-secondary);
}

.btn-add-popular {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-add-popular:hover {
  background: var(--primary-dark);
  transform: scale(1.1);
}

.btn-add-popular svg {
  width: 14px;
  height: 14px;
}

.loading-popular,
.empty-popular {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  color: var(--text-secondary);
}

.mini-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 0.5rem;
}

.empty-popular p {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.empty-popular small {
  font-size: 0.75rem;
}

/* Messages */
.message {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 0.5rem;
  display: none;
  font-weight: 500;
}

.message.show {
  display: block;
  animation: slideIn 0.3s ease-out;
}

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

.message.success {
  background: #d1fae5;
  color: #065f46;
  border: 2px solid #10b981;
}

.message.error {
  background: #fee2e2;
  color: #991b1b;
  border: 2px solid #ef4444;
}

/* Library Section */
.library-section {
  padding: 0 2rem 3rem 2rem;
}

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

.section-header h2 {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.section-header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

.video-count-badge {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 1rem;
  white-space: nowrap;
}

.video-count-badge span {
  font-size: 1.5rem;
  font-weight: 700;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.video-card {
  background: var(--surface);
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: all 0.3s;
}

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

.video-thumbnail {
  position: relative;
  padding-bottom: 56.25%;
  background: linear-gradient(135deg, #E52D1D 0%, #FDC233 100%);
  overflow: hidden;
}

.video-thumbnail img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.video-card:hover .video-thumbnail img {
  transform: scale(1.05);
}

.video-info {
  padding: 1.25rem;
}

.video-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
  word-wrap: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 3rem;
}

.video-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.video-id {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: 'Monaco', 'Courier New', monospace;
  background: var(--background);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
  background: var(--surface);
  border-radius: 1rem;
  border: 2px dashed var(--border);
}

.empty-state p {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.empty-state small {
  color: var(--text-secondary);
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #E52D1D 0%, #FDC233 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  z-index: 9999;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 5px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1.5rem;
}

.loading-screen p {
  font-size: 1.125rem;
  font-weight: 500;
}

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

/* Clerk Authentication Container */
.clerk-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #E52D1D 0%, #FDC233 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  padding: 2rem;
}

.signin-wrapper {
  max-width: 500px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.signin-header {
  text-align: center;
  margin-bottom: 2rem;
  color: white;
}

.signin-logo {
  height: 120px;
  width: auto;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
}

.signin-header h1 {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.signin-header p {
  font-size: 1.25rem;
  opacity: 0.95;
}

#sign-in {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* Onboarding Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 2rem;
}

.modal-content {
  background: var(--surface);
  border-radius: 1.5rem;
  padding: 3rem;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
  text-align: center;
  margin-bottom: 2rem;
}

.modal-header h2 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.modal-header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

.onboarding-form {
  display: flex;
  flex-direction: column;
}

.onboarding-form .form-group:last-of-type {
  margin-bottom: 2rem;
}

.onboarding-form small {
  display: block;
  margin-top: 0.375rem;
  color: var(--text-secondary);
  font-size: 0.813rem;
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .add-video-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .popular-videos-compact {
    border-left: none;
    border-top: 3px solid var(--border);
    padding-left: 0;
    padding-top: 2rem;
  }
}

@media (max-width: 768px) {
  .top-nav {
    padding: 1rem;
  }

  .logo-section h1 {
    font-size: 1.5rem;
  }

  .badge {
    font-size: 0.625rem;
    padding: 0.25rem 0.5rem;
  }

  .hero-section {
    padding: 2rem 1.5rem;
    margin: 0 1rem 1.5rem 1rem;
  }

  .hero-content h2 {
    font-size: 1.5rem;
  }

  .hero-content > p {
    font-size: 1rem;
  }

  .share-link-wrapper {
    flex-direction: column;
    gap: 0.5rem;
  }

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

  .content-grid {
    padding: 0 1rem;
    margin-bottom: 2rem;
  }

  .card {
    padding: 1.5rem;
  }

  .library-section {
    padding: 0 1rem 2rem 1rem;
  }

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

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .video-count-badge {
    align-self: flex-start;
  }

  .add-video-layout {
    grid-template-columns: 1fr;
  }

  .popular-videos-compact {
    border-left: none;
    border-top: 3px solid var(--border);
    padding-left: 0;
    padding-top: 1.5rem;
  }

  .popular-videos-list {
    max-height: 300px;
  }
}
