/* Systema PWA — Estilos */

:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --msg-user: #1d4ed8;
  --msg-assistant: #1e293b;
  --border: #334155;
  --safe-bottom: env(safe-area-inset-bottom, 12px);
}

* { 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);
  height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Pantallas ── */
.screen { height: 100dvh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ── Login ── */
#login-screen {
  justify-content: center;
  align-items: center;
  padding: 24px;
}
.login-card {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 40px 28px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.logo {
  font-size: 2.2em;
  font-weight: 700;
  margin-bottom: 4px;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.subtitle {
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 0.95em;
}
#login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#password-input {
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border .2s;
}
#password-input:focus { border-color: var(--accent); }
#login-btn {
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
#login-btn:active { background: var(--accent-hover); }
.error-msg { color: var(--danger); font-size: 0.85em; margin-top: 8px; min-height: 20px; }

/* Google Login */
.divider { display: flex; align-items: center; color: var(--text-muted); margin: 8px 0; font-size: 0.85em; }
.divider::before, .divider::after { content: ""; flex: 1; border-bottom: 1px solid var(--border); margin: 0 10px; }
.google-btn {
  width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--border);
  background: #fff; color: #333; font-size: 15px; font-weight: 500; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px; transition: background .2s;
}
.google-btn span { font-weight: 700; color: #4285f4; font-size: 1.2em; }
.google-btn:active { background: #e8e8e8; }

/* ── Chat Header ── */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}
.header-title { font-size: 1.2em; font-weight: 700; }
.header-actions { display: flex; gap: 8px; }
.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.3em;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background .2s;
}
.icon-btn:active { background: var(--bg-input); }

/* ── Mensajes ── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.msg {
  max-width: 82%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.45;
  animation: fadeIn .25s ease;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user {
  align-self: flex-end;
  background: var(--msg-user);
  border-bottom-right-radius: 6px;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--msg-assistant);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}
.msg.typing {
  opacity: .6;
  font-style: italic;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Input Bar ── */
.input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + var(--safe-bottom));
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#text-input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
#text-input:focus { border-color: var(--accent); }
.mic-btn, .send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 1.2em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.mic-btn:active, .send-btn:active { background: var(--accent); }
.mic-btn.recording { background: var(--danger); border-color: var(--danger); animation: pulse-bg .8s infinite; }

/* ── Indicador de Grabación ── */
.recording-badge {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 0.9em;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 100;
}
.pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  animation: pulse-scale 0.8s infinite;
}
@keyframes pulse-scale {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.8); opacity: 0.5; }
}
@keyframes pulse-bg {
  0%, 100% { background: var(--danger); }
  50% { background: #dc2626; }
}

/* ── Modal Settings ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
  padding: 20px;
}
.modal-content {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-content h2 { text-align: center; font-size: 1.3em; }
.modal-content label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9em;
  color: var(--text-muted);
}
.modal-content select {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.btn-secondary, .btn-danger {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary { background: var(--bg-input); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
