/* Variables */
:root {
  --md-sys-color-primary: #6750a4;
  --md-sys-color-accent: #ffb300;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-background: #121212;
  --md-sys-color-surface: #1e1e1e;
  --md-sys-color-on-surface: #e0e0e0;
  --md-sys-color-outline: #444;
  --md-sys-color-secondary: #03dac6;
  --md-elevation-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

/* Global & Base Classes */
body {
  font-family: "Roboto", sans-serif;
  background-color: var(--md-sys-color-background);
  color: var(--md-sys-color-on-surface);
  margin: 0;
  padding: 0;
}

h1,
h2 {
  text-align: center;
  color: var(--md-sys-color-primary);
  margin-top: 1rem;
}

label {
  color: var(--md-sys-color-on-surface);
  font-size: 0.9rem;
}

select {
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--md-sys-color-outline);
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
}

/* Layout classes */
.controls,
nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem;
}

.tabs {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  padding: 2rem;
}

/* Navigation & Tabs */
nav a,
.tab-button {
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: 20px;
  padding: 0.5rem 1rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.3s;
}

nav a:hover,
.tab-button:hover,
.tab-button.active {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.tab-content {
  display: none;
  padding: 1rem;
}

.tab-content.active {
  display: block;
}

/* Cards */
.card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background-color: var(--md-sys-color-surface);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
}

.card:hover {
  transform: scale(1.03);
}

.card img {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.card h3 {
  font-size: 1.1rem;
  margin: 0.5rem 0;
  color: var(--md-sys-color-on-surface);
}

.card p {
  font-size: 0.9rem;
  margin: 0.2rem 0;
  color: var(--md-sys-color-on-surface);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.4em;
  margin: 0.5em 0;
}

.card-meta .meta-item {
  display: flex;
  align-items: center;
  gap: 0.3em;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.3em 0.6em;
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: nowrap;
  flex-grow: 0;
  flex-shrink: 0;
}

.card-meta .material-icons {
  font-size: 1em;
  color: var(--md-sys-color-primary);
}

.card-meta .meta-text {
  color: #eee;
}

.dimmed {
  color: #6a6a6a !important;
  font-size: 0.85rem !important;
}

/* Genres & Badges */
.badge {
  border-radius: 5px;
  padding: 0.25em 0.6em;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.3;
  outline: 1px solid;
}

/* Collections */
.collections {
  font-size: 0.85em;
  font-style: italic;
  color: #aaa;
  text-align: center;
}

.collection-buttons {
  padding-top: 0.5em;
  margin-top: auto;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 0.25em;
  overflow: hidden;
}

.collection-btn {
  background: #444;
  color: #fff;
  border: none;
  padding: 0.3em 0.6em;
  border-radius: 0.4em;
  font-size: 0.8em;
  cursor: pointer;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collection-btn:hover {
  background: #666;
}

.collection-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
}

.collection-buttons .collection-btn {
  width: 100%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Inputs & Forms */
.md-input {
  font: inherit;
  padding: 1rem 1rem 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  box-shadow: 0 1px 0 0 var(--md-sys-color-outline);
  width: 250px;
  outline: none;
  transition: box-shadow 0.2s ease;
}

.md-input:focus {
  box-shadow: 0 2px 0 0 var(--md-sys-color-primary);
}

.md-input::placeholder {
  color: var(--md-sys-color-on-surface);
  opacity: 0.6;
}

.clear-btn {
  margin-left: 1em;
  padding: 0.4em 0.8em;
  background-color: #555;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.clear-btn:hover {
  background-color: #777;
}

/* Modals */
.modal {
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal.show {
  display: flex;
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  border-radius: 16px;
  padding: 2rem;
  max-width: 600px;
  width: 90%;
  box-shadow: var(--md-elevation-shadow);
  position: relative;
}

.modal-content h3 {
  margin-top: 0;
  font-size: 1.4rem;
  color: var(--md-sys-color-primary);
}

.modal-content p {
  margin: 0.5rem 0;
  line-height: 1.4;
  font-size: 0.95rem;
}
.modal-title {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
  color: var(--md-sys-color-accent);
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--md-sys-color-on-surface);
}

.modal-meta .meta-item {
  display: flex;
  align-items: center;
  gap: 0.3em;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.3em 0.6em;
  border-radius: 6px;
  font-size: 0.85rem;
}

.meta-directors {
  margin-bottom: 1rem;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--md-sys-color-secondary);
}
.modal-description::before {
  content: "";
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3em;
  width: 100%;
  background: linear-gradient(to top, var(--md-sys-color-surface), transparent);
  z-index: 0;
  pointer-events: none;
}
.modal-description {
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1rem;
  max-height: 7em;
  position: relative;
  cursor: pointer;
  padding-bottom: 2em;
  overflow: hidden;
}

.modal-description::after {
  display: none;
  content: "...";
  position: absolute;
  bottom: 0;
  right: 0;
  width: 100%;
  text-align: right;
  font-size: 0.75rem;
  color: var(--md-sys-color-accent);
  padding: 0.3em 0.5em;
  white-space: nowrap;
  font-weight: bolder;
}

.modal-description.needs-toggle::after {
  display: block;
}

.modal-description.expanded::after {
  content: "Click to collapse";
}

.modal-description.expanded {
  max-height: none;
}
.modal-description.expanded::after {
  content: "Click to collapse";
  background: none;
}

.modal-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
  margin-bottom: 1rem;
}

.modal-collections {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
}

.modal-collections .collection-btn {
  background: var(--md-sys-color-secondary);
  color: black;
  font-weight: bold;
}
.modal-meta .material-icons {
  font-size: 1rem;
  margin-right: 0.3em;
  color: var(--md-sys-color-primary);
}
.close-button {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  font-size: 1.5rem;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  background: none;
  border: none;
}
.modal-body {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

#modal-poster {
  width: 200px;
  max-height: 300px;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.modal-details {
  flex: 1;
}

/* Scroll to Top button */
.scroll-top-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 3rem;
  height: 3rem;
  border: none;
  border-radius: 50%;
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-size: 1.5rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  display: none;
  z-index: 999;
  transition: opacity 0.2s ease;
}

.scroll-top-btn.show {
  display: block;
}

/* Jump List */
.jump-list {
  position: sticky;
  top: 10px;
  float: right;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0.5em;
  z-index: 999;
  max-height: 90vh;
  overflow-y: auto;
  right: 1em;
}

.jump-list a {
  font-size: 0.9em;
  text-decoration: none;
  color: #666;
  text-align: center;
}

.jump-list a:hover {
  text-decoration: underline;
  color: #000;
}

.jump-list a.disabled {
  pointer-events: none;
  opacity: 0.4;
}

/* Responsive */
@media (max-width: 768px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    padding: 1rem;
    gap: 1rem;
  }

  .modal-content {
    width: 95%;
    padding: 1rem;
  }

  .controls,
  nav,
  .tabs {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }

  .md-input {
    width: 90%;
    max-width: 100%;
  }

  .card {
    padding: 0.75rem;
  }

  .card h3 {
    font-size: 1rem;
  }

  .card p {
    font-size: 0.85rem;
  }

  .scroll-top-btn {
    bottom: 1rem;
    right: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.2rem;
  }

  h1,
  h2 {
    font-size: 1.5rem;
  }

  label {
    font-size: 0.85rem;
  }

  .badge {
    font-size: 0.7rem;
  }
}
.file-path {
  font-size: 0.65rem;
  color: #888;
  margin-top: 0.25em;
  white-space: pre-wrap;
  word-break: break-word;
}