/**
 * Material 3 Components
 * 组件样式
 */

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--md-sys-space-2);
  padding: 10px 24px;
  font-size: var(--md-sys-typescale-label-large);
  font-weight: 500;
  letter-spacing: 0.1px;
  line-height: 1.43;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

/* Filled Button */
.btn-filled {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.btn-filled:hover:not(:disabled) {
  box-shadow: var(--md-sys-elevation-1);
}

.btn-filled:active:not(:disabled) {
  box-shadow: var(--md-sys-elevation-0);
}

/* Filled Tonal Button */
.btn-tonal {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.btn-tonal:hover:not(:disabled) {
  box-shadow: var(--md-sys-elevation-1);
}

/* Outlined Button */
.btn-outlined {
  background-color: transparent;
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-outline);
}

.btn-outlined:hover:not(:disabled) {
  background-color: var(--md-sys-color-primary);
  background-color: rgba(25, 118, 210, 0.08);
}

/* Text Button */
.btn-text {
  background-color: transparent;
  color: var(--md-sys-color-primary);
  padding: 10px 12px;
}

.btn-text:hover:not(:disabled) {
  background-color: rgba(25, 118, 210, 0.08);
}

/* Icon Button */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: transparent;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.btn-icon:hover:not(:disabled) {
  background-color: var(--md-sys-color-on-surface);
  background-color: rgba(0, 0, 0, 0.08);
}

.btn-icon:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.btn-icon svg, .btn-icon img {
  width: 24px;
  height: 24px;
}

/* FAB */
.fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: var(--md-sys-shape-corner-large);
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  box-shadow: var(--md-sys-elevation-3);
  cursor: pointer;
  transition: box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.fab:hover {
  box-shadow: var(--md-sys-elevation-4);
}

.fab svg {
  width: 24px;
  height: 24px;
}

/* ===== Cards ===== */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-medium);
  overflow: hidden;
  transition: box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.card-elevated {
  background-color: var(--md-sys-color-surface-container-low);
  box-shadow: var(--md-sys-elevation-1);
}

.card-elevated:hover {
  box-shadow: var(--md-sys-elevation-2);
}

.card-filled {
  background-color: var(--md-sys-color-surface-container-highest);
}

.card-outlined {
  background-color: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.card-media {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-content {
  padding: var(--md-sys-space-4);
}

.card-title {
  font-size: var(--md-sys-typescale-title-medium);
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  margin-bottom: var(--md-sys-space-1);
}

.card-subtitle {
  font-size: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-on-surface-variant);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: var(--md-sys-space-2);
  padding: var(--md-sys-space-2) var(--md-sys-space-4);
}

/* Card as link */
.card-link {
  text-decoration: none;
  color: inherit;
}

.card-link:hover .card {
  box-shadow: var(--md-sys-elevation-2);
}

/* ===== Video Card (视频卡片) ===== */
.vod-card {
  position: relative;
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: var(--md-sys-shape-corner-medium);
  overflow: hidden;
  background-color: var(--md-sys-color-surface-container);
  transition: transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.vod-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--md-sys-elevation-2);
}

.vod-card:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.vod-card__poster {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background-color: var(--md-sys-color-surface-container-high);
}

.vod-card__poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

.vod-card:hover .vod-card__poster img {
  transform: scale(1.05);
}

.vod-card__badge {
  position: absolute;
  top: var(--md-sys-space-2);
  right: var(--md-sys-space-2);
  padding: 2px 8px;
  font-size: var(--md-sys-typescale-label-small);
  font-weight: 500;
  color: var(--md-sys-color-on-primary);
  background-color: var(--md-sys-color-primary);
  border-radius: var(--md-sys-shape-corner-small);
}

.vod-card__score {
  position: absolute;
  bottom: var(--md-sys-space-2);
  left: var(--md-sys-space-2);
  padding: 2px 6px;
  font-size: var(--md-sys-typescale-label-small);
  font-weight: 500;
  color: #FFF;
  background-color: rgba(0, 0, 0, 0.6);
  border-radius: var(--md-sys-shape-corner-extra-small);
}

