/* ===========================================================
   Diktat — stilovi
   Tamna tema podrazumevano, svetla preko prefers-color-scheme.
   =========================================================== */

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

:root {
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --bg-base: #0c0d11;
  --bg-glow-1: rgba(255, 107, 74, 0.16);
  --bg-glow-2: rgba(45, 212, 191, 0.10);

  --card-bg: rgba(255, 255, 255, 0.045);
  --card-border: rgba(255, 255, 255, 0.09);
  --card-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);

  --text-primary: #f3f4f7;
  --text-secondary: #9ba0ac;
  --text-muted: #6c7280;

  --accent: #ff6b4a;
  --accent-2: #ff3d3d;
  --accent-soft: rgba(255, 107, 74, 0.16);

  --action: #2dd4bf;
  --action-2: #14b8a6;
  --action-soft: rgba(45, 212, 191, 0.14);

  --danger: #ff5a5a;

  --input-bg: rgba(255, 255, 255, 0.06);
  --input-border: rgba(255, 255, 255, 0.14);

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-base: #f4f2ef;
    --bg-glow-1: rgba(255, 107, 74, 0.14);
    --bg-glow-2: rgba(20, 184, 166, 0.10);

    --card-bg: rgba(255, 255, 255, 0.72);
    --card-border: rgba(20, 20, 30, 0.08);
    --card-shadow: 0 20px 45px -22px rgba(60, 40, 30, 0.28);

    --text-primary: #211f1c;
    --text-secondary: #5d5951;
    --text-muted: #8b867d;

    --input-bg: rgba(20, 20, 30, 0.04);
    --input-border: rgba(20, 20, 30, 0.12);
  }
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-stack);
  color: var(--text-primary);
  background-color: var(--bg-base);
  background-image:
    radial-gradient(circle at 15% -10%, var(--bg-glow-1), transparent 55%),
    radial-gradient(circle at 100% 15%, var(--bg-glow-2), transparent 45%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p {
  margin: 0;
}

button {
  font-family: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Skladište stranice ---------- */

.app-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2rem;
  gap: 1.25rem;
}

/* Kada je vidljiva samo kartica za šifru, centriraj je lepo u prostoru */
.main-content:has(> .token-card:not([hidden])):not(:has(> .workspace:not([hidden]))) {
  justify-content: center;
  align-items: center;
  flex: 1;
}

/* ---------- Zaglavlje ---------- */

.site-header {
  width: 100%;
  border-bottom: 1px solid var(--card-border);
}

.site-header__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.brand-mark {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 6px 16px -4px rgba(255, 90, 60, 0.5);
}

.brand-mark svg {
  width: 20px;
  height: 20px;
}

.brand-text h1 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-text .subtitle {
  margin-top: 0.15rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.icon-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: 1.15rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, background 0.2s ease, border-color 0.2s ease;
}

.icon-btn:hover {
  border-color: var(--action);
  transform: rotate(35deg);
}

.icon-btn:active {
  transform: rotate(70deg) scale(0.94);
}

/* ---------- Kartice (opšti stil) ---------- */

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

/* ---------- Kartica za šifru ---------- */

.token-card {
  width: 100%;
  max-width: 420px;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  animation: cardIn 0.35s ease;
}

.token-card h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.token-hint {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.token-hint code {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  padding: 0.1rem 0.4rem;
  font-size: 0.85em;
}

.field-row {
  display: flex;
  gap: 0.6rem;
}

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

/* ---------- Polja ---------- */

.text-input,
.select-input {
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.text-input {
  flex: 1;
  min-width: 0;
}

.text-input:focus,
.select-input:focus {
  outline: none;
  border-color: var(--action);
  box-shadow: 0 0 0 3px var(--action-soft);
}

.select-input {
  width: 100%;
  cursor: pointer;
}

/* ---------- Dugmad ---------- */

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.1rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}

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

.btn-accent {
  background: linear-gradient(135deg, var(--action), var(--action-2));
  color: #04211d;
  box-shadow: 0 10px 22px -8px rgba(20, 184, 166, 0.55);
}

.btn-accent:hover {
  box-shadow: 0 12px 26px -6px rgba(20, 184, 166, 0.65);
}

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

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

.btn-danger.is-armed {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-text {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.4rem 0.2rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

/* ---------- Radni prostor ---------- */

.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 0;
  animation: cardIn 0.35s ease;
}

.controls {
  flex: 0 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.panel {
  flex: 1;
  min-height: 0;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.panel-actions {
  display: flex;
  gap: 0.5rem;
}

/* ---------- Izlazni tekst ---------- */

.output-wrap {
  position: relative;
  flex: 1;
  min-height: 40vh;
}

.output {
  width: 100%;
  height: 100%;
  min-height: 40vh;
  resize: vertical;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.output:focus {
  outline: none;
  border-color: var(--action);
  box-shadow: 0 0 0 3px var(--action-soft);
}

.empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.output:placeholder-shown + .empty-hint {
  opacity: 1;
}

.empty-hint svg {
  width: 42px;
  height: 42px;
  opacity: 0.5;
}

.empty-hint p {
  max-width: 26ch;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ---------- Zona za snimanje ---------- */

.record-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0 0.25rem;
}

.rec-btn {
  position: relative;
  width: 96px;
  height: 96px;
  min-width: 88px;
  min-height: 88px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  animation: recIdleGlow 3.2s ease-in-out infinite;
  transition: transform 0.15s ease, background 0.3s ease;
}

.rec-btn:hover {
  transform: translateY(-2px);
}

.rec-btn:active {
  transform: scale(0.96);
}

.rec-btn:disabled {
  cursor: not-allowed;
}

.rec-btn-icon {
  position: relative;
  z-index: 2;
  width: 32px;
  height: 32px;
  transition: opacity 0.2s ease;
}

.rec-btn-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent-2);
  opacity: 0;
  pointer-events: none;
}

.rec-btn-spinner {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.32);
  border-top-color: #fff;
  opacity: 0;
}

@keyframes recIdleGlow {
  0%, 100% {
    box-shadow: 0 8px 22px -6px rgba(255, 90, 60, 0.35), 0 0 0 0 rgba(255, 107, 74, 0.3);
  }
  50% {
    box-shadow: 0 10px 30px -4px rgba(255, 90, 60, 0.5), 0 0 0 9px rgba(255, 107, 74, 0);
  }
}

/* Stanje snimanja: crveni puls + prstenovi koji se šire */
.rec-btn.is-recording {
  background: linear-gradient(145deg, #ff4d4d, #d81e1e);
  animation: recPulse 1.4s ease-in-out infinite;
}

.rec-btn.is-recording .rec-btn-ring {
  animation: recRing 1.8s ease-out infinite;
}

.rec-btn.is-recording .rec-btn-ring--2 {
  animation-delay: 0.6s;
}

@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 60, 60, 0.55); }
  50% { box-shadow: 0 0 0 14px rgba(255, 60, 60, 0); }
}

@keyframes recRing {
  0% { opacity: 0.55; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.9); }
}

