/**
 * ExamFlo Component Styles
 * Reusable component classes with mobile-first responsive design
 */

/* ========================================
   BUTTONS
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
  background: white;
  color: #3b82f6;
  border: 2px solid #3b82f6;
}

.btn-secondary:hover:not(:disabled) {
  background: #3b82f6;
  color: white;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

@media (max-width: 640px) {
  .btn {
    width: 100%;
    padding: 0.875rem 1rem;
  }
  
  .btn-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
  }
}

@media (min-width: 641px) {
  .btn-group {
    display: flex;
    gap: 1rem;
    align-items: center;
  }
}

/* Header CTA buttons: ensure Login and Sign Up match widths on desktop */
.header-cta {
  min-width: 9.5rem; /* ~152px */
  display: inline-flex;
  justify-content: center;
}

/* ========================================
   CARDS
   ======================================== */

.card {
  background: white;
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

/* Result / Test cards: subtle lift and shadow on hover */
.result-card { transition: transform 250ms ease, box-shadow 250ms ease, border-color 250ms ease; }
.result-card:hover { transform: translateY(-6px); box-shadow: 0 8px 20px rgba(15,23,42,0.09); border-color: rgba(29,78,216,0.12); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.card-body {
  flex: 1;
}

@media (max-width: 767px) {
  .card {
    padding: 1rem;
    border-radius: 0.75rem;
  }
  
  .card-title {
    font-size: 1.125rem;
  }
}

/* ========================================
   TEST CARD
   ======================================== */

.test-card {
  background: white;
  border-radius: 1rem;
  padding: 1.25rem;
  border: 1px solid #e5e7eb;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.test-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.15);
  transform: translateY(-4px);
}

.test-card-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.test-card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.test-card-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.test-card-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid #f3f4f6;
}

@media (max-width: 640px) {
  .test-card {
    padding: 1rem;
  }
  
  .test-card-title {
    font-size: 1rem;
  }
  
  .test-card-meta {
    gap: 0.75rem;
    font-size: 0.8125rem;
  }
}

/* ========================================
   VIDEO CARD
   ======================================== */

.video-card {
  background: white;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.video-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  transform: translateY(-4px);
}

.video-thumbnail {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 aspect ratio */
  background: #f3f4f6;
  overflow: hidden;
}

.video-thumbnail img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-play-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background: rgba(59, 130, 246, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
  transition: all 0.3s ease;
}

.video-card:hover .video-play-button {
  background: #3b82f6;
  transform: translate(-50%, -50%) scale(1.1);
}

.video-content {
  padding: 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.video-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.video-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: auto;
}

@media (max-width: 640px) {
  .video-content {
    padding: 1rem;
  }
  
  .video-title {
    font-size: 1rem;
  }
  
  .video-play-button {
    width: 50px;
    height: 50px;
    font-size: 1.25rem;
  }
}

/* ========================================
   EBOOK CARD
   ======================================== */

.ebook-card {
  background: white;
  border-radius: 1rem;
  padding: 1.25rem;
  border: 1px solid #e5e7eb;
  transition: all 0.3s ease;
  display: flex;
  gap: 1rem;
}

.ebook-card:hover {
  border-color: #10b981;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.15);
}

.ebook-cover {
  flex-shrink: 0;
  width: 80px;
  height: 110px;
  border-radius: 0.5rem;
  overflow: hidden;
  background: #f3f4f6;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ebook-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ebook-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.ebook-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.ebook-author {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 0.75rem;
}

.ebook-actions {
  margin-top: auto;
  display: flex;
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .ebook-card {
    padding: 1rem;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  
  .ebook-cover {
    width: 100px;
    height: 140px;
  }
  
  .ebook-content {
    align-items: center;
  }
  
  .ebook-actions {
    width: 100%;
    flex-direction: column;
  }
}

/* ========================================
   STATS/KPI CARDS
   ======================================== */

.stat-card {
  background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid #e5e7eb;

/* helper to hide scrollbars cross-browser for horizontal scrollers */
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
.scrollbar-hide::-webkit-scrollbar { height: 0; display: none; }
  transition: all 0.3s ease;
}

.stat-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.1);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: 0.875rem;
  color: #6b7280;
  font-weight: 500;
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8125rem;
  margin-top: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
}

