/* ========================================
   GUARDIANO v4.0 — Retro Pixel Phone UI
   ======================================== */

:root {
  --bg: #0a0a12;
  --phone-bg: #111118;
  --screen-bg: #0d0d18;
  --surface: #151520;
  --surface-2: #1c1c2a;
  --border: #2a2a40;
  --text: #d0d0e0;
  --text-muted: #606080;
  --pixel-green: #00e436;
  --pixel-red: #ff004d;
  --pixel-yellow: #ffec27;
  --pixel-blue: #29adff;
  --pixel-purple: #7e2553;
  --pixel-cyan: #00e4ff;
  --pixel-orange: #ffa300;
  --success: #00e436;
  --warning: #ffa300;
  --danger: #ff004d;
  --critical: #ff004d;
  --primary: #29adff;
  --font-pixel: 'Press Start 2P', cursive;
  --font-mono: 'Share Tech Mono', 'Courier New', monospace;
}

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

body {
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* Scanline overlay */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
}

/* ===== PHONE FRAME ===== */
.phone-frame {
  width: 400px;
  height: min(780px, 100vh);
  height: min(780px, 100dvh);
  background: #1a1a28;
  border-radius: 40px;
  border: 3px solid #333348;
  box-shadow:
    0 0 0 2px #0a0a12,
    0 0 40px rgba(41,173,255,0.1),
    0 0 80px rgba(41,173,255,0.05),
    inset 0 0 30px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.phone-bezel-top {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a28;
  flex-shrink: 0;
}

.bezel-cam {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #222238;
  border: 2px solid #333348;
}

.phone-bezel-bottom {
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a28;
  flex-shrink: 0;
}

.bezel-bar {
  width: 100px;
  height: 4px;
  border-radius: 2px;
  background: #333348;
}

.phone-screen {
  flex: 1;
  background: var(--screen-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ===== STATUS BAR ===== */
.status-bar {
  display: flex;
  justify-content: space-between;
  padding: 4px 16px;
  font-family: var(--font-pixel);
  font-size: 6px;
  color: var(--text-muted);
  background: rgba(0,0,0,0.3);
  flex-shrink: 0;
}

.status-bar-icons { letter-spacing: 2px; }

/* ===== CALLER INFO ===== */
.caller-info {
  text-align: center;
  padding: 12px 16px 8px;
  flex-shrink: 0;
}

.pixel-avatar {
  width: 48px;
  height: 48px;
  margin: 0 auto 6px;
  background: var(--surface-2);
  border: 2px solid var(--pixel-blue);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(41,173,255,0.3);
  position: relative;
}

.pixel-shield-icon {
  width: 20px;
  height: 24px;
  background: var(--pixel-blue);
  clip-path: polygon(50% 0%, 100% 20%, 100% 65%, 50% 100%, 0% 65%, 0% 20%);
  image-rendering: pixelated;
}

.app-title {
  font-family: var(--font-pixel);
  font-size: 14px;
  color: var(--pixel-cyan);
  text-shadow: 0 0 10px rgba(0,228,255,0.5), 0 0 20px rgba(0,228,255,0.2);
  letter-spacing: 2px;
  margin-bottom: 2px;
}

.caller-name {
  font-family: var(--font-pixel);
  font-size: 7px;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.call-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-pixel);
  font-size: 7px;
}

.call-status {
  color: var(--pixel-green);
  text-shadow: 0 0 6px rgba(0,228,54,0.4);
}

.call-status.recording {
  color: var(--pixel-red);
  text-shadow: 0 0 6px rgba(255,0,77,0.5);
  animation: blink 1s infinite;
}

.call-status.connected {
  color: var(--pixel-green);
  text-shadow: 0 0 6px rgba(0,228,54,0.5);
}

.meta-sep { color: var(--border); }

.call-timer {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.tab {
  flex: 1;
  padding: 6px;
  border: 2px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-pixel);
  font-size: 7px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  letter-spacing: 1px;
}

.tab:hover { border-color: var(--pixel-blue); color: var(--text); }
.tab.active {
  background: var(--pixel-blue);
  border-color: var(--pixel-blue);
  color: #000;
  box-shadow: 0 0 8px rgba(41,173,255,0.3);
}

.tab-content { display: none; }
.tab-content.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ===== VISUALIZER ===== */
.visualizer-container {
  margin: 0 16px 4px;
  border: 2px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  flex-shrink: 0;
}
.visualizer-container.hidden { display: none; }

#visualizer {
  width: 100%;
  display: block;
  image-rendering: pixelated;
}

/* ===== SCROLL AREA ===== */
.scroll-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 16px;
  min-height: 0;
  overflow: hidden;
}

