/* Think or Swim (ToS) Inspired Color Scheme */

:root {
  /* Light theme colors - ToS inspired */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #f1f3f4;
  --bg-hover: rgba(0, 127, 178, 0.08); /* Light blue hover background */
  --text-primary: #000000;
  --text-secondary: #6c757d;
  --text-muted: #9ca3af;
  --border-color: #e9ecef;
  --accent-color: #1db954; /* Keep green for branding */
  --accent-hover: #1ed760;
  --blue-primary: #007fb2; /* Updated blue */
  --blue-hover: #006a96;
  --blue-light: rgba(0, 127, 178, 0.1);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
  --radius: 8px;
  --radius-large: 12px;
  
  /* Filter pill colors - now blue */
  --pill-bg: rgba(0, 127, 178, 0.1);
  --pill-text: var(--blue-primary);
  --pill-border: var(--blue-primary);
}

[data-theme="dark"] {
  /* Dark theme colors - ToS inspired */
  --bg-primary: #121212;
  --bg-secondary: #181818;
  --bg-tertiary: #282828;
  --bg-hover: rgba(0, 127, 178, 0.15); /* Blue hover for dark theme */
  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
  --text-muted: #6b7280;
  --border-color: #2a2a2a;
  --accent-color: #1db954; /* Keep green for branding */
  --accent-hover: #1ed760;
  --blue-primary: #1a9bd1; /* Lighter blue for dark theme */
  --blue-hover: #148bb8;
  --blue-light: rgba(26, 155, 209, 0.15);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.playlist-dropdown {
  position: relative;
}

.playlist-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius);
  transition: all 0.2s ease;
}

.playlist-btn:hover {
  background-color: var(--bg-hover); /* Blue hover */
  transform: translateY(-1px);
}

.playlist-btn h1 {
  margin: 0;
  font-size: 2.5em;
  font-weight: 800;
  background: linear-gradient(135deg, var(--blue-primary), var(--blue-hover));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.playlist-panel {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  z-index: 1000;
  min-width: 160px;
  display: none;
  overflow: hidden;
}

.playlist-option {
  display: block;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.2s ease;
  border-bottom: 1px solid var(--border-color);
}

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

.playlist-option:hover {
  background-color: var(--bg-hover); /* Blue hover */
  color: var(--blue-primary); /* Blue text on hover */
}

.header-icons {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.theme-toggle {
  background: none;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  border-color: var(--blue-primary); /* Blue border on hover */
  transform: scale(1.1);
}

/* Account Section with Dropdown */
.account-dropdown {
  position: relative;
}

.account-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius);
  transition: all 0.2s ease;
}

.account-section:hover {
  background-color: var(--bg-hover); /* Blue hover */
}

.account-icon {
  width: 32px;
  height: 32px;
  color: var(--text-primary);
}

.account-name {
  color: var(--text-secondary);
  font-size: 0.95em;
  font-weight: 600;
  white-space: nowrap;
}

.account-panel {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  z-index: 1000;
  min-width: 160px;
  display: none;
  overflow: hidden;
}

.account-option {
  display: block;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.2s ease;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
}

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

.account-option:hover {
  background-color: var(--bg-hover); /* Blue hover */
  color: var(--blue-primary); /* Blue text on hover */
}

/* Controls with Filter Pills */
.controls {
  padding: 0.75rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-secondary);
  min-height: auto;
  flex-wrap: wrap;
  gap: 1rem;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--pill-bg); /* Blue background */
  color: var(--pill-text); /* Blue text */
  border: 1px solid var(--pill-border); /* Blue border */
  border-radius: 20px;
  padding: 0.4rem 0.8rem;
  font-size: 0.875em;
  font-weight: 500;
  transition: all 0.2s ease;
}

.filter-pill .remove-filter {
  background: none;
  border: none;
  color: var(--pill-text); /* Blue color */
  cursor: pointer;
  padding: 0;
  font-size: 1em;
  line-height: 1;
  transition: all 0.2s ease;
}

.filter-pill .remove-filter:hover {
  transform: scale(1.1);
}

.filter-dropdown {
  position: relative;
}