/* Stanje obrade: spinner, dugme onemogućeno */
.rec-btn.is-processing {
  animation: none;
  opacity: 0.85;
  box-shadow: 0 8px 20px -6px rgba(0, 0, 0, 0.4);
}

.rec-btn.is-processing .rec-btn-icon {
  opacity: 0;
}

.rec-btn.is-processing .rec-btn-spinner {
  opacity: 1;
  animation: recSpin 0.8s linear infinite;
}

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

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}

.rec-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- Opcije ---------- */

.option-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.option-row label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.option-row--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
}

.option-row--checkbox label {
  font-weight: 500;
}

.checkbox-input {
  width: 18px;
  height: 18px;
  accent-color: var(--action);
  cursor: pointer;
}

/* ---------- Status ---------- */

.status {
  min-height: 1.3em;
  font-size: 0.88rem;
  color: var(--accent);
  font-weight: 600;
}

.status:empty {
  color: transparent;
}

/* ---------- Podnožje ---------- */

.site-footer {
  text-align: center;
  padding: 1.25rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* ---------- Desktop raspored ---------- */

@media (min-width: 880px) {
  .workspace {
    flex-direction: row;
    align-items: flex-start;
  }

  .controls {
    flex: 0 0 340px;
  }

  .panel {
    flex: 1;
  }

  .output-wrap,
  .output {
    min-height: 60vh;
  }
}

/* ---------- Fokus dostupnost ---------- */

.btn:focus-visible,
.icon-btn:focus-visible,
.rec-btn:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 3px;
}

/* hidden atribut UVEK pobedjuje display pravila klasa */
[hidden] { display: none !important; }

/* ---------- Info o mikrofonu (VU metar) ---------- */

.mic-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.vu {
  display: inline-block;
  width: 120px;
  height: 6px;
  border-radius: 999px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  overflow: hidden;
}

.vu-bar {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--action), var(--accent));
  transition: width 90ms linear;
}

.mic-name {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
