/**
 * HBili 客户端 - Material Design 3 样式
 * 使用 Beer CSS + MD3 设计系统
 */

@import url('./beercss/beer.min.css');

/* ==================== MD3 颜色系统 ==================== */

html.light-theme {
  /* Primary Color System */
  --md-primary: #6750a4;
  --md-on-primary: #ffffff;
  --md-primary-container: #eaddff;
  --md-on-primary-container: #21005e;
  
  /* Secondary Color System */
  --md-secondary: #625b71;
  --md-on-secondary: #ffffff;
  --md-secondary-container: #e8def8;
  --md-on-secondary-container: #1e192b;
  
  /* Tertiary Color System */
  --md-tertiary: #7d5260;
  --md-on-tertiary: #ffffff;
  --md-tertiary-container: #ffd8e4;
  --md-on-tertiary-container: #31111d;
  
  /* Error Color System */
  --md-error: #b3261e;
  --md-on-error: #ffffff;
  --md-error-container: #f9dedc;
  --md-on-error-container: #410e0b;
  
  /* Neutral Color System */
  --md-background: #fffbfe;
  --md-on-background: #1c1b1f;
  --md-surface: #fffbfe;
  --md-on-surface: #1c1b1f;
  --md-on-surface-variant: #6c6c70;
  --md-surface-dim: #ddd7e0;
  --md-surface-bright: #fffbfe;
  --md-surface-container-lowest: #ffffff;
  --md-surface-container-low: #f7f2fa;
  --md-surface-container: #f3eef9;
  --md-surface-container-high: #ede9f3;
  --md-surface-container-highest: #e8e3ed;
  
  /* Outline */
  --md-outline: #79747e;
  --md-outline-variant: #cac4d0;
  
  /* Scrim */
  --md-scrim: #000000;
  
  /* Shadow Color */
  --md-shadow: rgba(0, 0, 0, 0.15);
  --md-shadow-sm: rgba(0, 0, 0, 0.1);
  
  /* Custom */
  --text-primary: #1c1b1f;
  --text-secondary: #6c6c70;
  --card-bg: #f3eef9;
  --border-color: #cac4d0;
}

html.dark-theme {
  /* Primary Color System */
  --md-primary: #d0bcff;
  --md-on-primary: #371e55;
  --md-primary-container: #4f378b;
  --md-on-primary-container: #eaddff;
  
  /* Secondary Color System */
  --md-secondary: #ccc7f0;
  --md-on-secondary: #332d41;
  --md-secondary-container: #4a4458;
  --md-on-secondary-container: #e8def8;
  
  /* Tertiary Color System */
  --md-tertiary: #f0b8d1;
  --md-on-tertiary: #492532;
  --md-tertiary-container: #633b48;
  --md-on-tertiary-container: #ffd8e4;
  
  /* Error Color System */
  --md-error: #f2b8b5;
  --md-on-error: #601410;
  --md-error-container: #8c1d18;
  --md-on-error-container: #f9dedc;
  
  /* Neutral Color System */
  --md-background: #1c1b1f;
  --md-on-background: #e8e3ed;
  --md-surface: #1c1b1f;
  --md-on-surface: #e8e3ed;
  --md-surface-dim: #0f0e14;
  --md-surface-bright: #3a3840;
  --md-surface-container-lowest: #0f0e14;
  --md-surface-container-low: #26252c;
  --md-surface-container: #2e2d34;
  --md-surface-container-high: #39373f;
  --md-surface-container-highest: #44424a;
  
  /* Outline */
  --md-outline: #9e9da7;
  --md-outline-variant: #49454e;
  
  /* Scrim */
  --md-scrim: #000000;
  
  /* Shadow Color */
  --md-shadow: rgba(0, 0, 0, 0.3);
  --md-shadow-sm: rgba(0, 0, 0, 0.2);
  
  /* Custom */
  --text-primary: #e8e3ed;
  --text-secondary: #9e9da7;
  --card-bg: #2e2d34;
  --border-color: #49454e;
}

/* ==================== 全局样式 ==================== */

* {
  box-sizing: border-box;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--md-background);
  color: var(--md-on-background);
}