.filter-btn {
  background: var(--bg-primary); /* Original background */
  border: 1px solid var(--border-color); /* Original border */
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary); /* Original text color */
  transition: all 0.2s ease;
  font-size: 0.9em;
}

.filter-btn:hover {
  background-color: var(--bg-hover); /* Blue hover */
  border-color: var(--blue-primary); /* Blue border on hover */
  color: var(--blue-primary); /* Blue text on hover */
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.filter-panel {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  z-index: 1000;
  padding: 1rem;
  min-width: 280px;
  display: none;
}

.filter-select, .filter-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 0.95em;
  font-weight: 500;
  margin-bottom: 0.5rem;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.filter-select:focus, .filter-input:focus {
  outline: none;
  border-color: var(--blue-primary); /* Blue focus border */
  box-shadow: 0 0 0 3px var(--blue-light); /* Blue focus shadow */
}

.clear-filters-btn {
  background: linear-gradient(135deg, var(--blue-primary), var(--blue-hover)); /* Blue background */
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875em;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s ease;
  margin-top: 0.5rem;
}

.clear-filters-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.clear-filters-btn.has-filters {
  /* background: linear-gradient(135deg, #e74c3c, #c0392b); */
  background: linear-gradient(to bottom right, #1a9bd1, #148bb8);

}

/* Main Content */
.main-content {
  flex: 1;
  padding: 0 2rem 2rem;
}

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--bg-primary);
  border-radius: var(--radius-large);
  overflow: hidden;
  box-shadow: var(--shadow);
}

thead {
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
}

th {
  padding: 1rem 1.5rem;
  text-align: left;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
  letter-spacing: 0.25px;
}

