/* ================================================
   BOOKIFY — Spotify-inspired Dark Theme
   Premium, clean, modern aesthetic
   ================================================ */

:root {
  --bg-base: #121212;
  --bg-elevated: #181818;
  --bg-highlight: #282828;
  --bg-card: #232323;
  --bg-hover: #2a2a2a;

  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
  --text-subdued: #6a6a6a;

  --accent: #1db954;
  --accent-hover: #1ed760;
  --accent-pressed: #169c46;

  --border: rgba(255,255,255,0.1);

  --font: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --transition: 200ms ease;
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* App Layout */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg-base);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-primary);
}

.logo svg {
  width: 32px;
  height: 32px;
  color: var(--accent);
}

.logo span {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nav-section {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  font-weight: 500;
}

.nav-item svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.nav-item:hover {
  color: var(--text-primary);
}

.nav-item.active {
  color: var(--text-primary);
}

.library {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.library-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  font-weight: 500;
}

.library-header svg {
  width: 24px;
  height: 24px;
}

.library-empty {
  padding: 16px;
  color: var(--text-subdued);
  font-size: 0.875rem;
}

/* Main Content */
.main-content {
  flex: 1;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  margin: 8px;
  margin-left: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.content-wrapper {
  min-height: 100%;
}

/* Hero Section */
.hero {
  position: relative;
  padding: 80px 32px 32px;
  overflow: hidden;
}

.hero-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #1a3a2a 0%, #0d1f17 50%, var(--bg-elevated) 100%);
  z-index: 0;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 800px;
}

.hero-label {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 16px;
}

.hero p {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 500px;
}

/* Search Section */
.search-section {
  padding: 0 32px 32px;
  position: relative;
  z-index: 10;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border-radius: 500px;
  padding: 8px 24px;
  gap: 12px;
  transition: all var(--transition);
  border: 2px solid transparent;
}

.search-box:focus-within {
  background: var(--bg-highlight);
  border-color: var(--text-primary);
}

.search-icon {
  width: 24px;
  height: 24px;
  color: var(--text-subdued);
  flex-shrink: 0;
}

.search-box:focus-within .search-icon {
  color: var(--text-primary);
}

.autocomplete-wrapper {
  flex: 1;
  position: relative;
}

.search-box input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font);
  padding: 12px 0;
}

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

/* Suggestions Dropdown */
.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: -36px;
  right: 0;
  background: var(--bg-highlight);
  border-radius: var(--radius-md);
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 16px 32px rgba(0,0,0,0.5);
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition);
}

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

.suggestion-cover {
  width: 40px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}

.suggestion-cover-placeholder {
  width: 40px;
  height: 56px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.suggestion-cover-placeholder::after {
  content: '';
  width: 20px;
  height: 26px;
  border: 2px solid var(--text-subdued);
  border-radius: 2px;
}

.suggestion-info {
  flex: 1;
  min-width: 0;
}

.suggestion-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-author {
  font-size: 0.875rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Form Extras */
.form-extras {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.form-field {
  flex: 1;
}

.form-field input {
  width: 100%;
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.875rem;
  transition: all var(--transition);
}

.form-field input:focus {
  outline: none;
  background: var(--bg-highlight);
}

.form-field input::placeholder {
  color: var(--text-subdued);
}

/* Generate Button */
.btn-generate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  padding: 14px 32px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 500px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-generate:hover {
  background: var(--accent-hover);
  transform: scale(1.04);
}

.btn-generate:active {
  background: var(--accent-pressed);
  transform: scale(1);
}

.btn-generate svg {
  width: 20px;
  height: 20px;
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 32px;
  gap: 24px;
}

.loading-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 40px;
}

.loading-bars span {
  width: 6px;
  background: var(--accent);
  border-radius: 3px;
  animation: bars 1s ease-in-out infinite;
}

.loading-bars span:nth-child(1) { height: 20px; animation-delay: 0s; }
.loading-bars span:nth-child(2) { height: 30px; animation-delay: 0.1s; }
.loading-bars span:nth-child(3) { height: 25px; animation-delay: 0.2s; }
.loading-bars span:nth-child(4) { height: 35px; animation-delay: 0.3s; }

@keyframes bars {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.5); }
}

.loading p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Results */
.result {
  padding: 0 32px 32px;
}

.playlist-header {
  display: flex;
  align-items: flex-end;
  gap: 24px;
  padding: 24px 0;
}

.playlist-cover {
  width: 192px;
  height: 192px;
  background: linear-gradient(135deg, #1a5438 0%, #0d2a1c 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.cover-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(29,185,84,0.3) 0%, transparent 100%);
}

.playlist-cover svg {
  width: 80px;
  height: 80px;
  position: relative;
  z-index: 1;
}

.playlist-info {
  flex: 1;
  min-width: 0;
}

.playlist-type {
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.playlist-info h2 {
  font-size: clamp(1.5rem, 4vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 8px 0 16px;
}

.playlist-info p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-bottom: 8px;
}

.playlist-meta {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Playlist Actions */
.playlist-actions {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 24px 0;
}

.btn-play {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}

.btn-play:hover {
  transform: scale(1.06);
  background: var(--accent-hover);
}

.btn-play svg {
  width: 24px;
  height: 24px;
  margin-left: 3px;
}

/* Analysis Tags */
.analysis-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  padding: 16px 0 24px;
  border-bottom: 1px solid var(--border);
}

.tag-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tag-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-subdued);
}

.tag {
  font-size: 0.9375rem;
  color: var(--text-primary);
}

/* Tracks */
.tracks-container {
  padding-top: 16px;
}

.tracks-header {
  display: grid;
  grid-template-columns: 48px 1fr 100px;
  gap: 16px;
  padding: 8px 16px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-subdued);
  border-bottom: 1px solid var(--border);
}

.tracks-list {
  list-style: none;
}

.track-item {
  display: grid;
  grid-template-columns: 48px 1fr 100px;
  gap: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

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

.track-num {
  color: var(--text-subdued);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.track-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.track-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  font-size: 0.875rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.btn-link {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: all var(--transition);
  text-decoration: none;
}

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

.btn-spotify:hover {
  color: var(--accent);
}

.btn-youtube:hover {
  color: #ff0000;
}

/* Reset Button */
.btn-reset {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 32px;
  padding: 12px 24px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 500px;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-reset:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.btn-reset svg {
  width: 18px;
  height: 18px;
}

/* Error */
.error {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 80px 32px;
  text-align: center;
}

.error svg {
  width: 48px;
  height: 48px;
  color: var(--text-subdued);
  margin-bottom: 16px;
}

.error p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 8px;
  }
}

@media (max-width: 640px) {
  .main-content {
    border-radius: 0;
    margin: 0;
  }

  .hero {
    padding: 60px 20px 24px;
  }

  .search-section,
  .result {
    padding-left: 20px;
    padding-right: 20px;
  }

  .form-extras {
    flex-direction: column;
  }

  .playlist-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .playlist-cover {
    width: 140px;
    height: 140px;
  }

  .tracks-header {
    display: none;
  }

  .track-item {
    grid-template-columns: 32px 1fr auto;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 12px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-highlight);
  border-radius: 6px;
  border: 3px solid var(--bg-elevated);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-subdued);
}