.panel {
  margin-bottom: 8px;
  flex-shrink: 0;
}

.panel:last-child {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  min-height: 0;
}

.panel h3 {
  font-family: var(--font-pixel);
  font-size: 6px;
  color: var(--pixel-blue);
  letter-spacing: 2px;
  margin-bottom: 4px;
  text-shadow: 0 0 6px rgba(41,173,255,0.3);
}

.content-box {
  background: var(--surface);
  border: 2px solid var(--border);
  padding: 8px;
  height: 120px;
  overflow-y: auto;
}

.panel:last-child .content-box {
  height: auto;
  flex: 1;
  min-height: 0;
}

.placeholder {
  font-family: var(--font-pixel);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.8;
}

/* ===== TRANSCRIPT ===== */
.transcript-box .chunk {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 32px;
  line-height: 1.4;
  color: var(--pixel-green);
  animation: fadeIn 0.3s;
}

.transcript-box .chunk:last-child { border-bottom: none; }

.chunk .chunk-idx {
  color: var(--pixel-blue);
  font-family: var(--font-pixel);
  font-size: 14px;
  margin-right: 8px;
}

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

/* ===== ANALYSIS RESULT ===== */
.analysis-result { animation: fadeIn 0.3s; }

.risk-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  margin-bottom: 6px;
  font-family: var(--font-pixel);
  font-size: 9px;
  border: 2px solid;
  letter-spacing: 1px;
}

.risk-low {
  background: rgba(0,228,54,0.1);
  color: var(--pixel-green);
  border-color: var(--pixel-green);
  box-shadow: 0 0 8px rgba(0,228,54,0.2);
}
.risk-medium {
  background: rgba(255,163,0,0.1);
  color: var(--pixel-orange);
  border-color: var(--pixel-orange);
  box-shadow: 0 0 8px rgba(255,163,0,0.2);
}
.risk-high {
  background: rgba(255,0,77,0.1);
  color: var(--pixel-red);
  border-color: var(--pixel-red);
  box-shadow: 0 0 8px rgba(255,0,77,0.2);
}
.risk-critical {
  background: rgba(255,0,77,0.15);
  color: var(--pixel-red);
  border-color: var(--pixel-red);
  box-shadow: 0 0 12px rgba(255,0,77,0.4);
  animation: dangerPulse 0.5s infinite;
}

@keyframes dangerPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(255,0,77,0.4); }
  50% { box-shadow: 0 0 20px rgba(255,0,77,0.7); }
}

.confidence-bar {
  height: 4px;
  background: var(--surface-2);
  margin-bottom: 6px;
  border: 1px solid var(--border);
}

.confidence-fill {
  height: 100%;
  transition: width 0.5s;
  image-rendering: pixelated;
}

.patterns-list {
  list-style: none;
  margin-bottom: 6px;
}

.patterns-list li {
  padding: 6px 0;
  font-family: var(--font-mono);
  font-size: 26px;
  color: var(--text);
  line-height: 1.4;
}

.patterns-list li::before {
  content: "> ";
  color: var(--pixel-yellow);
  font-family: var(--font-pixel);
  font-size: 6px;
}

.analysis-section { margin-bottom: 6px; }