body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background-color: var(--md-surface);
  color: var(--md-on-surface);
}

/* ==================== MD3 排版系统 ==================== */

/* Display Styles */
h1, .md-display-large {
  font-size: 57px;
  line-height: 64px;
  font-weight: 400;
  letter-spacing: -0.25px;
}

.md-display-medium {
  font-size: 45px;
  line-height: 52px;
  font-weight: 400;
  letter-spacing: 0px;
}

.md-display-small {
  font-size: 36px;
  line-height: 44px;
  font-weight: 400;
  letter-spacing: 0px;
}

/* Headline Styles */
h2, .md-headline-large {
  font-size: 32px;
  line-height: 40px;
  font-weight: 400;
  letter-spacing: 0px;
}

.md-headline-medium {
  font-size: 28px;
  line-height: 36px;
  font-weight: 400;
  letter-spacing: 0px;
}

.md-headline-small {
  font-size: 24px;
  line-height: 32px;
  font-weight: 400;
  letter-spacing: 0px;
}

/* Title Styles */
h3, .md-title-large {
  font-size: 22px;
  line-height: 28px;
  font-weight: 500;
  letter-spacing: 0px;
}

.md-title-medium {
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  letter-spacing: 0.15px;
}

.md-title-small {
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  letter-spacing: 0.1px;
}

/* Body Styles */
p, body, .md-body-large {
  font-size: 16px;
  line-height: 24px;
  font-weight: 400;
  letter-spacing: 0.5px;
}

.md-body-medium {
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  letter-spacing: 0.25px;
}

.md-body-small {
  font-size: 12px;
  line-height: 16px;
  font-weight: 400;
  letter-spacing: 0.4px;
}

/* Label Styles */
.md-label-large {
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  letter-spacing: 0.1px;
}

.md-label-medium {
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.md-label-small {
  font-size: 11px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* ==================== MD3 组件样式 ==================== */

/* 按钮 */
button, [role="button"] {
  border-radius: 100px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--md-shadow-sm);
  color: var(--md-on-primary);
  background-color: var(--md-primary);
}

button:hover {
  box-shadow: var(--md-shadow);
  background-color: #5f4896;
}

button:active {
  box-shadow: var(--md-shadow-sm);
}

button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

/* 按钮变体 */
button.outline {
  background-color: transparent;
  border: 1px solid var(--md-outline);
  color: var(--md-primary);
  box-shadow: none;
  border-radius: 8px;
}

button.outline:hover {
  background-color: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
}

/* 主要按钮 */
button.primary {
  background-color: var(--md-primary);
  color: var(--md-on-primary);
}

button.primary:hover {
  background-color: #5f4896;
}

@media (prefers-color-scheme: dark) {
  button.primary:hover {
    background-color: #7f6aaa;
  }
}

button.outline:hover {
  background-color: rgba(103, 80, 164, 0.08);
  box-shadow: none;
}

button.text {
  background-color: transparent;
  color: var(--md-primary);
  padding: 10px 12px;
  box-shadow: none;
}

button.text:hover {
  background-color: rgba(103, 80, 164, 0.08);
}

button.filled-tonal {
  background-color: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  box-shadow: none;
}

button.filled-tonal:hover {
  background-color: #d0c4dd;
  box-shadow: var(--md-shadow-sm);
}

/* 主题按钮 */
.theme-btn {
  background-color: var(--md-surface-container);
  color: var(--md-on-surface-variant);
}

.theme-btn:hover {
  background-color: var(--md-surface-container-high);
}

/* 卡片 */
.card {
  background-color: var(--md-surface-container);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px var(--md-shadow-sm);
  border: 1px solid var(--md-outline-variant);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
  box-shadow: 0 4px 8px var(--md-shadow);
}

.card.elevated {
  box-shadow: 0 3px 8px var(--md-shadow-sm);
  border: none;
}

.card.elevated:hover {
  box-shadow: 0 6px 12px var(--md-shadow);
}

/* 输入框 */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border: 1px solid var(--md-outline-variant);
  border-radius: 8px;
  background-color: var(--md-surface-container-high);
  color: var(--md-on-surface);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

html.dark-theme input[type="text"],
html.dark-theme input[type="password"],
html.dark-theme input[type="email"],
html.dark-theme input[type="number"],
html.dark-theme select,
html.dark-theme textarea {
  background-color: var(--md-surface-container-high) !important;
  color: var(--md-on-surface) !important;
  border-color: var(--md-outline-variant) !important;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--md-primary);
  box-shadow: 0 0 0 3px rgba(103, 80, 164, 0.1);
  background-color: var(--md-surface);
}

