/* Claude Mobile — Mobile-optimised terminal UI */

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-surface: #0f3460;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --success: #2ed573;
  --warning: #ffa502;
  --border: #2a2a4a;
  --bar-height: 48px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  touch-action: manipulation;
}

.screen {
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.hidden {
  display: none !important;
}

/* Auth screen */
.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
  gap: 16px;
}

.auth-container h1 {
  font-size: 28px;
  color: var(--accent);
}

.auth-container p {
  color: var(--text-secondary);
}

.auth-hint {
  text-align: center;
  line-height: 1.6;
}

.auth-hint code {
  background: var(--bg-surface);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 14px;
  color: var(--accent);
}

.auth-divider {
  width: 100%;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 13px;
  margin: 4px 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-container input {
  width: 100%;
  max-width: 320px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
}

.auth-container input:focus {
  border-color: var(--accent);
}

.auth-container button {
  padding: 12px 48px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.auth-container button:active {
  background: var(--accent-hover);
}

/* Pairing code screen */
#code-input {
  width: 100%;
  max-width: 240px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 32px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  text-align: center;
  letter-spacing: 8px;
  outline: none;
}

#code-input:focus {
  border-color: var(--accent);
}

.code-error {
  color: var(--accent) !important;
  font-size: 14px;
  text-align: center;
}

/* App screen layout */
#app-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* Top bar */
#top-bar {
  display: flex;
  align-items: center;
  height: 36px;
  min-height: 36px;
  background: var(--bg-secondary);
  border-bottom: none;
  padding: 0 8px;
  gap: 8px;
}

#session-list {
  flex: 1;
  display: flex;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0;
  align-items: flex-end;
  height: 100%;
}

#session-list::-webkit-scrollbar {
  display: none;
}

.session-tab {
  flex-shrink: 0;
  padding: 6px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 6px 6px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  margin-right: -1px;
  position: relative;
}

.session-tab.active {
  background: #000000;
  border-color: var(--accent);
  border-bottom-color: #000000;
  color: var(--text-primary);
  z-index: 1;
}

.session-tab.active::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--success);
  margin-right: 5px;
  vertical-align: middle;
}

#status-area {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-label {
  display: none;
}

.status-dot.connected { background: var(--success); }
.status-dot.disconnected { background: var(--accent); }
.status-dot.connecting { background: var(--warning); animation: pulse 1.5s infinite; }
.status-dot.no-mac { background: var(--warning); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.font-btn {
  padding: 4px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}

/* Terminal */
#terminal-container {
  flex: 1;
  overflow: hidden;
  background: #000;
}

#terminal-container .xterm {
  height: 100%;
  padding: 4px;
}

/* Bottom bar */
#bottom-bar {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 6px 8px;
}

#quick-actions {
  display: flex;
  gap: 3px;
  margin-bottom: 5px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#quick-actions::-webkit-scrollbar {
  display: none;
}

.qa-btn {
  flex-shrink: 0;
  padding: 5px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  cursor: pointer;
  user-select: none;
  min-width: 0;
  text-align: center;
}

.qa-btn:active {
  background: var(--bg-surface);
  border-color: var(--accent);
  color: var(--text-primary);
}

#input-row {
  display: flex;
  gap: 6px;
}

#text-input {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 16px; /* Prevents iOS zoom on focus */
  font-family: 'SF Mono', 'Fira Code', monospace;
  outline: none;
}

#text-input:focus {
  border-color: var(--accent);
}

#send-btn {
  padding: 10px 14px;
  background: #1a6fbf;
  border: 1px solid #1a6fbf;
  border-radius: 6px;
  color: white;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

#send-btn:active {
  background: #2488e0;
  border-color: #2488e0;
}

#enter-btn {
  padding: 10px 14px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: white;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

#enter-btn:active {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* Responsive: Galaxy Z Fold 6 cover screen (~374px) */
@media (max-width: 420px) {
  :root {
    --bar-height: 40px;
  }

  .session-tab {
    padding: 4px 8px;
    font-size: 11px;
  }

  .qa-btn {
    padding: 6px 8px;
    font-size: 12px;
    min-width: 36px;
  }

  #text-input {
    padding: 8px 10px;
    font-size: 14px;
  }

  .font-btn {
    display: none;
  }
}

/* Responsive: Galaxy Z Fold 6 inner landscape (~904px+) */
@media (min-width: 768px) {
  #app-screen {
    flex-direction: row;
    flex-wrap: wrap;
  }

  #top-bar {
    width: 100%;
  }

  #terminal-container {
    flex: 1;
  }

  #bottom-bar {
    width: 100%;
  }
}

/* Landscape orientation: reduce bar heights */
@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --bar-height: 36px;
  }

  #quick-actions {
    margin-bottom: 4px;
  }

  .qa-btn {
    padding: 4px 8px;
    font-size: 12px;
  }

  #text-input {
    padding: 6px 10px;
    font-size: 14px;
  }

  #bottom-bar {
    padding: 4px 8px;
  }
}
