/* ===================================================
   TOTP Generator — Dark security theme
   =================================================== */

:root {
  --bg-base: #0d1117;
  --bg-surface: #161b22;
  --bg-card: #1c2330;
  --bg-input: #0d1117;
  --border: #30363d;
  --border-focus: #388bfd;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-code: #79c0ff;
  --accent: #388bfd;
  --accent-hover: #4a98ff;
  --danger: #f85149;
  --warn: #d29922;
  --success: #3fb950;
  --ring-ok: #3fb950;
  --ring-warn: #d29922;
  --ring-danger: #f85149;
  --radius: 8px;
  --radius-lg: 12px;
}

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

html {
  font-size: 16px;
}

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.header-right {
  display: flex;
  gap: 8px;
}

/* ── Security warning ── */
.security-warning {
  background: #3d2b00;
  border-bottom: 1px solid #7d5a00;
  color: #e3b341;
  padding: 10px 24px;
  font-size: 0.78rem;
  line-height: 1.4;
}

/* ── Main ── */
.app-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-right {
  display: flex;
  gap: 8px;
}

/* ── Buttons ── */
button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, transform 0.1s;
  padding: 8px 14px;
  line-height: 1;
}

button:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

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

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #242d3d;
}

.btn-icon {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
}

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

.btn-add {
  font-size: 0.9rem;
  padding: 10px 18px;
}

/* ── Account cards ── */
.accounts-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 48px 0;
  font-size: 0.9rem;
}

.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: border-color 0.2s;
}

.account-card:hover {
  border-color: #444c56;
}

.card-left {
  flex: 1;
  min-width: 0;
}

.account-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-sublabel {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.code-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.otp-code {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", Consolas, "Liberation Mono", monospace;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-code);
  line-height: 1;
}

.btn-copy {
  background: transparent;
  color: var(--text-secondary);
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-copy:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border);
}

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

.card-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* ── Progress ring ── */
.progress-ring {
  flex-shrink: 0;
}

.ring-bg {
  stroke: var(--border);
}

.ring-fg {
  transition: stroke-dasharray 0.3s linear, stroke 0.3s;
  stroke-linecap: round;
}

.ring-text {
  font-size: 11px;
  font-weight: 700;
  fill: var(--text-secondary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.btn-delete {
  background: transparent;
  color: var(--text-secondary);
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
}

.btn-delete:hover {
  color: var(--danger);
  background: rgba(248, 81, 73, 0.1);
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.form-section {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-section label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"] {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 9px 12px;
  font-size: 0.875rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus {
  border-color: var(--border-focus);
}

input[type="number"] {
  width: auto;
  max-width: 80px;
}

.row-2col {
  display: flex;
  gap: 16px;
  align-items: center;
}

.row-2col label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .otp-code {
    font-size: 1.6rem;
  }

  .app-main {
    padding: 16px 12px;
  }

  .header-left {
    flex-direction: column;
    gap: 2px;
    align-items: flex-start;
  }
}