.analysis-section h4 {
  font-family: var(--font-pixel);
  font-size: 7px;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.analysis-section p {
  font-family: var(--font-mono);
  font-size: 26px;
  line-height: 1.4;
  color: var(--text);
}

/* ===== CALL BUTTONS ===== */
.call-buttons {
  display: flex;
  justify-content: center;
  gap: 48px;
  padding: 10px 16px;
  flex-shrink: 0;
}

.call-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.call-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.call-btn svg {
  width: 24px;
  height: 24px;
}

.call-btn-answer {
  background: var(--pixel-green);
  border-color: #00ff4c;
  color: #000;
  box-shadow: 0 0 16px rgba(0,228,54,0.4), 0 0 32px rgba(0,228,54,0.15);
}

.call-btn-answer:hover {
  transform: scale(1.1);
  box-shadow: 0 0 24px rgba(0,228,54,0.6), 0 0 48px rgba(0,228,54,0.25);
}

.call-btn-answer:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.call-btn-hangup {
  background: var(--pixel-red);
  border-color: #ff2266;
  color: #fff;
  box-shadow: 0 0 16px rgba(255,0,77,0.4), 0 0 32px rgba(255,0,77,0.15);
}

.call-btn-hangup svg {
  transform: rotate(135deg);
}

.call-btn-hangup:hover {
  transform: scale(1.1);
  box-shadow: 0 0 24px rgba(255,0,77,0.6), 0 0 48px rgba(255,0,77,0.25);
}

.call-btn-hangup:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.call-btn-answer.active-call {
  animation: callPulse 2s infinite;
}

@keyframes callPulse {
  0%, 100% { box-shadow: 0 0 16px rgba(0,228,54,0.4); }
  50% { box-shadow: 0 0 30px rgba(0,228,54,0.7); }
}

.call-label {
  font-family: var(--font-pixel);
  font-size: 5px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* ===== TEXT TAB ===== */
.text-input-area {
  padding: 0 16px;
  margin-bottom: 6px;
}

textarea {
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--border);
  padding: 8px;
  color: var(--pixel-green);
  font-family: var(--font-mono);
  font-size: 24px;
  resize: none;
  outline: none;
}

textarea:focus { border-color: var(--pixel-blue); }

textarea::placeholder {
  color: var(--text-muted);
  font-family: var(--font-pixel);
  font-size: 10px;
}

.text-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.pixel-btn {
  font-family: var(--font-pixel);
  font-size: 10px;
  padding: 8px 12px;
  border: 2px solid var(--pixel-blue);
  background: transparent;
  color: var(--pixel-blue);
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.15s;
}

.pixel-btn:hover {
  background: var(--pixel-blue);
  color: #000;
  box-shadow: 0 0 8px rgba(41,173,255,0.3);
}

.pixel-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pixel-btn-sm {
  font-size: 5px;
  padding: 4px 6px;
  border-color: var(--border);
  color: var(--text-muted);
}

.pixel-btn-sm:hover {
  border-color: var(--pixel-blue);
  color: var(--pixel-blue);
  background: transparent;
  box-shadow: none;
}

/* ===== LOADING SPINNER ===== */
.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(41,173,255,0.3);
  border-top-color: var(--pixel-blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ===== FOOTER ===== */
.phone-footer {
  display: flex;
  justify-content: space-between;
  padding: 4px 16px 2px;
  font-family: var(--font-pixel);
  font-size: 4px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== MOBILE: Full screen phone ===== */
@media (max-width: 440px) {
  body { align-items: stretch; }

  .phone-frame {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }

  .phone-bezel-top { height: 0; overflow: hidden; }
  .phone-bezel-bottom { height: 0; overflow: hidden; }
  .bezel-cam, .bezel-bar { display: none; }
}

/* ===== DESKTOP: taller phones ===== */
@media (min-height: 800px) {
  .content-box { max-height: 180px; }
}

@media (max-height: 700px) {
  .caller-info { padding: 6px 16px 4px; }
  .pixel-avatar { width: 36px; height: 36px; margin-bottom: 4px; }
  .pixel-shield-icon { width: 16px; height: 18px; }
  .app-title { font-size: 11px; }
  .call-btn { width: 48px; height: 48px; }
  .call-btn svg { width: 20px; height: 20px; }
  .call-buttons { padding: 6px 16px; gap: 36px; }
  .content-box { max-height: 100px; }
}