input[type="text"]::placeholder,
input[type="password"]::placeholder,
input[type="email"]::placeholder,
input[type="number"]::placeholder,
textarea::placeholder {
  color: var(--md-outline);
}

/* 单选框 / 复选框 */
input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--md-primary);
}

/* ==================== 导航栏 ==================== */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 80px;
  height: 100vh;
  background-color: var(--md-surface);
  border-right: 1px solid var(--md-outline-variant);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 12px;
  z-index: 1000;
  box-shadow: 0 0 4px var(--md-shadow-sm);
}

.nav-item {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  color: var(--md-on-surface-variant, var(--md-on-surface));
  border: none;
  cursor: pointer;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: none;
}

.nav-item:hover {
  background-color: rgba(103, 80, 164, 0.08);
  box-shadow: none;
}

.nav-item.active {
  background-color: var(--md-primary-container);
  color: var(--md-on-primary-container);
}

.nav-item svg {
  width: 28px;
  height: 28px;
  stroke-width: 2;
  fill: none;
  stroke: currentColor;
}

/* ==================== 主容器 ==================== */

main {
  margin-left: 80px;
  padding: 24px;
  background-color: var(--md-background);
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* ==================== 卡片网格 ==================== */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.video-card {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px var(--md-shadow-sm);
  background-color: var(--md-surface-container);
}

.video-card:hover {
  box-shadow: 0 8px 16px var(--md-shadow);
  transform: translateY(-2px);
}

.video-card-thumbnail {
  width: 100%;
  height: 158px;
  background-color: var(--md-surface-dim);
  object-fit: cover;
}

.video-card-content {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.video-card-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--md-on-surface);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-card-author {
  font-size: 12px;
  color: var(--md-on-surface-variant, var(--md-on-surface));
}

.video-card-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--md-on-surface-variant, var(--md-on-surface));
}

.video-stat {
  display: flex;
  gap: 4px;
  align-items: center;
}

.video-cover {
  position: relative;
  width: 100%;
  height: 158px;
  background-color: var(--md-surface-dim);
  overflow: hidden;
}

.video-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-duration {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
}

.video-info {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ==================== 用户卡片 ==================== */

.user-card {
  background-color: var(--md-primary-container);
  color: var(--md-on-primary-container);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 24px;
  box-shadow: 0 3px 8px var(--md-shadow-sm);
}

.user-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 3px solid rgba(255, 255, 255, 0.2);
}

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

.user-name {
  font-size: 24px;
  font-weight: 500;
  margin: 0 0 4px 0;
}

.user-sign {
  font-size: 14px;
  opacity: 0.9;
  margin: 0;
}

/* ==================== 视频播放器 ==================== */

.video-player-container {
  background-color: var(--md-surface-dim);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: 0 3px 8px var(--md-shadow-sm);
}

video {
  width: 100%;
  height: auto;
  display: block;
}

/* 控制条 */
.video-controls {
  display: flex;
  gap: 12px;
  padding: 16px;
  background-color: var(--md-surface-container);
  flex-wrap: wrap;
  align-items: center;
  border-top: 1px solid var(--md-outline-variant);
}

.video-controls select {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  min-width: 120px;
}

/* ==================== 对话框 ==================== */

dialog {
  border: none;
  border-radius: 16px;
  background-color: var(--md-surface-container);
  color: var(--md-on-surface);
  box-shadow: 0 11px 15px -7px var(--md-shadow), 0 24px 38px 3px var(--md-shadow);
  max-width: 512px;
  padding: 0;
}

dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.32);
}