.stat-change.positive {
  color: #10b981;
  background: #d1fae5;
}

.stat-change.negative {
  color: #ef4444;
  background: #fee2e2;
}

@media (max-width: 640px) {
  .stat-card {
    padding: 1rem;
  }
  
  .stat-value {
    font-size: 1.75rem;
  }
  
  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }
}

/* ========================================
   BADGES
   ======================================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.875rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
}

.badge-primary {
  background: #dbeafe;
  color: #1e40af;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-sm {
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
}

/* ========================================
   SEARCH BAR
   ======================================== */

.search-bar {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 0.875rem 1rem 0.875rem 3rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  font-size: 1.25rem;
}

@media (max-width: 640px) {
  .search-input {
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    font-size: 0.9375rem;
  }
  
  .search-icon {
    left: 0.875rem;
    font-size: 1.125rem;
  }
}

/* ========================================
   FILTER SECTION
   ======================================== */

.filter-section {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  padding: 1rem;
  background: #f9fafb;
  border-radius: 0.75rem;
  margin-bottom: 1.5rem;
}

.filter-select {
  padding: 0.625rem 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 140px;
}

.filter-select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

@media (max-width: 640px) {
  .filter-section {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-select {
    width: 100%;
  }
}

/* ========================================
   DARK MODE COMPONENT ADJUSTMENTS
   ======================================== */

[data-theme="dark"] .card,
[data-theme="dark"] .test-card,
[data-theme="dark"] .video-card,
[data-theme="dark"] .ebook-card,
[data-theme="dark"] .stat-card {
  background: #1f2937;
  border-color: #374151;
}

[data-theme="dark"] .search-input,
[data-theme="dark"] .filter-select {
  background: #1f2937;
  border-color: #374151;
  color: #f9fafb;
}

[data-theme="dark"] .btn-secondary {
  background: #1f2937;
  border-color: #3b82f6;
}

[data-theme="dark"] .filter-section {
  background: #111827;
}

/* ========================================
   PREMIUM USER AVATAR STYLES
   ======================================== */

/* Premium avatar button with animated gradient ring */
.premium-avatar-button {
  position: relative;
  animation: premium-pulse 2s ease-in-out infinite;
}

.premium-avatar-button::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b, #d97706, #fbbf24);
  background-size: 200% 200%;
  -webkit-mask: 
    linear-gradient(#fff 0 0) content-box, 
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: premium-rotate 3s linear infinite;
  z-index: -1;
}

@keyframes premium-rotate {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes premium-pulse {
  0%, 100% {
    filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.5));
  }
  50% {
    filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.8));
  }
}

/* Premium avatar wrapper for mobile */
.premium-avatar-wrapper {
  position: relative;
  animation: premium-pulse-mobile 2s ease-in-out infinite;
}

.premium-avatar-wrapper::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  padding: 2px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b, #d97706, #fbbf24);
  background-size: 200% 200%;
  -webkit-mask: 
    linear-gradient(#fff 0 0) content-box, 
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: premium-rotate 3s linear infinite;
  z-index: 0;
}

@keyframes premium-pulse-mobile {
  0%, 100% {
    filter: drop-shadow(0 0 3px rgba(251, 191, 36, 0.4));
  }
  50% {
    filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.7));
  }
}

/* Ensure avatar stays above the ring */
.premium-avatar-button > div,
.premium-avatar-wrapper > div {
  position: relative;
  z-index: 1;
}

/* Premium badge styles */
.premium-badge {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: white;
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(251, 191, 36, 0.3);
}

/* Crown icon animation */
@keyframes crown-bounce {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-2px) rotate(-5deg);
  }
}

.premium-avatar-button:hover .crown-icon,
.premium-avatar-wrapper:hover .crown-icon {
  animation: crown-bounce 0.6s ease-in-out;
}