/* GoFrank PWA - Mobile Remote Control */
:root {
  --bg: #0E1B3A;
  --panel: #132044;
  --card: #1a2a52;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #16a34a;
  --danger: #dc2626;
  --primary: #2563eb;
  --border: #0B1530;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #eab308;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-user-select: none;
  user-select: none;
}

/* Header */
.header {
  background: var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header h1 {
  font-size: 16px;
  font-weight: 700;
  color: #ff4444;
  letter-spacing: 0.3px;
}
.header .conn-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--red);
  transition: background 0.3s;
}
.header .conn-dot.online { background: var(--green); }

/* Login screen */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 24px;
}
.login-screen h2 {
  font-size: 22px;
  margin-bottom: 8px;
}
.login-screen p {
  color: var(--muted);
  margin-bottom: 24px;
  text-align: center;
  font-size: 14px;
}
.login-screen input {
  width: 100%;
  max-width: 320px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  margin-bottom: 16px;
  outline: none;
}
.login-screen input:focus {
  border-color: var(--primary);
}
.login-screen button {
  width: 100%;
  max-width: 320px;
  padding: 14px;
  border-radius: 10px;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.login-screen button:active { opacity: 0.7; }

/* Main app */
.app-container {
  display: none;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
  padding-bottom: 100px;
}
.app-container.active {
  display: flex;
}

/* Status dots row */
.status-row {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 16px;
  background: var(--panel);
  border-radius: 12px;
}
.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}
.dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--red);
  transition: background 0.4s;
  box-shadow: 0 0 6px rgba(0,0,0,0.3);
}
.dot.running { background: var(--green); box-shadow: 0 0 8px rgba(34,197,94,0.4); }
.dot.stale   { background: var(--orange); box-shadow: 0 0 8px rgba(234,179,8,0.4); }
.dot.off     { background: var(--red); }

/* Info cards */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.info-card {
  background: var(--panel);
  border-radius: 12px;
  padding: 14px;
}
.info-card .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.info-card .value {
  font-size: 18px;
  font-weight: 700;
}
.info-card .value.positive { color: var(--green); }
.info-card .value.negative { color: var(--red); }

/* Action buttons */
.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.btn {
  width: 100%;
  padding: 16px;
  border-radius: 12px;
  border: none;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  letter-spacing: 0.3px;
}
.btn:active {
  transform: scale(0.97);
  opacity: 0.8;
}
.btn-go {
  background: var(--accent);
  color: white;
}
.btn-stop {
  background: var(--danger);
  color: white;
}
.btn-secondary {
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  padding: 14px;
}
.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Event log */
.event-log {
  background: var(--panel);
  border-radius: 12px;
  padding: 14px;
  max-height: 300px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.event-log h3 {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.event-item {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 13px;
  line-height: 1.4;
}
.event-item:last-child { border-bottom: none; }
.event-item .time {
  color: var(--muted);
  font-size: 11px;
  font-family: 'SF Mono', 'Consolas', monospace;
}
.event-item .source {
  font-weight: 600;
  margin: 0 4px;
}
.event-item.error   { color: var(--red); }
.event-item.warning { color: var(--orange); }
.event-item.info    { color: var(--green); }
.event-item.trade_win  { color: var(--green); }
.event-item.trade_loss { color: var(--red); }

/* Notification permission banner */
.notif-banner {
  display: none;
  background: var(--card);
  border: 1px solid var(--primary);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}
.notif-banner.show { display: block; }
.notif-banner p {
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--muted);
}
.notif-banner button {
  padding: 10px 24px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Disconnected overlay */
.offline-bar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--danger);
  color: white;
  text-align: center;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  z-index: 200;
}
.offline-bar.show { display: block; }

/* Safe area (iPhone notch) */
@supports (padding-top: env(safe-area-inset-top)) {
  .header { padding-top: calc(14px + env(safe-area-inset-top)); }
  .app-container { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
}

/* Tablet/desktop: limit width */
@media (min-width: 480px) {
  .app-container, .login-screen {
    max-width: 420px;
    margin: 0 auto;
  }
}
