:root {
  /* Dark mode (default) */
  --primary-color: #1a1a2e;
  --secondary-color: #3498db;
  --accent-color: #e94560;
  --bg-color: #0f0f1e;
  --card-bg: #16213e;
  --text-color: #eef1f7;
  --text-light: #94a1b2;
  --border-color: rgba(255, 255, 255, 0.1);
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 8px 16px rgba(0, 0, 0, 0.4);
  --input-bg: #1a1a2e;
  --input-border: rgba(255, 255, 255, 0.2);
}

/* Light mode theme */
body.light-mode {
  --primary-color: #2c3e50;
  --secondary-color: #3498db;
  --accent-color: #e74c3c;
  --bg-color: #ecf0f1;
  --card-bg: #ffffff;
  --text-color: #2c3e50;
  --text-light: #7f8c8d;
  --border-color: #bdc3c7;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
  --input-bg: #ffffff;
  --input-border: #bdc3c7;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
}

/* Navigation */
.navbar {
  background-color: var(--primary-color);
  color: white;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.5rem;
  font-weight: bold;
}

.vinyl-icon {
  font-size: 1.8rem;
}

.nav-menu {
  display: flex;
  list-style: none;
  gap: 2rem;
}

.nav-menu a {
  color: white;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: background-color 0.3s;
}

.nav-menu a:hover,
.nav-menu a.active {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Navigation controls */
.nav-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-input {
  padding: 0.5rem 1rem;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  background-color: var(--input-bg);
  color: var(--text-color);
  font-size: 0.95rem;
  width: 200px;
  transition: all 0.3s;
}

.search-input:focus {
  outline: none;
  border-color: var(--secondary-color);
  width: 250px;
}

.search-input::placeholder {
  color: var(--text-light);
  opacity: 0.7;
}

.sort-select {
  padding: 0.5rem 1rem;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  background-color: var(--input-bg);
  color: var(--text-color);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s;
}

.sort-select:focus {
  outline: none;
  border-color: var(--secondary-color);
}

.theme-toggle {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.3s;
}

.theme-toggle:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.sync-btn {
  background-color: var(--secondary-color);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.3s;
}

.sync-btn:hover {
  background-color: #2980b9;
  transform: scale(1.05);
}

.sync-btn.syncing .sync-icon {
  animation: spin 1s linear infinite;
}

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

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

.header {
  margin-bottom: 2rem;
}

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

.stats {
  display: flex;
  gap: 2rem;
  color: var(--text-light);
  font-size: 0.9rem;
}

/* Loading */
.loading {
  text-align: center;
  padding: 4rem 2rem;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--border-color);
  border-top-color: var(--secondary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

/* Error */
.error {
  background-color: #fee;
  color: var(--accent-color);
  padding: 1rem;
  border-radius: 4px;
  margin: 1rem 0;
  border-left: 4px solid var(--accent-color);
}

.hidden {
  display: none !important;
}

/* Vinyl Grid */
.vinyl-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.5rem;
  margin-top: 2rem;
}

/* Tablet */
@media (max-width: 1024px) {
  .vinyl-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Mobile */
@media (max-width: 768px) {
  .vinyl-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .container {
    padding: 1rem;
  }

  .header h1 {
    font-size: 2rem;
  }

  .nav-container {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .nav-brand {
    font-size: 1.2rem;
  }

  .vinyl-icon {
    font-size: 1.4rem;
  }

  .nav-menu {
    gap: 0.5rem;
    order: 3;
    width: 100%;
    margin-top: 0.5rem;
  }

  .nav-menu a {
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
  }

  .nav-controls {
    flex: 1;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: nowrap;
  }

  .search-input {
    width: 100%;
    max-width: none;
    font-size: 0.9rem;
    padding: 0.4rem 0.75rem;
    order: 4;
    margin-top: 0.5rem;
  }

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

  .sort-select {
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
    min-width: 100px;
  }

  .theme-toggle,
  .sync-btn {
    padding: 0.4rem 0.75rem;
    font-size: 1rem;
  }
}

/* Vinyl Card */
.vinyl-card {
  cursor: pointer;
  background-color: var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
}

.vinyl-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px);
}

.vinyl-card:active {
  transform: translateY(-2px);
}

.vinyl-card-image-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background-color: #f0f0f0;
}

.vinyl-card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s ease;
}

.vinyl-card-details {
  position: relative;
  padding: 1rem;
  background-color: var(--card-bg);
  border-top: 1px solid var(--border-color);
}

.vinyl-card-info-icon {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  color: var(--text-color);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 1;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.vinyl-card-info-icon:hover {
  background: rgba(0, 0, 0, 0.1);
  transform: scale(1.1);
}

.vinyl-card-info-icon:active {
  transform: scale(0.95);
  background: rgba(0, 0, 0, 0.15);
}

/* Password Modal */
.password-modal-content {
  max-width: 400px;
  width: 90%;
}

#password-modal .modal-overlay {
  background-color: rgba(0, 0, 0, 0.05);
}

.password-modal-body {
  padding: 2rem;
  text-align: center;
}

.password-modal-body h2 {
  margin: 0 0 1rem 0;
  color: var(--text-color);
}

.password-modal-body p {
  margin: 0 0 1.5rem 0;
  color: var(--text-secondary);
}

.password-input {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  background: var(--card-bg);
  color: var(--text-color);
  margin-bottom: 1.5rem;
  box-sizing: border-box;
}