dialog > div {
  padding: 24px;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background-color: var(--md-surface-container);
  color: var(--md-on-surface);
  border-radius: 16px;
  box-shadow: 0 11px 15px -7px var(--md-shadow), 0 24px 38px 3px var(--md-shadow);
  max-width: 380px;
  width: 90%;
  padding: 24px;
  text-align: center;
}

.dialog-header {
  margin-bottom: 16px;
}

.dialog-title {
  font-size: 24px;
  font-weight: 500;
  margin: 0;
}

.dialog-content {
  margin-bottom: 16px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

/* ==================== Toast / 通知 ==================== */

.toast {
  position: fixed;
  bottom: 24px;
  left: 80px;
  right: 24px;
  background-color: var(--md-inverse-surface);
  color: var(--md-inverse-on-surface, var(--md-on-surface));
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 3px 8px var(--md-shadow);
  z-index: 2000;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ==================== 加载动画 ==================== */

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--md-outline-variant);
  border-top-color: var(--md-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--md-on-surface-variant, var(--md-on-surface));
}

.loading .spinner {
  width: 32px;
  height: 32px;
}

.alert {
  padding: 16px;
  border-radius: 8px;
  margin: 16px 0;
}

.alert.error {
  background-color: var(--md-error-container);
  color: var(--md-on-error-container);
}

.alert.info {
  background-color: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
}

.page-container {
  max-width: 1200px;
  margin: 0 auto;
}

/* ==================== 标签 ==================== */

.tag {
  display: inline-block;
  background-color: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  margin: 4px 4px 4px 0;
}

.tag:hover {
  background-color: #d0c4dd;
}

/* ==================== 布局工具类 ==================== */

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gap-8 {
  gap: 8px;
}

.gap-12 {
  gap: 12px;
}

.gap-16 {
  gap: 16px;
}

.gap-24 {
  gap: 24px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-24 {
  margin-top: 24px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-12 {
  margin-bottom: 12px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-24 {
  margin-bottom: 24px;
}

.p-8 {
  padding: 8px;
}

.p-12 {
  padding: 12px;
}

.p-16 {
  padding: 16px;
}

.p-24 {
  padding: 24px;
}

/* ==================== 响应式设计 ==================== */

@media (max-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 60px;
  }

  main {
    margin-left: 60px;
    padding: 16px;
  }

  .nav-item {
    width: 48px;
    height: 48px;
  }

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

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
  }

  .user-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .video-controls {
    gap: 8px;
    padding: 12px;
  }

  .video-controls select {
    min-width: 100px;
    font-size: 11px;
  }

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .sidebar {
    width: 50px;
  }

  main {
    margin-left: 50px;
    padding: 12px;
  }

  .nav-item {
    width: 44px;
    height: 44px;
  }

  .nav-item svg {
    width: 20px;
    height: 20px;
  }

  .card-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  h1, .md-display-large {
    font-size: 32px;
    line-height: 40px;
  }

  h2, .md-headline-large {
    font-size: 24px;
    line-height: 32px;
  }

  .video-controls {
    flex-direction: column;
  }

  .video-controls select {
    width: 100%;
  }

  .user-card {
    padding: 16px;
  }

  .user-avatar {
    width: 64px;
    height: 64px;
  }

  .toast {
    left: 50px;
    right: 12px;
  }

  button {
    padding: 8px 16px;
    border-radius: 8px;
  }
}

/* ==================== MD3 深色主题特殊处理 ==================== */

html.dark-theme .card {
  background-color: var(--md-surface-container);
  box-shadow: 0 1px 3px var(--md-shadow);
}

html.dark-theme .video-card {
  background-color: var(--md-surface-container);
}

html.dark-theme .user-card {
  background-color: var(--md-primary-container);
}

html.dark-theme input[type="text"]:focus,
html.dark-theme input[type="password"]:focus,
html.dark-theme input[type="email"]:focus,
html.dark-theme input[type="number"]:focus,
html.dark-theme select:focus,
html.dark-theme textarea:focus {
  background-color: var(--md-surface-container-high);
  box-shadow: 0 0 0 3px rgba(208, 188, 255, 0.1);
}
