/**
 * Main Stylesheet - Layout, Typography, and Base Styles
 */

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: 'Oswald', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  letter-spacing: 0.5px;
  min-width: 1400px;
  /* Loopable rusty background tile */
  background-image: url('../assets/icons/loopable_background_tile_1.png');
  background-repeat: repeat;
  background-size: auto;
  background-position: 0 0;
  position: relative;
}

/* Subtle overlay for the tiled background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(26, 26, 26, 0.75);
  pointer-events: none;
  z-index: 0;
  backdrop-filter: blur(0.5px);
}

/* Ensure content appears above the overlay */
body > * {
  position: relative;
  z-index: 1;
}

/* Header */
.app-header {
  background-color: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
  padding: 1rem 2rem;
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px var(--shadow);
  /* Loopable header background tile */
  background-image: url('../assets/icons/loopable_background_tile_2.png');
  background-repeat: repeat;
  background-size: auto;
  background-position: 0 0;
}

/* Subtle overlay for header background */
.app-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(45, 45, 45, 0.7);
  pointer-events: none;
  z-index: 0;
}

/* Ensure header content appears above overlay */
.app-header > * {
  position: relative;
  z-index: 1;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.2rem;
}

.app-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: center;
  grid-column: 2;
}

.app-title-banner {
  max-height: 160px;
  width: auto;
  max-width: 800px;
  object-fit: contain;
  grid-column: 2;
  display: block;
  margin: 0 auto;
  /* Blend the banner with dark theme */
  filter: brightness(0.95) contrast(1.1);
  background-color: transparent;
  border-radius: 8px;
  padding: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Status Bar - Hidden */
.status-bar {
  display: none;
}

/* App Tabs */
.app-tabs {
  background-color: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
  padding: 0 2rem;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) var(--bg-secondary);
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 89;
  margin-top: 0;
}

.app-tabs::-webkit-scrollbar {
  height: 6px;
}

.app-tabs::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

.app-tabs::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

/* Gang Tabs */
.gang-tabs {
  background-color: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
  border-left: 2px solid var(--border-color);
  border-right: 2px solid var(--border-color);
  padding: 0.75rem 0.5rem 0.3rem 0.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.05rem;
  row-gap: 0.5rem;
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 88;
  max-width: 950px;
  margin: 0 auto;
}

.gang-tabs::-webkit-scrollbar {
  height: 4px;
}

.gang-tabs::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

.gang-tabs::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

/* Main Content */
.main-content {
  position: relative;
  overflow: visible;
}

#gang-checker-content {
  position: relative;
  overflow: visible;
}

.gang-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  min-height: calc(100vh - 300px);
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 1000;
  color: var(--text-primary);
}

.loading-overlay.hidden {
  display: none;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--bg-tertiary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Error Message */
.error-message {
  position: fixed;
  top: 20px;
  right: 20px;
  background-color: var(--error);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--shadow-heavy);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 400px;
  z-index: 1001;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.error-icon {
  font-size: 1.25rem;
}

.error-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  margin-left: auto;
  opacity: 0.8;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.error-close:hover {
  opacity: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
  .app-header {
    padding: 1rem;
  }

  .header-content {
    justify-content: center;
  }

  .app-title {
    font-size: 1.5rem;
  }

  .app-tabs {
    padding: 0 1rem;
    top: 140px;
  }

  .gang-tabs {
    padding: 0 1rem;
    top: 194px;
  }

  .gang-content {
    padding: 1rem;
  }

  .error-message {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .app-title {
    font-size: 1.25rem;
  }
}
