/* ===== CSS Variables & Reset ===== */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a26;
  --bg-elevated: #222233;
  --bg-hover: #2a2a3d;
  --bg-input: #16161f;
  --border-color: #2a2a3d;
  --border-light: #353550;
  --text-primary: #e8e8f0;
  --text-secondary: #9898b0;
  --text-muted: #6868808;
  --accent-primary: #6c5ce7;
  --accent-secondary: #a29bfe;
  --accent-gradient: linear-gradient(135deg, #6c5ce7, #a29bfe);
  --accent-glow: rgba(108, 92, 231, 0.3);
  --success: #00cec9;
  --success-bg: rgba(0, 206, 201, 0.1);
  --warning: #fdcb6e;
  --warning-bg: rgba(253, 203, 110, 0.1);
  --danger: #ff6b6b;
  --danger-bg: rgba(255, 107, 107, 0.1);
  --strength-weak: #ff6b6b;
  --strength-medium: #fdcb6e;
  --strength-strong: #00cec9;
  --strength-very-strong: #6c5ce7;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px var(--accent-glow);
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(108, 92, 231, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(162, 155, 254, 0.05), transparent);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ===== App Container ===== */
.app-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  min-height: 100vh;
}

/* ===== Header ===== */
.app-header {
  text-align: center;
  padding: 32px 0 28px;
}

.header-icon {
  font-size: 48px;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 12px var(--accent-glow));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.app-header h1 {
  font-size: 28px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 6px;
  letter-spacing: 4px;
}

/* ===== Mode Tabs ===== */
.mode-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 5px;
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
}

.mode-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition-normal);
  font-family: var(--font-sans);
}

.mode-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.mode-tab.active {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.tab-icon {
  font-size: 16px;
}

/* ===== Generator Panels ===== */
.generator-panel {
  display: none;
}

.generator-panel.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* ===== Password Display ===== */
.password-display {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
}

.password-output-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.password-output {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  word-break: break-all;
  line-height: 1.5;
  min-height: 54px;
  display: flex;
  align-items: center;
  letter-spacing: 0.5px;
  transition: border-color var(--transition-fast);
  overflow: hidden;
  position: relative;
}

.password-output:hover {
  border-color: var(--border-light);
}

.password-output.hidden-chars {
  color: var(--text-muted);
  letter-spacing: 3px;
}

.passphrase-output {
  font-size: 18px;
  font-family: var(--font-sans);
  font-weight: 600;
}

.pin-output {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 8px;
  justify-content: center;
  text-align: center;
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.btn-icon:hover {
  border-color: var(--accent-primary);
  color: var(--accent-secondary);
  background: var(--bg-hover);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

/* ===== Password Actions ===== */
.password-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}

.btn:hover {
  border-color: var(--accent-primary);
  background: var(--bg-hover);
  box-shadow: var(--shadow-glow);
}

.btn:active {
  transform: scale(0.97);
}

.btn-copy.copied {
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
}

/* ===== Strength Indicator ===== */
.strength-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
}

.strength-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  border-radius: 2px;
  transition: all var(--transition-slow);
  width: 0%;
}

.strength-fill.weak {
  width: 25%;
  background: var(--strength-weak);
}

.strength-fill.medium {
  width: 50%;
  background: var(--strength-medium);
}

.strength-fill.strong {
  width: 75%;
  background: var(--strength-strong);
}

.strength-fill.very-strong {
  width: 100%;
  background: var(--strength-very-strong);
}

.strength-label {
  font-size: 12px;
  font-weight: 600;
  min-width: 48px;
  text-align: right;
  transition: color var(--transition-normal);
}

.strength-label.weak { color: var(--strength-weak); }
.strength-label.medium { color: var(--strength-medium); }
.strength-label.strong { color: var(--strength-strong); }
.strength-label.very-strong { color: var(--strength-very-strong); }

/* ===== Options Section ===== */
.options-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-bottom: 20px;
}

.option-group {
  margin-bottom: 20px;
}

.option-group:last-child {
  margin-bottom: 0;
}

