/* F.A.C.T Mobile — iPhone/Safari güvenli alan uyumlu arayüz */

:root {
  --bg:     #010a0a;
  --panel:  #041111;
  --teal:   #00d4c4;
  --teal-d: #007a72;
  --mid:    #0a3a36;
  --text:   #c8f5f0;
  --dim:    #3a8a82;
  --red:    #ff4d4d;
  --amber:  #ffbf47;
  color-scheme: dark;
}

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

html, body {
  width: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           0 env(safe-area-inset-left);
  background:
    radial-gradient(circle at 50% 28%, rgba(0, 212, 196, .08), transparent 35%),
    var(--bg);
}

button, input { touch-action: manipulation; }
.hidden { display: none !important; }

/* ── Header ─────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--mid);
  background: rgba(4, 17, 17, .92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand { font-size: 18px; letter-spacing: 3px; color: var(--teal); }
.brand .sub { font-size: 10px; color: var(--dim); letter-spacing: 2px; }

.badges { display: flex; gap: 8px; }

.badge {
  font-size: 10px;
  letter-spacing: 1px;
  padding: 4px 10px;
  border: 1px solid var(--mid);
  border-radius: 3px;
  color: var(--dim);
}
.badge.on  { color: var(--teal); border-color: var(--teal-d);
             text-shadow: 0 0 8px var(--teal); }
.badge.off { color: var(--dim); }
.badge.warn { color: var(--amber); border-color: rgba(255, 191, 71, .5); }

/* ── Ana alan ───────────────────────────────────────── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  padding: 10px 14px 0;
}

.companion {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.setup-card {
  width: min(100%, 420px);
  margin: auto;
  padding: 26px 22px;
  border: 1px solid var(--mid);
  border-radius: 18px;
  background: rgba(4, 17, 17, .9);
  box-shadow: 0 22px 70px rgba(0, 0, 0, .45);
}
.setup-card h1 { color: var(--teal); font-size: 20px; letter-spacing: 1px; }
.setup-card p { color: var(--dim); font-size: 13px; line-height: 1.55; margin: 10px 0 20px; }
.setup-card label { display: block; color: var(--text); font-size: 12px; margin: 12px 0 7px; }
.setup-card label:first-of-type { margin-top: 0; }
.setup-card input {
  width: 100%;
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--mid);
  border-radius: 10px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  font: 16px "SF Mono", Menlo, monospace;
}
.setup-card input:focus { border-color: var(--teal-d); }
.setup-card button, .permission-action {
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  border: 1px solid var(--teal-d);
  border-radius: 10px;
  background: rgba(0, 212, 196, .1);
  color: var(--teal);
  font: 600 13px inherit;
  letter-spacing: 1px;
}
#token-error { min-height: 18px; margin-top: 10px; color: var(--red); font-size: 12px; }
#pair-form { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--mid); }
body.device-only #orb { opacity: .45; }
.permission-action { width: min(94vw, 560px); margin: 0 0 8px; }

.audio-unlock {
  position: fixed;
  inset: 0;
  z-index: 50;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  background: rgba(1, 10, 10, .84);
  color: var(--teal);
  font: 600 16px inherit;
  letter-spacing: 2px;
}
.audio-unlock.notice {
  flex-direction: column;
  gap: 18px;
  padding: 28px 24px;
  letter-spacing: 0;
  text-align: center;
}
#device-notice-text {
  max-width: 22rem;
  font: 500 18px/1.35 inherit;
  color: var(--text);
}
#device-notice-action {
  letter-spacing: 2px;
  font-weight: 700;
  color: var(--teal);
}

#cam-wrap {
  position: relative;
  width: min(92vw, 480px);
  aspect-ratio: 16 / 9;
  border: 1px solid var(--mid);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 6px;
  flex-shrink: 0;
}
#cam { width: 100%; height: 100%; object-fit: cover;
       transform: scaleX(-1); /* ayna */ }
.cam-live {
  position: absolute; top: 6px; right: 8px;
  font-size: 10px; color: var(--red);
  text-shadow: 0 0 6px var(--red);
}

#orb {
  width: min(60vw, 280px);
  height: min(60vw, 280px);
  flex-shrink: 0;
}

#status {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--dim);
  margin: 4px 0 8px;
  flex-shrink: 0;
}
#status.live { color: var(--teal); }

/* ── Sohbet günlüğü ─────────────────────────────────── */
#log {
  flex: 1;
  width: min(94vw, 560px);
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--mid);
  border-radius: 6px;
  background: var(--panel);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.55;
  margin-bottom: 8px;
}

#log .row       { margin-bottom: 6px; word-wrap: break-word; }
#log .who-user   { color: var(--dim); }
#log .who-jarvis { color: var(--teal); }
#log .who-sys    { color: #8a7a3a; font-size: 11px; }

/* ── Footer / kontroller ────────────────────────────── */
footer {
  flex-shrink: 0;
  padding: 8px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--mid);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.controls { display: flex; gap: 10px; justify-content: center; }

.ctl {
  flex: 1;
  max-width: 200px;
  min-height: 46px;
  padding: 12px 0;
  background: transparent;
  border: 1px solid var(--mid);
  border-radius: 4px;
  color: var(--dim);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all .15s;
}
.ctl.subtle { flex: 0 0 48px; color: var(--dim); }
.ctl.on {
  color: var(--teal);
  border-color: var(--teal-d);
  box-shadow: 0 0 12px rgba(0, 212, 196, .25) inset;
}
.ctl.rec {
  color: var(--red);
  border-color: var(--red);
}

#text-form, #name-form { display: flex; gap: 8px; }

#text-input, #live-device-name {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--mid);
  border-radius: 4px;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px; /* iOS odaklanırken yakınlaştırmasın */
  outline: none;
}

@media (max-height: 700px) {
  #orb { width: min(42vw, 190px); height: min(42vw, 190px); }
  header { padding-block: 8px; }
  main { padding-top: 4px; }
}

@media (display-mode: standalone) {
  .brand .sub { color: var(--teal-d); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
#text-input:focus, #live-device-name:focus { border-color: var(--teal-d); }

#text-form button, #name-form button {
  background: transparent;
  border: 1px solid var(--mid);
  border-radius: 4px;
  color: var(--teal);
  padding: 0 18px;
  font-size: 15px;
  cursor: pointer;
}
