/* ==================== Header Component ==================== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 17, 23, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  height: var(--header-height);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}

/* Logo */
.header-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  text-decoration: none;
  transition: transform var(--duration-fast) var(--ease-default);
}

.header-logo:hover {
  transform: scale(1.05);
  color: var(--text-primary);
}

/* Search Box */
.header-search {
  position: relative;
  flex: 0 1 400px;
}

.search-input {
  width: 100%;
  padding: 10px 40px 10px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: all var(--duration-normal) var(--ease-default);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(53, 160, 255, 0.1);
  width: 110%;
}

.search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 36px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: none;
}

.search-clear:hover {
  color: var(--text-primary);
}

.search-input:not(:placeholder-shown) ~ .search-clear {
  display: block;
}

/* Search suggestions dropdown */
.search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  display: none;
}

.search-suggestions.active {
  display: block;
}

.search-suggestion-item {
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--duration-fast);
  border-bottom: 1px solid var(--border-color);
}

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

.search-suggestion-item:hover,
.search-suggestion-item.selected {
  background: var(--bg-hover);
}

/* Header Controls */
.header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: all var(--duration-fast) var(--ease-default);
  font-size: 0.875rem;
}

.header-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.header-btn-icon {
  font-size: 1.25rem;
}

/* Badge for count (favorites, history) */
.header-btn-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: rgba(126, 195, 255, 0.2);
  color: var(--text-primary);
  font-size: 0.625rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  min-width: 16px;
  text-align: center;
  border: 1px solid rgba(126, 195, 255, 0.45);
}

/* Language dropdown */
.lang-dropdown {
  position: relative;
}

.lang-current {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 1000;
}

.lang-menu.active {
  display: block;
}

.lang-option {
  display: block;
  width: 100%;
  padding: 10px 16px;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast);
  border-bottom: 1px solid var(--border-color);
}

.lang-option:last-child {
  border-bottom: none;
}

.lang-option:hover,
.lang-option.active {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ==================== Footer Component ==================== */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: var(--space-2xl) 0 var(--space-lg);
  margin-top: var(--space-2xl);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.footer-section h3 {
  font-size: 1rem;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-links li {
  margin-bottom: var(--space-sm);
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--duration-fast);
  position: relative;
}

.footer-links a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--accent-primary);
  transition: width var(--duration-fast);
}

.footer-links a:hover {
  color: var(--accent-primary);
}

.footer-links a:hover::after {
  width: 100%;
}

.footer-bottom {
  text-align: center;
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ==================== Game Card Component ==================== */
.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--duration-normal) var(--ease-default);
  cursor: pointer;
  position: relative;
}

.game-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-xl);
  border-color: var(--accent-primary);
}

.game-card-image {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-secondary);
}

.game-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-normal) var(--ease-default);
}

.game-card:hover .game-card-image img {
  transform: scale(1.05);
}

.game-card-tags {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.game-card-body {
  padding: var(--space-md);
}

.game-card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-card-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.game-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-sm);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Generic card-based game link (SSR) */
.card.game-card {
  display: flex;
  flex-direction: column;
  padding: 0;
}

.card.game-card .card-cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-secondary);
  overflow: hidden;
}

.card.game-card .card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card.game-card .card-body {
  padding: var(--space-md);
}

/* ==================== Breadcrumb Component ==================== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.breadcrumb-item {
  color: var(--text-muted);
  transition: color var(--duration-fast);
}

.breadcrumb-item:hover {
  color: var(--accent-primary);
}

.breadcrumb-separator {
  color: var(--text-muted);
}

.breadcrumb-item.active {
  color: var(--text-primary);
  font-weight: 600;
  pointer-events: none;
}

/* ==================== Category Navigation ==================== */
.category-nav {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-lg) 0;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.category-nav::-webkit-scrollbar {
  height: 6px;
}

.category-nav::-webkit-scrollbar-track {
  background: transparent;
}

.category-nav::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}

.category-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-default);
  white-space: nowrap;
}

.category-btn:hover {
  border-color: var(--accent-primary);
  background: var(--bg-hover);
  color: var(--text-primary);
}

.category-btn.active {
  border-color: var(--accent-primary);
  background: var(--accent-primary);
  color: #0b0c10;
}

/* ==================== Pagination Component ==================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
}

.pagination-btn {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-default);
  min-width: 40px;
  text-align: center;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.pagination-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #0b0c10;
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-ellipsis {
  color: var(--text-muted);
  padding: 0 var(--space-xs);
}

/* ==================== Modal/Overlay Components ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-lg);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-normal) var(--ease-default);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95);
  transition: transform var(--duration-normal) var(--ease-default);
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color var(--duration-fast);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-lg);
}

.modal-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

/* ==================== Slide Panel (Favorites/History) ==================== */
.slide-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--sidebar-width);
  max-width: 90vw;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-xl);
  z-index: 999;
  transform: translateX(100%);
  transition: transform var(--duration-normal) var(--ease-default);
  display: flex;
  flex-direction: column;
}

.slide-panel.active {
  transform: translateX(0);
}

.slide-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-color);
}

.slide-panel-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.slide-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
}

.slide-panel-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  margin-bottom: var(--space-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
}

.slide-panel-item:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}

.slide-panel-item-thumb {
  width: 80px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

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

.slide-panel-item-title {
  font-weight: 600;
  margin-bottom: var(--space-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slide-panel-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.slide-panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  text-align: center;
  color: var(--text-muted);
}

.slide-panel-empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

/* ==================== Toast Notification ==================== */
.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transform: translateX(calc(100% + var(--space-lg)));
  transition: transform var(--duration-normal) var(--ease-default);
}

.toast.active {
  transform: translateX(0);
}

.toast-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.toast-success {
  border-left: 3px solid var(--success);
}

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

.toast-error {
  border-left: 3px solid var(--danger);
}

.toast-error .toast-icon {
  color: var(--danger);
}

.toast-warning {
  border-left: 3px solid var(--warning);
}

.toast-warning .toast-icon {
  color: var(--warning);
}

.toast-message {
  flex: 1;
}

/* ==================== Loading States ==================== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 25%,
    var(--bg-card) 50%,
    var(--bg-secondary) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 1em;
  margin-bottom: var(--space-xs);
}

.skeleton-card {
  height: 300px;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.spinner {
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 0.8s linear infinite;
}

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

/* ==================== Brand Section (Home page) ==================== */
.brand-section {
  text-align: center;
  padding: var(--space-2xl) 0;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  margin: var(--space-xl) 0;
}

.brand-section h2 {
  font-size: 1.5rem;
  margin-bottom: var(--space-sm);
}

.brand-section p {
  color: var(--text-muted);
  margin: 0;
}

/* ==================== Responsive Adjustments ==================== */
@media (max-width: 768px) {
  .header-search {
    flex: 1;
    max-width: none;
  }

  .search-input:focus {
    width: 100%;
  }

  .header-controls {
    gap: var(--space-xs);
  }

  .header-btn span {
    display: none;
  }
  
  /* Hide Boss Key on mobile as it's not relevant */
  .header-btn[data-boss-key],
  button[data-boss-key] {
    display: none !important;
  }

  .slide-panel {
    width: 100%;
    max-width: 100%;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }
}