.password-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.password-modal-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 100px;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--text-color);
  border: 2px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.vinyl-card-artist {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vinyl-card-title {
  font-size: 0.85rem;
  color: var(--text-color);
  margin-bottom: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vinyl-card-meta {
  font-size: 0.75rem;
  color: var(--text-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Placeholder for missing images */
.vinyl-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem;
  text-align: center;
}

.vinyl-card-placeholder .icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.vinyl-card-placeholder .artist {
  font-size: 0.9rem;
  font-weight: bold;
  margin-bottom: 0.3rem;
}

.vinyl-card-placeholder .title {
  font-size: 0.8rem;
  opacity: 0.9;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
}

.modal-content {
  position: relative;
  background-color: var(--card-bg);
  border-radius: 8px;
  max-width: 900px;
  max-height: 90vh;
  width: 90%;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: var(--text-color);
  z-index: 10;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.3s;
}

.modal-close:hover {
  background-color: var(--border-color);
}

.modal-body {
  display: flex;
  gap: 2rem;
  padding: 2rem;
}

.modal-images {
  flex: 1;
}

.modal-images img {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.modal-thumbnails {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.modal-thumbnail {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.3s;
}

.modal-thumbnail:hover,
.modal-thumbnail.active {
  border-color: var(--secondary-color);
}

.modal-info {
  flex: 1;
}

.modal-info h2 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.modal-artist {
  font-size: 1.2rem;
  color: var(--text-light);
  margin-bottom: 1.5rem;
}

.modal-details {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.detail-row {
  display: flex;
  gap: 0.5rem;
}

.detail-label {
  font-weight: bold;
  min-width: 80px;
  color: var(--text-light);
}

/* Mobile modal */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    max-height: 95vh;
    border-radius: 12px;
  }

  .modal-close {
    top: 0.5rem;
    right: 0.5rem;
    width: 36px;
    height: 36px;
    font-size: 1.8rem;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
  }

  .modal-body {
    flex-direction: column;
    padding: 1rem;
    padding-top: 3rem;
  }

  .modal-images {
    width: 100%;
  }

  .modal-images img {
    margin-bottom: 0.75rem;
  }

  .modal-thumbnails {
    gap: 0.4rem;
    justify-content: center;
  }

  .modal-thumbnail {
    width: 50px;
    height: 50px;
  }

  .modal-info {
    width: 100%;
  }

  .modal-info h2 {
    font-size: 1.3rem;
    line-height: 1.3;
  }

  .modal-artist {
    font-size: 1rem;
    margin-bottom: 1rem;
  }

  .modal-details {
    gap: 0.6rem;
  }

  .detail-row {
    flex-direction: column;
    gap: 0.2rem;
  }

  .detail-label {
    min-width: auto;
    font-size: 0.85rem;
  }
}

/* Gallery Modal */
.gallery-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  cursor: pointer;
}

.gallery-container {
  position: relative;
  width: 90%;
  max-width: 1200px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 1;
}

.gallery-close {
  position: absolute;
  top: -50px;
  right: 0;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  font-size: 2.5rem;
  cursor: pointer;
  color: white;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.3s;
  z-index: 10;
}

.gallery-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.gallery-prev,
.gallery-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.2);
  border: none;
  font-size: 3rem;
  cursor: pointer;
  color: white;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.3s;
  z-index: 10;
}

.gallery-prev {
  left: -80px;
}

.gallery-next {
  right: -80px;
}

.gallery-prev:hover,
.gallery-next:hover {
  background: rgba(255, 255, 255, 0.3);
}

.gallery-image-container {
  width: 100%;
  max-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  overflow: hidden;
}

#gallery-image {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  display: block;
}

.gallery-info {
  margin-top: 1rem;
  text-align: center;
  color: white;
}

.gallery-caption {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.gallery-counter {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
}

/* Mobile gallery */
@media (max-width: 768px) {
  .gallery-container {
    width: 100%;
    max-height: 100vh;
  }

  .gallery-close {
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
    font-size: 2rem;
    background: rgba(0, 0, 0, 0.7);
  }

  .gallery-prev,
  .gallery-next {
    width: 44px;
    height: 44px;
    font-size: 1.8rem;
    background: rgba(0, 0, 0, 0.5);
  }

  .gallery-prev {
    left: 5px;
  }

  .gallery-next {
    right: 5px;
  }

  .gallery-image-container {
    max-height: 60vh;
    border-radius: 4px;
  }

  #gallery-image {
    max-height: 60vh;
  }

  .gallery-info {
    margin-top: 0.75rem;
    padding: 0 1rem;
  }

  .gallery-caption {
    font-size: 0.95rem;
    line-height: 1.3;
  }

  .gallery-counter {
    font-size: 0.8rem;
    margin-top: 0.25rem;
  }
}

/* Lazy loading animation */
.vinyl-card.lazy-loading {
  opacity: 0;
  animation: fadeIn 0.5s forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

/* Extra small mobile screens */
@media (max-width: 480px) {
  .nav-brand .brand-text {
    display: none;
  }

  .nav-controls {
    gap: 0.4rem;
  }

  .sort-select {
    font-size: 0.8rem;
    padding: 0.4rem 0.5rem;
    min-width: 80px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .stats {
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.85rem;
  }

  .modal-info h2 {
    font-size: 1.1rem;
  }

  .modal-details {
    font-size: 0.9rem;
  }
}

/* Prevent body scroll when modal is open */
body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* Touch-friendly improvements for mobile */
@media (max-width: 768px) {
  .vinyl-card {
    -webkit-tap-highlight-color: transparent;
  }

  .modal-close,
  .gallery-close,
  .gallery-prev,
  .gallery-next,
  .theme-toggle,
  .sync-btn {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  /* Improve button hit targets on touch devices */
  .modal-close,
  .gallery-close {
    min-width: 44px;
    min-height: 44px;
  }

  .gallery-prev,
  .gallery-next {
    min-width: 44px;
    min-height: 44px;
  }
}
