/* style.css — 密码管理器样式 */
/* 深色背景 + 毛玻璃卡片 + 移动端优先 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0f0f1a;
  --card-bg: rgba(30, 30, 50, 0.7);
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #e0e0e8;
  --text-muted: #8888aa;
  --accent: #6c63ff;
  --accent-hover: #5a52e0;
  --danger: #ff4d6a;
  --success: #4dff91;
  --warning: #ffd24d;
  --radius: 16px;
  --radius-sm: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  transition: background 0.5s ease;
}

/* 背景装饰 */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 20%, rgba(108, 99, 255, 0.08) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(255, 77, 106, 0.06) 0%, transparent 50%);
  z-index: -1;
  transition: background 0.5s ease;
}

.hidden {
  display: none !important;
}

/* ——— 视图容器 ——— */
.view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* ——— 卡片 ——— */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.center-card {
  text-align: center;
}

.center-card h1 {
  font-size: 1.8em;
  margin-bottom: 8px;
  font-weight: 700;
}

.center-card .hint {
  color: var(--text-muted);
  font-size: 0.9em;
  margin-bottom: 20px;
}

/* ——— 输入框 ——— */
input[type="text"],
input[type="password"],
select {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1em;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 12px;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

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

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238888aa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

/* ——— 按钮 ——— */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  padding: 10px 20px;
  background: rgba(108, 99, 255, 0.2);
  color: var(--accent);
  border: 1px solid rgba(108, 99, 255, 0.3);
  border-radius: var(--radius-sm);
  font-size: 0.9em;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: rgba(108, 99, 255, 0.3);
}

.btn-ghost {
  padding: 10px 20px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
  cursor: pointer;
  transition: color 0.2s;
}

.btn-ghost:hover {
  color: var(--text);
}

.btn-danger {
  padding: 10px 20px;
  background: rgba(255, 77, 106, 0.15);
  color: var(--danger);
  border: 1px solid rgba(255, 77, 106, 0.3);
  border-radius: var(--radius-sm);
  font-size: 0.9em;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-danger:hover {
  background: rgba(255, 77, 106, 0.25);
}

.btn-icon {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  font-size: 1.2em;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-icon-sm {
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-icon-sm:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ——— 密码强度条 ——— */
.strength-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-bottom: 4px;
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: width 0.3s, background 0.3s;
}

.strength-text {
  font-size: 0.8em;
  color: var(--text-muted);
  margin-bottom: 12px;
  min-height: 1.2em;
}

.error-text {
  color: var(--danger);
  font-size: 0.85em;
  margin-top: 12px;
}

/* ——— 主界面头部 ——— */
.main-header {
  width: 100%;
  max-width: 640px;
  padding: 16px 20px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-bar {
  width: 100%;
}

.search-bar input {
  margin-bottom: 0;
}

.header-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ——— 分类标签栏 ——— */
.tag-bar {
  width: 100%;
  max-width: 640px;
  padding: 12px 20px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tag-btn {
  padding: 6px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 0.85em;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.tag-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.tag-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.1);
}

/* ——— 密码列表 ——— */
.vault-list {
  width: 100%;
  max-width: 640px;
  padding: 0 20px 100px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.vault-item {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.1s;
}

.vault-item:hover {
  border-color: rgba(108, 99, 255, 0.3);
}

.vault-item:active {
  transform: scale(0.99);
}

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

.vault-item-name {
  font-weight: 600;
  font-size: 1.05em;
}

.vault-item-tag {
  font-size: 0.75em;
  padding: 3px 10px;
  background: rgba(108, 99, 255, 0.15);
  color: var(--accent);
  border-radius: 12px;
  transition: background 0.3s, color 0.3s;
}

.vault-item-username {
  color: var(--text-muted);
  font-size: 0.85em;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.vault-item-detail {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.vault-item-url {
  font-size: 0.8em;
  color: var(--text-muted);
  margin-bottom: 8px;
  word-break: break-all;
}

.password-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px 14px;
  border-radius: 10px;
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.95em;
}

.password-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: all;
}

.vault-item-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: flex-end;
}

/* ——— 浮动按钮 ——— */
.fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.8em;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(108, 99, 255, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(108, 99, 255, 0.5);
}

/* ——— 表单 ——— */
.form-card {
  max-width: 480px;
  margin: 0 auto;
}

.form-card h2 {
  margin-bottom: 20px;
  font-size: 1.4em;
}

.form-card label {
  display: block;
  font-size: 0.85em;
  color: var(--text-muted);
  margin-bottom: 4px;
  margin-top: 8px;
}

.form-card label:first-of-type {
  margin-top: 0;
}

.password-field {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
}

.password-field input {
  flex: 1;
  margin-bottom: 0;
}

.generator {
  margin-top: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
}

.gen-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.gen-controls input[type="range"] {
  flex: 1;
  margin-bottom: 0;
  accent-color: var(--accent);
}

.gen-controls span {
  font-size: 0.85em;
  color: var(--text-muted);
  min-width: 40px;
  text-align: center;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 24px;
}

/* ——— 历史密码 ——— */
.history-section {
  margin-top: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
}

.history-section > label {
  display: block;
  font-size: 0.85em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 8px;
}

.history-pwd {
  flex: 1;
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 0.85em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: all;
}

.history-date {
  font-size: 0.75em;
  color: var(--text-muted);
  white-space: nowrap;
}

.form-actions .btn-primary {
  flex: 1;
}

/* ——— 健康仪表盘 ——— */
.health-stats {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

.health-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
}

.health-label {
  font-size: 0.9em;
}

.health-value {
  font-size: 1.4em;
  font-weight: 700;
}

.health-good {
  color: var(--success);
}

.health-warn {
  color: var(--warning);
}

.health-bad {
  color: var(--danger);
}

/* ——— Toast 通知 ——— */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: rgba(40, 40, 60, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  font-size: 0.9em;
  z-index: 100;
  transition: opacity 0.3s;
  pointer-events: none;
}

/* ——— 空状态 ——— */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 1.1em;
  margin-bottom: 8px;
}

/* ——— 主题面板 ——— */
.theme-panel {
  width: 100%;
  max-width: 640px;
  padding: 0 20px;
  margin-bottom: 8px;
}

.theme-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
}

.theme-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid transparent;
  border-radius: 10px;
  color: var(--text);
  font-size: 0.85em;
  cursor: pointer;
  transition: all 0.2s;
}

.theme-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.theme-btn.active {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.theme-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ——— 响应式 ——— */
@media (min-width: 768px) {
  .main-header {
    flex-direction: row;
    align-items: center;
    padding: 24px 0 0;
  }

  .search-bar {
    flex: 1;
  }

  .vault-list {
    padding: 0 0 100px;
  }

  .tag-bar {
    padding: 16px 0;
  }
}

@media (max-width: 480px) {
  .card {
    padding: 24px 20px;
  }

  .center-card h1 {
    font-size: 1.5em;
  }

  .header-actions {
    gap: 6px;
  }

  .btn-icon {
    width: 36px;
    height: 36px;
    font-size: 1em;
  }
}
