/* iGTP · UI base estilo ChatGPT con Alba (FractAIll) */
[hidden] { display: none !important; }

html { height: 100%; }
.paya-body {
  background: #0A0A0D;
  color: #ECECEC;
  height: var(--app-h, 100dvh);
  overflow: hidden;
  overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Helvetica Neue", sans-serif;
  position: fixed; inset: 0; width: 100%;
}
.paya-view { height: var(--app-h, 100dvh); }

/* iOS Safari: simplificar backdrop */
html[data-os="ios"][data-browser="safari"] .cgpt-top { backdrop-filter: none; -webkit-backdrop-filter: none; }

/* === LOGIN (mantengo Alba) === */
.paya-login { display: grid; place-items: center; padding: 24px; }
.paya-login-card {
  width: 100%; max-width: 400px; padding: 36px 32px 28px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 22px;
  text-align: center;
  box-shadow: 0 12px 40px -12px rgba(0,0,0,0.5);
}
.paya-isotipo { display: inline-block; aspect-ratio: 1/1; width: 32px; height: 32px; object-fit: contain; flex-shrink: 0; }
.paya-isotipo-sm { width: 24px; height: 24px; }
.paya-isotipo-md { width: 32px; height: 32px; }
.paya-isotipo-lg { width: 72px; height: 72px; margin: 0 auto 18px; }
.paya-login-h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.025em; margin-bottom: 6px; color: #fff; }
.paya-login-sub { font-size: 14px; color: #888C95; margin-bottom: 22px; }
.igtp-mark { font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; }
.igtp-mark .igtp-i { color: #FF7A29; font-style: normal; }
.paya-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.paya-field { display: flex; flex-direction: column; gap: 6px; }
.paya-label { font-size: 12px; color: #888C95; padding-left: 2px; }
.paya-form input {
  width: 100%; padding: 12px 14px;
  background: #15151B; border: 1px solid rgba(255,255,255,0.07);
  color: #fff; font: inherit; font-size: 15px; border-radius: 12px; outline: 0;
  -webkit-appearance: none; appearance: none;
}
.paya-form input:focus { border-color: #FF7A29; box-shadow: 0 0 0 3px rgba(255,122,41,0.15); }
.paya-input-suffix { position: relative; }
.paya-input-suffix input { padding-right: 130px; }
.paya-suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #888C95; font-size: 13px; pointer-events: none; }
.paya-form-error { color: #FF3B30; font-size: 13px; min-height: 18px; padding-left: 4px; font-weight: 500; }
.paya-login-btn { width: 100%; justify-content: center; margin-top: 6px; min-height: 44px; touch-action: manipulation; }
a.paya-login-btn { text-decoration: none; }
.paya-login-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: #5C5F68; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.paya-login-divider::before, .paya-login-divider::after { content:''; flex:1; height:1px; background: rgba(255,255,255,0.07); }
.paya-login-foot { margin-top: 22px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.07); font-size: 12px; color: #888C95; display: inline-flex; align-items: center; gap: 8px; }
.paya-dot { width: 7px; height: 7px; background: #00C76C; border-radius: 50%; animation: pulse 2s infinite; display: inline-block; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(0,199,108,0.4); }
  70% { box-shadow: 0 0 0 8px rgba(0,199,108,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,199,108,0); }
}

/* ===================== CGPT-LIKE APP ===================== */
.cgpt-app {
  display: grid;
  grid-template-columns: 64px 1fr;
  height: var(--app-h, 100dvh);
  min-height: 0;
}

/* === RAIL 64px === */
.rail {
  background: #0A0A0D;
  border-right: 1px solid rgba(255,255,255,0.05);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0 max(12px, env(safe-area-inset-bottom));
  gap: 8px;
  position: relative;
  z-index: 20;
}
.rail-brand {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  margin-bottom: 8px;
  text-decoration: none;
}
.rail-brand img { width: 28px; height: 28px; object-fit: contain; display: block; }
.rail-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: transparent; border: 0; cursor: pointer;
  color: #ECECEC;
  border-radius: 10px;
  transition: background 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(255,122,41,0.2);
}
.rail-btn:hover, .rail-btn.is-active { background: rgba(255,255,255,0.08); }
.rail-btn svg { width: 20px; height: 20px; }
.rail-spacer { flex: 1; }
.rail-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #FF7A29;
  color: #fff; font-weight: 700; font-size: 13px;
  display: grid; place-items: center;
  border: 0; cursor: pointer;
  touch-action: manipulation;
}
.rail-popover {
  position: absolute;
  bottom: 56px; left: 56px;
  background: #1A1A22;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 24px 60px -12px rgba(0,0,0,0.7);
  z-index: 50;
  min-width: 220px;
}
.rail-pop-meta { padding: 8px 10px 10px; border-bottom: 1px solid rgba(255,255,255,0.07); font-size: 11px; color: #5C5F68; margin-bottom: 4px; }
.rail-pop-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 10px;
  background: transparent; border: 0;
  color: #ECECEC; font: inherit; font-size: 13px;
  border-radius: 8px; cursor: pointer; text-align: left;
  min-height: 40px; touch-action: manipulation;
}
.rail-pop-item:hover { background: rgba(255,255,255,0.06); }
.rail-pop-item svg { width: 14px; height: 14px; }

/* === DRAWER conversaciones === */
.drawer {
  position: fixed;
  top: 0; left: 64px; bottom: 0;
  width: 280px;
  background: #15151B;
  border-right: 1px solid rgba(255,255,255,0.07);
  z-index: 30;
  display: flex; flex-direction: column;
  transform: translateX(-110%);
  transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}
.drawer.is-open { transform: translateX(0); }
.drawer-head { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,0.07); }
.drawer-title { font-size: 13px; color: #888C95; font-weight: 500; }
.drawer-list { flex: 1; overflow-y: auto; padding: 8px; -webkit-overflow-scrolling: touch; }
.drawer-item {
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: #C8CBD2; line-height: 1.3;
  transition: background 0.15s ease;
  min-height: 40px; touch-action: manipulation;
}
.drawer-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.drawer-item.is-active { background: rgba(255,122,41,0.15); color: #fff; }
.drawer-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-item .meta { font-size: 11px; color: #5C5F68; flex-shrink: 0; }
.drawer-empty { padding: 24px 16px; text-align: center; color: #5C5F68; font-size: 13px; }
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 25; }

/* === MAIN === */
.cgpt-main {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  background: #0A0A0D;
  overflow: hidden;
  position: relative;
}
.cgpt-top {
  position: absolute; top: 0; right: 0;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  display: flex; gap: 8px;
  z-index: 5;
}
.cgpt-top-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: transparent; border: 0; cursor: pointer;
  color: #C8CBD2; border-radius: 8px;
  transition: background 0.15s ease;
  touch-action: manipulation;
}
.cgpt-top-btn:hover { background: rgba(255,255,255,0.06); color: #fff; }
.cgpt-top-btn svg { width: 18px; height: 18px; }

.cgpt-conversation {
  flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  display: flex; flex-direction: column;
  padding: max(64px, env(safe-area-inset-top)) 0 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.cgpt-conversation::-webkit-scrollbar { width: 8px; }
.cgpt-conversation::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 8px; }

/* === Welcome (saludo gigante centrado) === */
.cgpt-welcome {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 16px 24px;
  width: 100%;
  animation: fadein 0.4s ease;
}
.cgpt-welcome h1 {
  font-size: clamp(26px, 4.5vw, 36px);
  font-weight: 400;
  letter-spacing: -0.01em;
  color: #ECECEC;
  margin: 0;
}

/* === Mensajes === */
.cgpt-thread { width: 100%; max-width: 760px; margin: 0 auto; padding: 8px 16px; }
.cgpt-msg { display: flex; gap: 12px; margin-bottom: 22px; animation: slideup 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); }
.cgpt-msg.is-user { flex-direction: row-reverse; }
.cgpt-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  flex-shrink: 0; overflow: hidden;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
}
.cgpt-avatar.is-bot { background: transparent; }
.cgpt-avatar.is-bot img { width: 100%; height: 100%; object-fit: contain; }
.cgpt-avatar.is-user { background: #FF7A29; color: #fff; }
.cgpt-bubble {
  max-width: 80%; padding: 10px 14px;
  background: #1F1F26;
  border-radius: 16px;
  line-height: 1.55; word-wrap: break-word; white-space: pre-wrap;
  font-size: 15px;
}
.cgpt-msg.is-user .cgpt-bubble { background: #2C2C38; }
.cgpt-bubble pre { background: #0A0A0D; padding: 10px 12px; border-radius: 10px; overflow-x: auto; border: 1px solid rgba(255,255,255,0.07); font-family: "SF Mono", "JetBrains Mono", Menlo, monospace; font-size: 12px; margin: 8px 0; }
.cgpt-bubble code { background: rgba(255,255,255,0.08); padding: 1px 6px; border-radius: 4px; font-family: "SF Mono", "JetBrains Mono", Menlo, monospace; font-size: 12.5px; }
.cgpt-bubble pre code { background: transparent; padding: 0; }
.cgpt-bubble a { color: #FF7A29; text-decoration: underline; text-underline-offset: 2px; }
.cgpt-bubble.is-error { background: rgba(255,59,48,0.08); border: 1px solid rgba(255,59,48,0.35); color: #FF3B30; }
.cgpt-cursor { display: inline-block; width: 8px; height: 16px; background: #FF7A29; margin-left: 2px; vertical-align: text-bottom; animation: blink 1s steps(2, jump-none) infinite; border-radius: 1px; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }
.cgpt-typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.cgpt-typing span { width: 7px; height: 7px; border-radius: 50%; background: #888C95; animation: typing 1.2s infinite ease-in-out; }
.cgpt-typing span:nth-child(2) { animation-delay: 0.15s; }
.cgpt-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 0%, 80%, 100% { transform: scale(0.7); opacity: 0.35; } 40% { transform: scale(1); opacity: 1; } }
.cgpt-tool-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; font-size: 11px; background: rgba(255,122,41,0.16); border: 1px solid rgba(255,122,41,0.35); border-radius: 100px; color: #FF7A29; margin: 6px 6px 0 0; font-family: "SF Mono", monospace; }

/* === Composer pill === */
.cgpt-composer-area {
  padding: 0 16px max(14px, env(safe-area-inset-bottom));
  flex-shrink: 0;
  display: flex; flex-direction: column;
  align-items: center;
  gap: 10px;
}
.cgpt-composer {
  width: 100%; max-width: 760px;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 10px 14px;
  background: #2A2A33;
  border: 1px solid transparent;
  border-radius: 28px;
  transition: border-color 0.15s ease;
}
.cgpt-composer:focus-within { border-color: rgba(255,122,41,0.35); }
.cgpt-add, .cgpt-mic, .cgpt-send {
  flex-shrink: 0;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: transparent; border: 0; cursor: pointer;
  color: #C8CBD2; border-radius: 50%;
  transition: all 0.15s ease;
  touch-action: manipulation;
}
.cgpt-add:hover, .cgpt-mic:hover { background: rgba(255,255,255,0.08); color: #fff; }
.cgpt-add svg, .cgpt-mic svg { width: 18px; height: 18px; }
.cgpt-input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: 0;
  color: #ECECEC; font: inherit; font-size: 15px;
  padding: 6px 4px; line-height: 1.5;
  resize: none; max-height: 180px; min-height: 22px;
  font-family: inherit;
}
.cgpt-input::placeholder { color: #888C95; }
.cgpt-mode {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; color: #C8CBD2;
  padding: 4px 8px; border-radius: 8px;
  cursor: default;
  flex-shrink: 0;
}
.cgpt-mode svg { width: 12px; height: 12px; opacity: 0.6; }
.cgpt-send {
  background: #fff; color: #0A0A0D;
  width: 36px; height: 36px;
}
.cgpt-send:hover:not(:disabled) { background: #f0f0f0; }
.cgpt-send:disabled { background: rgba(255,255,255,0.2); color: rgba(255,255,255,0.4); cursor: not-allowed; }
.cgpt-send svg { width: 16px; height: 16px; }

/* === Mobile === */
@media (max-width: 760px) {
  .cgpt-app { grid-template-columns: 56px 1fr; }
  .rail { padding: 8px 0 max(8px, env(safe-area-inset-bottom)); }
  .rail-brand, .rail-btn { width: 40px; height: 40px; }
  .drawer { left: 56px; width: calc(100% - 56px); max-width: 320px; }
  .cgpt-conversation { padding-top: max(56px, env(safe-area-inset-top)); }
  .cgpt-welcome h1 { font-size: clamp(22px, 6vw, 28px); }
  .cgpt-composer { padding: 8px 10px 8px 12px; border-radius: 24px; }
  .cgpt-add, .cgpt-mic { width: 30px; height: 30px; }
  .cgpt-add svg, .cgpt-mic svg { width: 16px; height: 16px; }
  .cgpt-send { width: 32px; height: 32px; }
  .cgpt-bubble { max-width: 88%; font-size: 14.5px; }
  .cgpt-thread { padding: 8px 12px; }
}

@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideup { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
