﻿/* ===================================
   CSS Variables for Theming
   =================================== */
:root {
  /* Light Theme Colors */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-dim: #eff6ff;
  --danger: #ef4444;
  --success: #10b981;
  --favorite: #fbbf24;

  /* Sleek modern aesthetics */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-full: 9999px;
  --shadow-float: 0 4px 20px rgba(0, 0, 0, 0.05);
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  /* Dark Theme Colors */
  --bg-page: #0f172a;
  --bg-card: #1e293b;
  --border-color: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-dim: rgba(59, 130, 246, 0.1);
  --shadow-float: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* ===================================
   Global Styles
   =================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

svg {
  display: block;
}

/* ===================================
   Container & Layout
   =================================== */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem 2rem 1rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Removed old layout .header and .controls */

/* ===================================
   Buttons
   =================================== */
.btn {
  padding: 0.75rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
}

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

.btn-secondary {
  flex: 1;
}

.btn-filter {
  flex: 1;
}

.btn-filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.action-buttons {
  display: flex;
  gap: 0.75rem;
}

/* ===================================
   Search Bar
   =================================== */
.search-container {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 18px;
  height: 18px;
}

.search-input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 1rem;
  color: var(--text-primary);
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

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

/* ===================================
   Stats
   =================================== */
.stats {
  display: flex;
  gap: 1rem;
  padding: 0;
  align-items: center;
}

.stat-item {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===================================
   Song List
   =================================== */
.song-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.empty-state svg {
  color: var(--border-color);
}

.empty-state p {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.empty-subtitle {
  font-size: 0.9rem !important;
  color: var(--text-muted) !important;
  font-weight: 400 !important;
}

/* ===================================
   Song Item (List View approach)
   =================================== */
.song-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: transparent;
  border-radius: var(--radius-md);
  transition: var(--transition);
  border: 1px solid transparent;
}

.song-item:hover {
  background: var(--bg-card);
  border-color: var(--border-color);
  box-shadow: var(--shadow-float);
}

.song-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.song-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.song-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: var(--bg-card);
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  font-weight: 600;
  color: var(--accent);
}

.song-artist {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}

.favorite-btn svg { width: 24px; height: 24px; }
.favorite-btn:hover {
  background: var(--bg-page);
  color: var(--text-secondary);
}

.favorite-btn.active {
  color: var(--favorite);
}

.favorite-btn.active svg {
  fill: var(--favorite);
}

/* ===================================
   Scroll to Top Button
   =================================== */
.scroll-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-float);
  border: 1px solid var(--border-color);
  transition: var(--transition);
  z-index: 100;
}

.scroll-top:hover {
  transform: translateY(-4px);
  color: var(--accent);
  border-color: var(--accent);
}

.scroll-top.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

/* ===================================
   Loading / Infinite Scroll
   =================================== */
.infinite-scroll-trigger {
  text-align: center;
  padding: 2rem;
  width: 100%;
}
.loading {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.loading::after {
  content: "";
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--text-muted);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===================================
   Footer
   =================================== */
.footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: auto;
}

/* ===================================
   SweetAlert2 Custom Styling
   =================================== */
.swal2-popup {
  background: var(--bg-card) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-float) !important;
  border: 1px solid var(--border-color) !important;
  padding: 2em !important;
}

.swal2-title {
  color: var(--text-primary) !important;
  font-size: 1.25rem !important;
  font-weight: 700 !important;
}

.swal2-html-container {
  color: var(--text-secondary) !important;
  font-size: 1rem !important;
}

.swal2-confirm {
  background: var(--accent) !important;
  border-radius: var(--radius-full) !important;
  padding: 0.75rem 1.5rem !important;
  font-weight: 600 !important;
}

/* ===================================
   Responsive Design
   =================================== */
@media (max-width: 600px) {
  .title {
    font-size: 1.5rem;
  }
  .controls {
    margin-bottom: 1.5rem;
  }
  .action-buttons {
    flex-direction: column;
  }
  .song-item {
    padding: 0.75rem 0.5rem;
  }
  .scroll-top {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
  }
}
.nav-wrapper {
  position: sticky;
  top: 0;
  z-index: 50;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background-color: var(--bg-page);
  padding-top: 2rem;
  padding-bottom: 1rem;
  transition: background-color 0.3s ease;
}

.nav-pill {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  padding: 0.5rem 0.5rem 0.5rem 1.25rem;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
  border: 1px solid var(--border-color);
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
  flex-shrink: 0;
}

.brand-icon {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.title {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0;
}

.sub-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.stat-divider {
  color: var(--border-color);
}

.btn-icon {
  width: 18px;
  height: 18px;
}

/* Adjustments for search pulled out of pill */
.nav-wrapper .search-container {
  flex: 1;
  width: 100%;
}
.nav-wrapper .search-input {
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.8rem 1rem 0.8rem 2.5rem;
}
.nav-wrapper .search-input:focus {
  background: var(--bg-card);
  border-color: var(--accent);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: var(--shadow-float);
  flex-shrink: 0;
}
.icon-btn:hover {
  color: var(--accent);
  transform: translateY(-2px);
}
.theme-icon, .theme-icon-dark {
  width: 20px;
  height: 20px;
}
@media (max-width: 600px) {
  .nav-pill {
    flex-wrap: wrap;
    padding: 0.75rem;
    gap: 0.75rem;
  }
  .brand {
    flex: 1;
  }
  .title {
    font-size: 1.3rem;
  }
  .sub-controls {
    flex-direction: column;
    align-items: flex-start;
  }
  .action-buttons {
    flex-direction: row;
    width: 100%;
  }
  .action-buttons .btn {
    width: 50%;
    justify-content: center;
    padding: 0.75rem 0.5rem;
    font-size: 0.8rem;
  }
  .stats {
    width: 100%;
    justify-content: flex-start;
    padding-left: 0.5rem;
    font-size: 0.75rem;
  }
  .song-item {
    align-items: center;
  }
}
/* Fix media query for nav wrapper on mobile */
@media (max-width: 600px) {
  .nav-wrapper {
    padding-top: 1rem;
    padding-bottom: 0.5rem;
  }
}