.vod-card__info {
  padding: var(--md-sys-space-3);
}

.vod-card__title {
  font-size: var(--md-sys-typescale-title-small);
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  margin-bottom: var(--md-sys-space-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vod-card__meta {
  font-size: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-on-surface-variant);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Chips ===== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--md-sys-space-2);
  padding: 6px 16px;
  font-size: var(--md-sys-typescale-label-large);
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  background-color: transparent;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-small);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
  white-space: nowrap;
}

.chip:hover {
  background-color: var(--md-sys-color-on-surface);
  background-color: rgba(0, 0, 0, 0.08);
}

.chip:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.chip.active, .chip[aria-selected="true"] {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--md-sys-space-2);
}

/* ===== Chips Filter Row (横向滚动) ===== */
.chips-row {
  display: flex;
  gap: var(--md-sys-space-2);
  overflow-x: auto;
  padding-bottom: var(--md-sys-space-2);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.chips-row::-webkit-scrollbar {
  display: none;
}

/* ===== List Items ===== */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--md-sys-space-4);
  padding: var(--md-sys-space-3) var(--md-sys-space-4);
  text-decoration: none;
  color: inherit;
  transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.list-item:hover {
  background-color: var(--md-sys-color-on-surface);
  background-color: rgba(0, 0, 0, 0.04);
}

.list-item:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: -2px;
}

.list-item__leading {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: var(--md-sys-shape-corner-small);
  overflow: hidden;
  background-color: var(--md-sys-color-surface-container);
}

.list-item__leading img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-item__content {
  flex: 1;
  min-width: 0;
}

.list-item__headline {
  font-size: var(--md-sys-typescale-body-large);
  color: var(--md-sys-color-on-surface);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item__supporting {
  font-size: var(--md-sys-typescale-body-medium);
  color: var(--md-sys-color-on-surface-variant);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item__trailing {
  flex-shrink: 0;
  font-size: var(--md-sys-typescale-label-small);
  color: var(--md-sys-color-on-surface-variant);
}

/* ===== Divider ===== */
.divider {
  height: 1px;
  background-color: var(--md-sys-color-outline-variant);
  border: none;
}

.divider-inset {
  margin-left: 72px;
}

/* ===== Text Fields ===== */
.text-field {
  position: relative;
  width: 100%;
}

.text-field__input {
  width: 100%;
  padding: 16px;
  font-size: var(--md-sys-typescale-body-large);
  color: var(--md-sys-color-on-surface);
  background-color: var(--md-sys-color-surface-container-highest);
  border: none;
  border-bottom: 2px solid var(--md-sys-color-on-surface-variant);
  border-radius: var(--md-sys-shape-corner-extra-small) var(--md-sys-shape-corner-extra-small) 0 0;
  transition: border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.text-field__input:focus {
  outline: none;
  border-bottom-color: var(--md-sys-color-primary);
}

.text-field__input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
}

/* Outlined Text Field */
.text-field--outlined .text-field__input {
  background-color: transparent;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-extra-small);
}

.text-field--outlined .text-field__input:focus {
  border-color: var(--md-sys-color-primary);
  border-width: 2px;
}

/* ===== Search Bar ===== */
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--md-sys-space-4);
  width: 100%;
  padding: 0 var(--md-sys-space-4);
  background-color: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-full);
  transition: box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.search-bar:focus-within {
  box-shadow: var(--md-sys-elevation-2);
}

.search-bar__icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  color: var(--md-sys-color-on-surface-variant);
}

.search-bar__input {
  flex: 1;
  padding: 16px 0;
  font-size: var(--md-sys-typescale-body-large);
  color: var(--md-sys-color-on-surface);
  background-color: transparent;
  border: none;
}

.search-bar__input:focus {
  outline: none;
}

.search-bar__input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
}

/* ===== Dialogs ===== */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background-color: var(--md-sys-color-scrim);
  opacity: 0.32;
  z-index: 999;
}

.dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 48px);
  max-width: 560px;
  max-height: calc(100vh - 48px);
  background-color: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-extra-large);
  box-shadow: var(--md-sys-elevation-3);
  z-index: 1000;
  overflow: hidden;
}

.dialog__header {
  padding: var(--md-sys-space-5);
  padding-bottom: var(--md-sys-space-4);
}

.dialog__title {
  font-size: var(--md-sys-typescale-headline-small);
  color: var(--md-sys-color-on-surface);
}

.dialog__content {
  padding: 0 var(--md-sys-space-5);
  font-size: var(--md-sys-typescale-body-medium);
  color: var(--md-sys-color-on-surface-variant);
  max-height: 60vh;
  overflow-y: auto;
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--md-sys-space-2);
  padding: var(--md-sys-space-5);
}

/* ===== Snackbar ===== */
.snackbar {
  position: fixed;
  bottom: calc(var(--md-sys-layout-bottom-nav-height) + var(--md-sys-space-4));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--md-sys-space-3);
  padding: 14px var(--md-sys-space-4);
  min-width: 288px;
  max-width: calc(100vw - 32px);
  background-color: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  border-radius: var(--md-sys-shape-corner-extra-small);
  box-shadow: var(--md-sys-elevation-3);
  z-index: 1001;
}

@media (min-width: 840px) {
  .snackbar {
    bottom: var(--md-sys-space-5);
    left: calc(var(--md-sys-layout-nav-rail-width) + var(--md-sys-space-5));
    transform: none;
  }
}

.snackbar__text {
  flex: 1;
  font-size: var(--md-sys-typescale-body-medium);
}

.snackbar__action {
  color: var(--md-sys-color-inverse-primary);
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
}

/* ===== Badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: var(--md-sys-typescale-label-small);
  font-weight: 500;
  color: var(--md-sys-color-on-error);
  background-color: var(--md-sys-color-error);
  border-radius: var(--md-sys-shape-corner-full);
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--md-sys-color-surface-variant);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--md-sys-space-2);
  padding: var(--md-sys-space-4);
  font-size: var(--md-sys-typescale-title-small);
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.tab:hover {
  color: var(--md-sys-color-on-surface);
  background-color: var(--md-sys-color-on-surface);
  background-color: rgba(0, 0, 0, 0.04);
}

.tab.active, .tab[aria-selected="true"] {
  color: var(--md-sys-color-primary);
  border-bottom-color: var(--md-sys-color-primary);
}

/* ===== Progress Indicators ===== */
.progress-linear {
  width: 100%;
  height: 4px;
  background-color: var(--md-sys-color-surface-container-highest);
  border-radius: 2px;
  overflow: hidden;
}

.progress-linear__bar {
  height: 100%;
  background-color: var(--md-sys-color-primary);
  border-radius: 2px;
  transition: width var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

.progress-linear--indeterminate .progress-linear__bar {
  width: 50%;
  animation: progress-indeterminate 1.5s infinite ease-in-out;
}

@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

/* ===== Skeleton Loading ===== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--md-sys-color-surface-container) 25%,
    var(--md-sys-color-surface-container-high) 50%,
    var(--md-sys-color-surface-container) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--md-sys-shape-corner-small);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Switch ===== */
.switch {
  position: relative;
  display: inline-flex;
  width: 52px;
  height: 32px;
  cursor: pointer;
}

.switch__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__track {
  position: absolute;
  inset: 0;
  background-color: var(--md-sys-color-surface-container-highest);
  border: 2px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-full);
  transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.switch__thumb {
  position: absolute;
  top: 50%;
  left: 6px;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background-color: var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-full);
  transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.switch__input:checked + .switch__track {
  background-color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
}

.switch__input:checked ~ .switch__thumb {
  left: 28px;
  width: 24px;
  height: 24px;
  background-color: var(--md-sys-color-on-primary);
}

.switch__input:focus-visible + .switch__track {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}
