/*
 * Oruk Support Call — iPhone-style UI.
 * Framework-free. Dark call screen with the Oruk green accent.
 */

:root {
  --green: #34d39a;
  --green-deep: #16a97a;
  --red: #ff453a;
  --screen: #0a0d12;
  --panel: #151a22;
  --panel-2: #1c2430;
  --line: #2a3340;
  --fg: #f3f5f7;
  --muted: #8b97a6;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 700px at 50% -10%, #1a2733 0%, transparent 60%),
    linear-gradient(160deg, #0e1319, #0a0d12);
  color: var(--fg);
  min-height: 100dvh;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 2rem;
  padding: 2rem 1rem;
  -webkit-font-smoothing: antialiased;
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  max-width: 30rem;
}

/* ---------- Phone frame ---------- */

.phone {
  width: 380px;
  max-width: 92vw;
  height: min(86vh, 800px);
  background: #000;
  border-radius: 54px;
  padding: 12px;
  box-shadow:
    0 2px 0 2px #1c1c1e inset,
    0 40px 90px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.04);
  position: relative;
}
.screen {
  position: relative;
  height: 100%;
  border-radius: 44px;
  overflow: hidden;
  background: radial-gradient(120% 70% at 50% -10%, #172029 0%, var(--screen) 55%);
  display: flex;
  flex-direction: column;
}
.island {
  position: absolute;
  top: 11px;
  left: 50%;
  transform: translateX(-50%);
  width: 118px;
  height: 33px;
  background: #000;
  border-radius: 20px;
  z-index: 20;
}
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 26px 0;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--fg);
  flex-shrink: 0;
}
.status-icons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  fill: var(--fg);
}
.cbar,
.warc {
  transition: opacity 0.45s ease;
}
#battFill {
  transition: width 0.6s ease, fill 0.3s ease;
}
.home-indicator {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 128px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.35);
  z-index: 20;
}

/* ---------- Views ---------- */

.view {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  padding: 1.4rem 1.4rem 2.2rem;
}
.screen[data-view="dialer"] .view-dialer,
.screen[data-view="call"] .view-call,
.screen[data-view="ended"] .view-ended {
  display: flex;
}

/* ---------- Dialer ---------- */

.dial-top {
  text-align: center;
  padding: 2.2rem 0 1.1rem;
  min-height: 6.5rem;
}
.dial-display {
  font-size: 2.1rem;
  font-weight: 500;
  letter-spacing: 1px;
  min-height: 2.5rem;
  word-break: break-all;
}
.dial-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.4rem;
}
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.1rem 1.4rem;
  justify-items: center;
  margin: auto 0;
}
.key {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.09);
  color: var(--fg);
  display: grid;
  place-items: center;
  gap: 0;
  cursor: pointer;
  transition: background 0.12s, transform 0.05s;
  -webkit-tap-highlight-color: transparent;
}
.key:active {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(0.96);
}
.key .d {
  font-size: 1.9rem;
  font-weight: 400;
  line-height: 1;
}
.key .l {
  font-size: 0.56rem;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-top: 2px;
  height: 0.7rem;
}
.dial-actions {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-top: 1.4rem;
}
.dial-spacer {
  display: block;
}
.call-btn {
  grid-column: 2;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(160deg, var(--green), var(--green-deep));
  color: #04231a;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(52, 211, 154, 0.4);
  transition: transform 0.1s, filter 0.15s;
}
.call-btn:hover {
  filter: brightness(1.06);
}
.call-btn:active {
  transform: scale(0.95);
}
.del-btn {
  grid-column: 3;
  justify-self: center;
  width: 46px;
  height: 46px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.del-btn[hidden] {
  display: none;
}

/* ---------- Call ---------- */

.call-top {
  text-align: center;
  padding: 1.4rem 0 0.6rem;
  flex-shrink: 0;
}
.avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  margin: 0 auto 0.7rem;
  background: linear-gradient(160deg, #223, #101620);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.avatar.big {
  width: 100px;
  height: 100px;
}
.avatar img {
  opacity: 0.95;
}
.call-name {
  font-size: 1.5rem;
  font-weight: 600;
}
.call-number {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.15rem;
  min-height: 1rem;
}
.call-status {
  color: var(--green);
  font-size: 0.95rem;
  margin-top: 0.3rem;
  font-variant-numeric: tabular-nums;
}

.transcript {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.9rem 0.1rem;
  margin-top: 0.6rem;
}
.transcript::-webkit-scrollbar {
  width: 0;
}
.msg {
  max-width: 82%;
  padding: 0.6rem 0.8rem;
  border-radius: 1.1rem;
  font-size: 0.9rem;
  line-height: 1.4;
  animation: pop 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
.msg.agent {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-left-radius: 0.35rem;
}
.msg.caller {
  align-self: flex-end;
  background: linear-gradient(160deg, var(--green), var(--green-deep));
  color: #04231a;
  border-bottom-right-radius: 0.35rem;
}
.msg.caller.pending,
.msg.agent.pending {
  opacity: 0.75;
  font-style: italic;
}
.msg-emos {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.4rem;
}
.emo-chip {
  font-size: 0.66rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  color: #04231a;
  text-transform: capitalize;
}
.msg.agent .thinking {
  display: inline-flex;
  gap: 0.28rem;
}
.msg.agent .thinking span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite ease-in-out both;
}
.msg.agent .thinking span:nth-child(2) {
  animation-delay: 0.2s;
}
.msg.agent .thinking span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.sys-note {
  align-self: center;
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.7rem;
  margin: 0.15rem 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  animation: pop 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.call-hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  min-height: 1.1rem;
  margin-bottom: 0.6rem;
  flex-shrink: 0;
  transition: color 0.2s;
}
.call-hint.your-turn {
  color: var(--green);
  font-weight: 600;
}
.call-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3rem;
  flex-shrink: 0;
}
.round-btn {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--fg);
  transition: transform 0.1s, background 0.15s, box-shadow 0.2s;
}
.round-btn:active {
  transform: scale(0.94);
}
.mic-btn {
  background: rgba(255, 255, 255, 0.12);
}
.mic-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.mic-btn[data-state="ready"] {
  background: rgba(52, 211, 154, 0.16);
  color: var(--green);
  animation: mic-ready 1.6s ease-out infinite;
}
@keyframes mic-ready {
  0% {
    box-shadow: 0 0 0 0 rgba(52, 211, 154, 0.5);
    transform: scale(1);
  }
  70% {
    box-shadow: 0 0 0 18px rgba(52, 211, 154, 0);
    transform: scale(1.05);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(52, 211, 154, 0);
    transform: scale(1);
  }
}
.mic-btn[data-state="listening"] {
  background: var(--green);
  color: #04231a;
  box-shadow: 0 0 0 6px rgba(52, 211, 154, 0.22);
  animation: mic-pulse 1.3s ease-out infinite;
}
.mic-btn[data-state="thinking"] {
  background: rgba(255, 255, 255, 0.12);
}
@keyframes mic-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(52, 211, 154, 0.4);
  }
  100% {
    box-shadow: 0 0 0 22px rgba(52, 211, 154, 0);
  }
}
.end-btn {
  background: var(--red);
}

