/* =============================================
   components.css - Reusable UI Components
   Java Interview Questions Reader
   ============================================= */

/* --- Hero Banner (Home Page) --- */
.hero-banner {
  background: linear-gradient(145deg, #fff7ed 0%, #ffffff 50%, #eff6ff 100%);
  padding: var(--space-6) var(--space-4);
  margin-bottom: var(--space-4);
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--color-border);
}

.hero-banner::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 30% 40%,
    rgba(234,111,10,0.07) 0%,
    transparent 60%
  );
  pointer-events: none;
}

.hero-banner::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle,
    rgba(96,165,250,0.08) 0%,
    transparent 70%
  );
  pointer-events: none;
}

.hero-label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--color-accent-orange);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.hero-label::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 2px;
  background: var(--color-accent-orange);
  border-radius: 2px;
}

.hero-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  line-height: 1.2;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.hero-title span {
  background: linear-gradient(135deg, var(--color-accent-orange), var(--color-accent-yellow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-5);
}

.hero-stats {
  display: flex;
  gap: var(--space-4);
}

.hero-stat {
  display: flex;
  flex-direction: column;
}

.hero-stat-num {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--color-text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hero-stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* --- Search Bar --- */
.search-wrapper {
  padding: 0 var(--space-4) var(--space-4);
  position: sticky;
  top: var(--nav-height);
  z-index: calc(var(--z-sticky) - 1);
  background: linear-gradient(
    to bottom,
    #ffffff 0%,
    #ffffff 80%,
    transparent 100%
  );
  padding-top: var(--space-3);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0 var(--space-4);
  height: 44px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-bar:focus-within {
  border-color: var(--color-accent-orange);
  box-shadow: 0 0 0 3px var(--color-accent-orange-dim);
}

.search-icon {
  color: var(--color-text-muted);
  font-size: 16px;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--color-text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  caret-color: var(--color-accent-orange);
}

.search-input::placeholder {
  color: var(--color-text-muted);
}

.search-clear {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--color-bg-hover);
  border: none;
  color: var(--color-text-muted);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  flex-shrink: 0;
}

.search-clear.visible { display: flex; }

/* --- Category Grid --- */
.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  padding: var(--space-4);
}

/* --- Category Card --- */
.category-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  display: block;
  box-shadow: var(--shadow-sm);
}

.category-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.category-card:hover,
.category-card:active {
  border-color: var(--color-border-accent);
  background: #fff8f3;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.category-card:hover::before,
.category-card:active::before {
  opacity: 1;
}

/* Color accents per category */
.card-color-orange::before { background: var(--color-accent-orange); }
.card-color-blue::before   { background: var(--color-accent-blue); }
.card-color-green::before  { background: var(--color-accent-green); }
.card-color-purple::before { background: var(--color-accent-purple); }
.card-color-yellow::before { background: var(--color-accent-yellow); }
.card-color-red::before    { background: var(--color-accent-red); }

.category-emoji {
  font-size: 24px;
  margin-bottom: var(--space-2);
  display: block;
}

.category-num {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  margin-bottom: var(--space-1);
  letter-spacing: 0.05em;
}

.category-name {
  font-size: var(--text-sm);
  font-weight: var(--font-semi);
  color: var(--color-text-primary);
  line-height: 1.3;
  margin-bottom: var(--space-2);
}

.category-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-3);
}

.category-progress-bar {
  height: 3px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  flex: 1;
  margin-right: var(--space-2);
  overflow: hidden;
}

.category-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-accent-orange);
  width: 0%;
  transition: width 0.8s ease;
}

.category-progress-text {
  font-size: 10px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* --- Tag Chips --- */
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 0 var(--space-4) var(--space-3);
}

.tag-chip {
  font-size: var(--text-xs);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.tag-chip:hover,
.tag-chip.active {
  border-color: var(--color-accent-orange);
  background: var(--color-accent-orange-dim);
  color: var(--color-accent-orange);
}

/* --- Progress Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-weight: var(--font-medium);
  white-space: nowrap;
}

.badge-orange {
  background: var(--color-accent-orange-dim);
  color: var(--color-accent-orange);
  border: 1px solid rgba(249,115,22,0.3);
}

.badge-blue {
  background: var(--color-accent-blue-dim);
  color: var(--color-accent-blue);
  border: 1px solid rgba(96,165,250,0.3);
}

.badge-green {
  background: var(--color-accent-green-dim);
  color: var(--color-accent-green);
  border: 1px solid rgba(52,211,153,0.3);
}

/* --- Difficulty Stars --- */
.difficulty {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}

.star {
  font-size: 11px;
  opacity: 0.3;
}

.star.lit {
  opacity: 1;
  filter: drop-shadow(0 0 2px rgba(251,191,36,0.6));
}

/* --- Toast Notification --- */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-bar) + var(--space-4));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1f2937;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  color: #f9fafb;
  box-shadow: var(--shadow-lg);
  z-index: var(--z-toast);
  opacity: 0;
  transition: all var(--transition-normal);
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Empty State --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-4);
  text-align: center;
  color: var(--color-text-muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-title {
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.empty-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* --- Bookmark List Item --- */
.bookmark-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.bookmark-item:hover {
  background: var(--color-bg-hover);
}

.bookmark-item-icon {
  width: 40px;
  height: 40px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.bookmark-item-content {
  flex: 1;
  min-width: 0;
}

.bookmark-item-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semi);
  color: var(--color-text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bookmark-item-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.bookmark-remove {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.bookmark-remove:hover {
  background: rgba(248,113,113,0.15);
  color: var(--color-accent-red);
}

/* --- Settings List --- */
.settings-group {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.settings-group-title {
  font-size: var(--text-xs);
  font-weight: var(--font-semi);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.settings-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.settings-item:last-child { border-bottom: none; }
.settings-item:hover { background: var(--color-bg-hover); }

.settings-item-icon {
  width: 32px;
  height: 32px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.settings-item-info { flex: 1; }

.settings-item-title {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-primary);
}

.settings-item-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 1px;
}

.settings-item-value {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

/* --- Toggle Switch --- */
.toggle {
  width: 44px;
  height: 26px;
  background: var(--color-bg-hover);
  border-radius: var(--radius-full);
  position: relative;
  cursor: pointer;
  transition: background var(--transition-normal);
  flex-shrink: 0;
  border: 1px solid var(--color-border);
}

.toggle.on {
  background: var(--color-accent-orange);
  border-color: var(--color-accent-orange);
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: var(--radius-full);
  transition: transform var(--transition-normal);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}


.toggle.on .toggle-thumb {
  transform: translateX(18px);
}

/* --- Card Quiz Button (首頁章節卡片測驗按鈕) --- */
.card-quiz-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-accent-orange-dim);
  border: 1px solid rgba(234,111,10,0.25);
  border-radius: var(--radius-md);
  color: var(--color-accent-orange);
  font-size: var(--text-xs);
  font-weight: var(--font-semi);
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.02em;
}

.card-quiz-btn:hover,
.card-quiz-btn:active {
  background: var(--color-accent-orange);
  color: #fff;
  border-color: var(--color-accent-orange);
  transform: none;
}
