/* ============================================================
   SOFTIA — Custom Styles
   Complements Tailwind CSS utilities
   ============================================================ */

/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { font-family: 'Inter', sans-serif; }

body {
  background-color: #020617;
  color: #f1f5f9;
  overflow: hidden;
  height: 100vh;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ── Glassmorphism ────────────────────────────────────────── */
.glass {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.glass-dark {
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* ── Gradient text ────────────────────────────────────────── */
.gradient-text {
  background: linear-gradient(135deg, #a78bfa 0%, #818cf8 50%, #60a5fa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Gradient button ──────────────────────────────────────── */
.btn-gradient {
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.btn-gradient::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #6d28d9 0%, #4338ca 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.btn-gradient:hover::after { opacity: 1; }
.btn-gradient:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(124, 58, 237, 0.4);
}
.btn-gradient:active { transform: translateY(0); }
.btn-gradient span, .btn-gradient svg { position: relative; z-index: 1; }

/* ── Input focus glow ─────────────────────────────────────── */
.input-field {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(100, 116, 139, 0.3);
  transition: all 0.2s ease;
  outline: none;
}
.input-field:focus {
  border-color: rgba(124, 58, 237, 0.6);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15), 0 0 20px rgba(124, 58, 237, 0.08);
  background: rgba(30, 41, 59, 0.8);
}
.input-field::placeholder { color: #475569; }

/* ── Auth background blobs ────────────────────────────────── */
@keyframes blobFloat {
  0%, 100% { transform: translate(0, 0) scale(1) rotate(0deg); }
  25%       { transform: translate(30px, -40px) scale(1.05) rotate(5deg); }
  50%       { transform: translate(60px, 20px) scale(0.95) rotate(-3deg); }
  75%       { transform: translate(-20px, 40px) scale(1.02) rotate(8deg); }
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
  animation: blobFloat 18s infinite ease-in-out;
}
.blob-1 { width: 600px; height: 600px; background: #7c3aed; top: -200px; left: -200px; animation-duration: 20s; }
.blob-2 { width: 500px; height: 500px; background: #4f46e5; bottom: -150px; right: -150px; animation-delay: -7s; animation-duration: 22s; }
.blob-3 { width: 350px; height: 350px; background: #2563eb; top: 40%; left: 40%; animation-delay: -14s; animation-duration: 16s; }

/* ── Auth card shimmer border ─────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}
.card-auth {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 32px 64px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(124, 58, 237, 0.1) inset,
    0 1px 0 rgba(255, 255, 255, 0.05) inset;
}

/* ── Tab indicator ────────────────────────────────────────── */
.tab-btn {
  position: relative;
  transition: color 0.2s ease;
}
.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, #7c3aed, #4f46e5);
  border-radius: 99px;
  transform: scaleX(0);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.tab-btn.active { color: #a78bfa; }
.tab-btn.active::after { transform: scaleX(1); }

/* ── Sidebar conversation items ───────────────────────────── */
.conv-item {
  position: relative;
  transition: all 0.18s ease;
  border-left: 2px solid transparent;
}
.conv-item:hover { background: rgba(51, 65, 85, 0.5); }
.conv-item.active {
  background: rgba(124, 58, 237, 0.12);
  border-left-color: #7c3aed;
}

/* ── Message animations ───────────────────────────────────── */
@keyframes messageSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.message-animate {
  animation: messageSlideIn 0.28s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ── Typing indicator ─────────────────────────────────────── */
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-6px); opacity: 1; }
}
.typing-dot {
  width: 7px; height: 7px;
  background: #a78bfa;
  border-radius: 50%;
  animation: typingBounce 1.3s infinite ease;
}
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

/* ── Cursor blink for streaming ───────────────────────────── */
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}
.stream-cursor {
  display: inline-block;
  width: 2px; height: 1.1em;
  background: #a78bfa;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: cursorBlink 0.8s infinite;
}

/* ── Message content markdown ─────────────────────────────── */
.message-content pre {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 10px 0;
  font-size: 0.8125rem;
}
.message-content code {
  font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 0.8125rem;
}
.message-content :not(pre) > code {
  background: rgba(124, 58, 237, 0.2);
  color: #c4b5fd;
  padding: 2px 6px;
  border-radius: 4px;
}
.message-content p { margin: 0 0 8px; }
.message-content p:last-child { margin: 0; }
.message-content ul, .message-content ol { padding-left: 20px; margin: 8px 0; }
.message-content li { margin: 3px 0; }
.message-content h1, .message-content h2, .message-content h3 {
  font-weight: 600; margin: 14px 0 6px;
}
.message-content h1 { font-size: 1.125rem; }
.message-content h2 { font-size: 1rem; }
.message-content h3 { font-size: 0.9375rem; }
.message-content blockquote {
  border-left: 3px solid #7c3aed;
  padding-left: 12px;
  color: #94a3b8;
  margin: 8px 0;
}
.message-content a { color: #818cf8; text-decoration: underline; }
.message-content hr { border-color: #1e293b; margin: 12px 0; }
.message-content table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.message-content th, .message-content td {
  border: 1px solid #1e293b;
  padding: 6px 10px;
  text-align: left;
}
.message-content th { background: #1e293b; font-weight: 600; }

/* ── Modal overlay ────────────────────────────────────────── */
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.94) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-card {
  animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ── Toast ────────────────────────────────────────────────── */
@keyframes toastIn {
  from { opacity: 0; transform: translateX(110%); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(110%); }
}
.toast-enter { animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.toast-exit  { animation: toastOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; }

/* ── Fade-in utility ──────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.fade-in { animation: fadeIn 0.4s ease forwards; }

/* ── Preset buttons ───────────────────────────────────────── */
.preset-btn {
  transition: all 0.18s ease;
  cursor: pointer;
}
.preset-btn:hover {
  border-color: #7c3aed !important;
  color: #a78bfa !important;
  background: rgba(124, 58, 237, 0.1) !important;
}
.preset-btn.selected {
  border-color: #7c3aed !important;
  color: #a78bfa !important;
  background: rgba(124, 58, 237, 0.15) !important;
}

/* ── Sidebar mobile ───────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  #sidebar.open { transform: translateX(0); }
  #sidebar-overlay { display: block; }
}

/* ── Send button ──────────────────────────────────────────── */
.send-btn {
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
  transition: all 0.2s ease;
}
.send-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #6d28d9 0%, #4338ca 100%);
  transform: scale(1.05);
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.5);
}
.send-btn:disabled {
  background: #1e293b;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Mesh grid background ─────────────────────────────────── */
.mesh-bg {
  background-image:
    linear-gradient(rgba(124, 58, 237, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 58, 237, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* ── Fondo del chat con imagen ────────────────────────────── */
#chat-area {
  position: relative;
  background-image: url('/img/image.png');
  background-size: cover;
  background-position: center;
  background-attachment: local;
}

/* Capa oscura semitransparente sobre la imagen */
#chat-area::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);   /* slate-950 al 78% */
  backdrop-filter: blur(1px);
  pointer-events: none;
  z-index: 0;
}

/* Los mensajes deben quedar por encima de la capa */
#chat-area > #messages {
  position: relative;
  z-index: 1;
}

/* ── Welcome screen ───────────────────────────────────────── */
@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}
.float-icon { animation: floatIcon 3s ease-in-out infinite; }

/* ── Highlight.js theme override ──────────────────────────── */
.hljs {
  background: transparent !important;
  padding: 0 !important;
}