.sortable {
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.sortable:hover {
  background-color: var(--bg-hover); /* Blue hover */
  color: var(--blue-primary); /* Blue text on hover */
}

.sortable:hover .sort-indicator {
  color: var(--blue-primary); /* Blue sort indicators only on hover */
}

.sort-indicator {
  font-size: 0.75em;
  margin-left: 0.5rem;
  opacity: 0.6;
  transition: all 0.2s ease;
}

tr {
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
}

tr:hover {
  background-color: var(--bg-hover); /* Blue hover background */
  transform: translateX(2px);
}

tr:last-child {
  border-bottom: none;
}

td {
  padding: 1rem 1.5rem;
  vertical-align: middle;
}

td:nth-child(2) {
  min-width: 200px;
  max-width: 300px;
}

td:nth-child(3) {
  min-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

td:nth-child(4) {
  min-width: 80px;
  white-space: nowrap;
  font-weight: 600;
}

td.club {
  font-size: 1.75em;
  font-weight: 800;
  color: var(--accent-color); /* Keep green for card numbers */
  min-width: 90px;
  letter-spacing: -0.5px;
}

.song-title {
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
  font-size: 1.5em;
  letter-spacing: 0.25px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-artist {
  color: var(--text-secondary);
  font-size: 1.2em;
  font-weight: 500;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile: Put puzzle piece under artist */
@media (max-width: 768px) {
  .song-info {
    display: flex;
    flex-direction: column;
  }
  
  .song-puzzle {
    color: var(--text-muted);
    font-size: 1em;
    margin-top: 0.25rem;
  }
}

/* Detail Card - Fixed Layout */
.detail-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-large);
  margin: 2rem 0;
  overflow: hidden;
  box-shadow: var(--shadow-hover);
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.detail-header {
  display: flex;
  flex-direction: column;
  padding: 2rem;
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
  border-bottom: 1px solid var(--border-color);
  gap: 1rem;
}

.detail-header-top {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.card-symbol {
  font-size: 2.5em;
  font-weight: 800;
  color: var(--accent-color); /* Keep green for card symbols */
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  letter-spacing: -1px;
  white-space: nowrap;
  flex-shrink: 0;
}

.card-title {
  flex: 1;
  min-width: 0;
}

.card-title h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.75em;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: 0.25px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-title p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 1.4em;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Icons under the card symbol for better mobile layout */
.card-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-left: 0;
}

.card-info div {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  background-color: var(--bg-primary);
  border-radius: var(--radius);
  font-size: 0.95em;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.detail-content {
  padding: 2rem;
  font-size: 1.3em;
}

.puzzle-piece {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background-color: var(--bg-secondary);
  border-radius: var(--radius);
  border-left: 4px solid var(--accent-color); /* Keep green for puzzle piece border */
}

.puzzle-icon {
  font-size: 1.75em;
}

.notes-links {
  margin-top: 1.5rem;
}

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

.notes-links li {
  margin-bottom: 0.5rem;
}

.notes-links a {
  color: var(--blue-primary); /* Blue text */
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  background-color: var(--bg-secondary); /* Original background */
}

.notes-links a:hover {
  background-color: var(--bg-tertiary); /* Original hover */
  transform: translateX(4px);
}
.notes-links a.active-link {
  box-shadow: 0 0 0 2px var(--blue-primary); /* Blue outline */
  transform: translateX(4px);
  outline: none;
}

/* Document Viewer */
.document-viewer {
  margin-top: 1.5rem;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.document-viewer iframe {
  width: 100%;
  height: 600px;
  border: none;
}

.document-viewer img {
  width: 100%;
  height: auto;
  display: block;
}

.document-viewer .markdown-content {
  padding: 1.5rem;
  background-color: var(--bg-secondary);
  line-height: 1.8;
}

.hidden {
  display: none !important;
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }
  
  .playlist-btn h1 {
    font-size: 1.95em;
  }
  
  .controls {
    padding: 0.5rem 1rem;
    flex-direction: column;
    align-items: stretch;
  }
  
  .active-filters {
    order: 1;
    margin-bottom: 0.5rem;
  }
  
  .filter-dropdown {
    order: 2;
    align-self: flex-end;
  }
  
  .filter-panel {
    right: 10px;
    left: auto;
    min-width: 260px;
    max-width: calc(100vw - 20px);
  }
  
  .filter-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.85em;
  }
  
  .main-content {
    padding: 0 1rem 1rem;
  }
  
  table {
    font-size: 0.875em;
    table-layout: fixed;
  }
  
  th, td {
    padding: 0.75rem 0.5rem;
  }
  
  th:nth-child(1), td:nth-child(1) {
    width: 15%;
    min-width: 60px;
  }
  
  th:nth-child(2), td:nth-child(2) {
    width: 50%;
    min-width: 150px;
  }
  
  th:nth-child(3), td:nth-child(3) {
    width: 20%;
    min-width: 80px;
    display: none;
  }
  
  th:nth-child(4), td:nth-child(4) {
    width: 15%;
    min-width: 50px;
  }
  
  td.club {
    font-size: 1.4em;
    font-weight: 700;
  }
  
  /* SIMPLIFIED Mobile detail card layout */

  .detail-header-top {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 1rem;
    row-gap: 1rem;
  }
  
  .card-symbol {
    grid-column: 1;
    grid-row: 1;
    font-size: 2.5em;
    line-height: 1;
  }
  
  .card-title {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }
  
  .card-title h2 {
    font-size: 1.4em;
    margin: 0 0 0.25rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .card-title p {
    font-size: 1.2em;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .card-info {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
  }
  
  .card-info div {
    padding: 0.4rem 0.6rem;
    font-size: 0.85em;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 0.75rem;
  }
  
  .playlist-btn h1 {
    font-size: 2em;
  }
  
  .controls {
    padding: 0.4rem 0.5rem;
  }
  
  .filter-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.8em;
  }
  
  .filter-panel {
    min-width: 200px;
    max-width: 85vw;
    padding: 0.5rem;
  }
  
  .main-content {
    padding: 0 0.5rem 0.5rem;
  }
  
  th, td {
    padding: 0.5rem 0.25rem;
  }
  
  .card-symbol {
    font-size: 2em;
  }
  
  .card-title h2 {
    font-size: 1.2em;
  }
  
  .card-title p {
    font-size: 0.9em;
  }
  
  .card-info div {
    padding: 0.3rem 0.5rem;
    font-size: 0.8em;
  }
  
  td.club {
    font-size: 1.2em;
  }
}