/* ---------- Ended ---------- */

.view-ended {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.4rem;
}
.ended-top {
  margin-top: -2rem;
}
.ended-label {
  color: var(--red);
  font-size: 1rem;
  margin-top: 0.5rem;
}
.ended-dur {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-top: 0.2rem;
}
.redial-btn {
  margin-top: 2rem;
  padding: 0.8rem 1.6rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--fg);
  font-size: 0.9rem;
  cursor: pointer;
}
.redial-btn:hover {
  border-color: var(--green);
}

/* ---------- Stage note + hints ---------- */

.stage-note {
  max-width: 26rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.55;
  margin: 0;
}
.stage-note strong {
  color: var(--fg);
  font-weight: 600;
}
.app-version {
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  margin: 0.2rem 0 0;
  opacity: 0.85;
}
.perm-hint {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-size: 0.82rem;
}
.perm-hint[hidden] {
  display: none;
}

/* ---------- Call report (operator / manager) ---------- */

.report {
  width: 480px;
  max-width: 92vw;
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.3rem 1.4rem 1.6rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  animation: report-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.report[hidden] {
  display: none;
}
@keyframes report-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}
.report-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.report-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}
.report-sub {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}
.report-head-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}
.report-export {
  border: 1px solid var(--green-deep);
  background: linear-gradient(160deg, var(--green), var(--green-deep));
  color: #04231a;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.report-export:hover {
  filter: brightness(1.06);
}
.report-export:disabled {
  opacity: 0.5;
  cursor: default;
  filter: none;
}
.report-close {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
}
.report-close:hover {
  color: var(--fg);
  border-color: var(--muted);
}

.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}
.meta-pill {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.4rem 0.7rem;
  min-width: 4.5rem;
}
.meta-k {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.meta-v {
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.report-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}
.report-badges:empty {
  margin-bottom: 0;
}
.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--c, var(--muted));
  color: var(--fg);
}
.badge.good {
  --c: var(--green);
}
.badge.warn {
  --c: #f5b74a;
}
.badge.bad {
  --c: #ff6b5e;
}

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.report-section {
  min-width: 0;
}
.report-section.span-2 {
  grid-column: 1 / -1;
}
.report-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 700;
}
.report-hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--muted);
  opacity: 0.75;
}
.report-body {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--fg);
}
.report-body .thinking {
  display: inline-flex;
  gap: 0.28rem;
  vertical-align: middle;
}
.report-body .thinking span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite ease-in-out both;
}
.report-body .thinking span:nth-child(2) {
  animation-delay: 0.2s;
}
.report-body .thinking span:nth-child(3) {
  animation-delay: 0.4s;
}
.report-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.88rem;
  line-height: 1.55;
}
.report-list li {
  margin-bottom: 0.2rem;
}
.report-list .muted {
  list-style: none;
  margin-left: -1.1rem;
  color: var(--muted);
}

.emo-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}
.emo-step {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--c);
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  font-size: 0.76rem;
}
.emo-step-n {
  display: grid;
  place-items: center;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: var(--c);
  color: #04231a;
  font-size: 0.62rem;
  font-weight: 700;
}
.emo-step-label {
  font-weight: 600;
}
.emo-step-score {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.report-transcript {
  max-height: 15rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding-right: 0.3rem;
}
.t-row {
  display: grid;
  grid-template-columns: 3.4rem 1fr;
  gap: 0.5rem;
  font-size: 0.84rem;
  line-height: 1.45;
  align-items: baseline;
}
.t-row .t-who {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--muted);
  padding-top: 0.1rem;
}
.t-row.caller .t-who {
  color: var(--green);
}
.t-text {
  color: var(--fg);
}
.t-emo {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.66rem;
  font-weight: 600;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--c);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
  }
}