.option-group + .option-group {
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.option-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.option-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.option-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

/* ===== Length Control ===== */
.length-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.length-input {
  width: 64px;
  padding: 6px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-mono);
  text-align: center;
  outline: none;
  transition: border-color var(--transition-fast);
}

.length-input:focus {
  border-color: var(--accent-primary);
}

.length-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.length-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
  transition: transform var(--transition-fast);
}

.length-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.length-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ===== Checkbox Grid ===== */
.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  user-select: none;
}

.checkbox-item:hover {
  background: var(--bg-hover);
}

.checkbox-item.full-width {
  grid-column: 1 / -1;
}

.checkbox-item input[type="checkbox"],
.checkbox-item input[type="radio"] {
  display: none;
}

.checkbox-custom {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-light);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  position: relative;
}

.checkbox-item input:checked + .checkbox-custom {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.checkbox-item input:checked + .checkbox-custom::after {
  content: '';
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

.checkbox-text {
  font-size: 13px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.char-preview {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-input);
  padding: 1px 6px;
  border-radius: 3px;
}

.hint {
  color: var(--text-secondary);
  font-size: 12px;
}

/* ===== Radio Buttons ===== */
.radio-custom {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.radio-item input:checked + .radio-custom {
  border-color: var(--accent-primary);
}

.radio-item input:checked + .radio-custom::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  font-size: 13px;
  user-select: none;
}

.radio-item:hover {
  background: var(--bg-hover);
}

.radio-item input[type="radio"] {
  display: none;
}

.separator-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.custom-separator-input {
  margin-top: 10px;
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color var(--transition-fast);
}

.custom-separator-input:focus {
  border-color: var(--accent-primary);
}

/* ===== Batch Control ===== */
.batch-select {
  padding: 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: border-color var(--transition-fast);
}

.batch-select:focus {
  border-color: var(--accent-primary);
}

/* ===== Batch Results ===== */
.batch-results {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 20px 24px;
  margin-bottom: 20px;
  animation: fadeIn 0.3s ease;
}

.batch-results.hidden {
  display: none;
}

.batch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.batch-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-copy-all {
  padding: 5px 12px;
  font-size: 12px;
}

.batch-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.batch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  gap: 10px;
}

.batch-item:hover {
  background: var(--bg-hover);
}

.batch-item-text {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-primary);
  word-break: break-all;
  flex: 1;
}

.batch-item-copy {
  padding: 4px 8px;
  font-size: 11px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.batch-item-copy:hover {
  color: var(--accent-secondary);
  background: var(--bg-elevated);
}

/* ===== History Section ===== */
.history-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 20px 24px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.history-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-clear-history {
  padding: 4px 12px;
  font-size: 12px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}

.btn-clear-history:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-bg);
}

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

.history-empty {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 20px 0;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  gap: 10px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.history-item:hover {
  background: var(--bg-hover);
}

.history-item-text {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-all;
  flex: 1;
}

.history-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.history-item-copy {
  padding: 4px 8px;
  font-size: 11px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.history-item-copy:hover {
  color: var(--accent-secondary);
  background: var(--bg-elevated);
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.2s forwards;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success {
  border-color: var(--success);
  background: var(--success-bg);
}

.toast.error {
  border-color: var(--danger);
  background: var(--danger-bg);
}

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

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

/* ===== Footer ===== */
.app-footer {
  text-align: center;
  padding: 24px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
}

/* ===== Utility ===== */
.hidden {
  display: none !important;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .app-container {
    padding: 16px 14px 32px;
  }

  .app-header h1 {
    font-size: 24px;
  }

  .password-output {
    font-size: 16px;
    padding: 12px;
  }

  .pin-output {
    font-size: 26px;
  }

  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .mode-tab {
    padding: 8px 10px;
    font-size: 13px;
  }

  .tab-icon {
    font-size: 14px;
  }

  .password-actions {
    flex-direction: column;
  }

  .btn {
    justify-content: center;
  }
}

/* ===== Character Color Coding ===== */
.char-upper { color: #a29bfe; }
.char-lower { color: #e8e8f0; }
.char-number { color: #00cec9; }
.char-symbol { color: #fdcb6e; }

/* ===== Selection ===== */
::selection {
  background: var(--accent-primary);
  color: #fff;
}
