/* ============================================================
   DicePassphrase Web — faithful port of the macOS Swift app
   Dark glassmorphic design with cyan/purple accents
   ============================================================ */

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

:root {
  --bg-base:       #0f1219;
  --bg-card:       rgba(255,255,255,0.1);
  --bg-card-hover: rgba(255,255,255,0.3);
  --border:        rgba(255,255,255,0.06);
  --border-hover:  rgba(255,255,255,0.12);
  --text:          #ffffff;
  --text-dim:      rgba(255,255,255,0.35);
  --text-faint:    rgba(255,255,255,0.60);
  --cyan:          #80d9ff;
  --cyan-glow:     rgba(128,217,255,0.25);
  --purple:        #d699ff;
  --green:         #4dffA0;
  --red:           #ff6666;
  --yellow:        #ffbe33;
  --font:          'SF Mono', 'Fira Code', 'Cascadia Mono', 'Consolas', monospace;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Background gradients ── */
body::before, body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
body::before {
  background: radial-gradient(ellipse at top left,
    rgba(38,20,76,0.60) 0%, transparent 55%);
}
body::after {
  background: radial-gradient(ellipse at bottom right,
    rgba(13,51,76,0.40) 0%, transparent 50%);
}

/* ── Layout ── */
#app {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  min-height: 540px;
}

/* ── Control panel (left sidebar) ── */
#panel {
  width: 300px;
  min-width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

/* ── Results panel (right) ── */
#results-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ── */
#header {
  padding: 28px 24px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#header img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}
.header-dice-icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}
#header-title {
  line-height: 1.2;
}
#header-title .bold  { font-size: 18px; font-weight: 900; color: #fff; }
#header-title .light { font-size: 18px; font-weight: 300; color: var(--cyan); }
#header-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ── Scroll area (controls) ── */
#controls-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
#controls-scroll::-webkit-scrollbar { width: 4px; }
#controls-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* ── Control sections ── */
.ctrl-section { margin-bottom: 28px; }
.ctrl-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* ── Language buttons ── */
#lang-grid {
  display: flex;
  gap: 6px;
}
.lang-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  background: rgba(255,255,255,0.1);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: var(--font);
  color: var(--text-dim);
}
.lang-btn:hover { background: rgba(255,255,255,0.3); }
.lang-btn.active {
  background: rgba(128,217,255,0.15);
  border-color: rgba(128,217,255,0.50);
  color: #fff;
}
.lang-btn .flag { font-size: 20px; line-height: 1; }
.lang-btn .code { font-size: 10px; font-weight: 600; }

/* ── Slider rows ── */
.slider-value-row {
  display: flex;
  align-items: flex-end;
  margin-bottom: 10px;
}
.slider-big-num {
  font-size: 36px;
  font-weight: 900;
  color: #fff;
  line-height: 1;
}
.slider-unit {
  font-size: 14px;
  font-weight: 300;
  color: var(--text-dim);
  margin-left: 8px;
  margin-bottom: 3px;
}
.slider-spacer { flex: 1; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
input[type="range"].cyan-slider {
  background: linear-gradient(to right, var(--cyan) var(--pct, 0%), rgba(255,255,255,0.1) var(--pct, 0%));
}
input[type="range"].purple-slider {
  background: linear-gradient(to right, var(--purple) var(--pct, 0%), rgba(255,255,255,0.1) var(--pct, 0%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px rgba(255,255,255,0.4);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  border: none;
}
.slider-range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-faint);
}

/* ── Entropy badge ── */
#entropy-badge {
  text-align: right;
}
#entropy-bits {
  font-size: 11px;
  font-weight: 700;
}
#entropy-label {
  font-size: 9px;
  margin-top: 1px;
}
.entropy-wrap {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid;
  text-align: right;
}

/* ── Toggle ── */
.toggle-row {
  display: flex;
  align-items: center;
}
.toggle-text { flex: 1; }
.toggle-text .tlabel { font-size: 13px; font-weight: 500; color: #fff; }
.toggle-text .tsub   { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.toggle-track {
  width: 44px; height: 26px;
  border-radius: 13px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.toggle-track.on {
  background: rgba(77,255,160,0.25);
  border-color: rgba(77,255,160,0.5);
}
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  transition: left 0.2s, background 0.2s, box-shadow 0.2s;
}
.toggle-track.on .toggle-thumb {
  left: 21px;
  background: var(--green);
  box-shadow: 0 0 8px rgba(77,255,160,0.5);
}

/* ── Generate button ── */
#generate-btn {
  margin: 0;
  padding: 20px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}
#gen-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--cyan), #5aa4f5);
  color: #000;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 0 16px rgba(128,217,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
#gen-btn:hover {
  background: linear-gradient(135deg, #b3edff, #7ab8ff);
  box-shadow: 0 0 24px rgba(128,217,255,0.50);
}
#gen-btn:active { transform: scale(0.97); }
#gen-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(0,0,0,0.3);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.generating .spinner { display: block; }
#gen-btn-text::after { content: attr(data-text); }

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

/* ── Results header ── */
#results-header {
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.results-hdr-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 2px;
  flex: 1;
}
#copy-all-btn {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s;
}
#copy-all-btn:hover { background: rgba(255,255,255,0.10); color: #fff; }

/* ── Results scroll ── */
#results-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
#results-scroll::-webkit-scrollbar { width: 4px; }
#results-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* ── Empty / info state ── */
#empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  max-width: 640px;
  margin: 0 auto;
}
#empty-state h2 {
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  margin-bottom: 8px;
}
#empty-state .hint {
  font-size: 12px;
  color: rgba(255,255,255,0.8);
  text-align: center;
  margin-bottom: 20px;
}
#empty-state .desc {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  line-height: 1.75;
  text-align: left;
}
#empty-state h3 {
  font-size: 12px;
  color: rgba(255,255,255,0.9);
  margin-bottom: 8px;
}

/* ── Result cards ── */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
  transition: background 0.1s, border-color 0.1s;
  animation: cardIn 0.1s ease both;
}
.result-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}
.result-card.copied {
  border-color: rgba(77,255,160,0.40);
}

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

.card-main {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 14px 16px;
}
.card-idx {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-faint);
  padding-top: 2px;
  white-space: nowrap;
}
.card-phrase {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  line-height: 1.6;
  word-break: break-all;
}
.card-copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  font-size: 24px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s;
  flex-shrink: 0;
}
.card-copy-btn:hover { color: rgba(255,255,255,0.8); }
.card-copy-btn.done  { color: var(--green); }

/* ── Verbose detail table ── */
.card-details {
  border-top: 1px solid var(--border);
  padding: 8px 16px 12px;
  background: rgba(255,255,255,0.02);
}
.card-details-head {
  display: grid;
  grid-template-columns: 40px 80px 1fr;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.card-details-row {
  display: grid;
  grid-template-columns: 40px 80px 1fr;
  font-size: 11px;
  color: rgba(255,255,255,0.50);
  padding: 2px 0;
}

/* ── Error state ── */
#error-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  text-align: center;
  padding: 40px;
}
#error-state .err-icon { font-size: 48px; opacity: 0.5; }
#error-state .err-title { font-size: 16px; font-weight: 700; color: rgba(255,255,255,0.6); }
#error-state .err-msg   { font-size: 12px; color: var(--text-dim); }

/* ── Responsive ── */
@media (max-width: 660px) {
  #app { flex-direction: column; height: auto; min-height: 100vh; }
  #panel { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  #results-pane { min-height: 400px; }
}

/* ── SVG dice icon (inline fallback) ── */
.dice-svg { width: 48px; height: 48px; }
