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

:root {
  --primary: oklch(0.27 0.12 264);
  --primary-dark: oklch(0.16 0.09 264);
  --primary-light: oklch(0.47 0.14 284);
  --accent: oklch(0.45 0.13 272);
  --accent-hover: oklch(0.54 0.13 276);

  --bg: oklch(0.97 0.005 240);
  --bg-light: oklch(1 0 0);
  --bg-dark: oklch(0.93 0.01 240);

  --text-primary: oklch(0.22 0.02 240);
  --text-secondary: oklch(0.42 0.02 240);
  --text-light: oklch(0.56 0.02 240);

  --user-msg: linear-gradient(
    135deg,
    oklch(0.58 0.15 276) 0%,
    oklch(0.48 0.17 308) 100%
  );
  --bot-msg: oklch(1 0 0);

  --error: oklch(0.63 0.19 25);
  --error-bg: oklch(0.98 0.02 25);
  --success: oklch(0.66 0.16 155);

  --shadow-sm: 0 1px 3px oklch(0 0 0 / 0.12);
  --shadow-md: 0 4px 6px oklch(0 0 0 / 0.1);
  --shadow-lg: 0 10px 25px oklch(0 0 0 / 0.15);
  --shadow-xl: 0 20px 40px oklch(0 0 0 / 0.2);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: "Open Sans", sans-serif;

  background-image: url("FIET Home.webp");
  background-size: cover;
  background-position: center;

  /*background:
    linear-gradient(
      135deg,
      rgba(26, 35, 126, 0.9) 0%,
      rgba(92, 107, 192, 0.9) 100%
    ),
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 10px,
      rgba(255, 255, 255, 0.03) 10px,
      rgba(255, 255, 255, 0.03) 20px
    );
  min-height: 100vh;*/
  background-attachment: fixed;
}

/* ========== BUTTON ========== */

.btn {
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn--action {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.15);
}

.btn--action:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.btn--action:active {
  transform: scale(0.95);
}

.btn--send {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--accent);
  flex-shrink: 0;
}

.btn--send:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.btn--send:active:not(:disabled) {
  transform: scale(0.95);
}

.btn--send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--floating {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: var(--primary);
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  outline: none;
}

.btn--floating:hover {
  background: var(--primary-light);
  transform: translateY(-4px) scale(1.05);
  box-shadow: var(--shadow-xl);
}

.btn--floating:active {
  transform: translateY(-2px) scale(1.02);
}

.btn__icon {
  color: white;
}

.btn__icon--sm {
  width: 20px;
  height: 20px;
}

.btn__icon--lg {
  width: 28px;
  height: 28px;
}

.btn__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--error);
  color: white;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  border: 2px solid white;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* ========== OVERLAY ========== */

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1001;
  animation: fadeIn 0.3s ease;
}

.overlay--show {
  display: flex;
}

/* En desktop, el overlay es transparente cuando no está maximizado */
@media (min-width: 768px) {
  .overlay:not(.overlay--maximized) {
    background: transparent;
    backdrop-filter: none;
    justify-content: flex-end;
    align-items: flex-end;
    pointer-events: none;
  }

  .overlay:not(.overlay--maximized) .modal {
    pointer-events: all;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ========== AVATAR ========== */

.bot-avatar {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.bot-avatar__icon {
  width: 28px;
  height: 28px;
}

/* ========== MODAL ========== */

.modal {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 440px;
  height: 85vh;
  height: 85dvh;
  max-height: 700px;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

/* Modo sidebar en desktop (no maximizado) */
@media (min-width: 768px) {
  .overlay:not(.overlay--maximized) .modal {
    width: 420px;
    height: calc(100vh - 120px);
    height: calc(100dvh - 120px);
    max-height: 700px;
    margin: 0 30px 30px 0;
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: var(--radius-lg);
  }

  /* Modo maximizado en desktop */
  .overlay--maximized .modal {
    width: 90%;
    max-width: 900px;
    height: 90vh;
    height: 90dvh;
    max-height: 800px;
    margin: 0;
    animation: scaleUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleUp {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal__header {
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-light) 100%
  );
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.modal__header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal__title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
}

.modal__header-actions {
  display: flex;
  gap: 8px;
}

.modal__content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg);
  scroll-behavior: smooth;
}

.modal__content::-webkit-scrollbar {
  width: 8px;
}

.modal__content::-webkit-scrollbar-track {
  background: transparent;
}

.modal__content::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: var(--radius-full);
}

.modal__content::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

.modal__footer {
  padding: 16px 20px;
  background: var(--bg-light);
  border-top: 1px solid #e2e8f0;
}

.modal__input-wrapper {
  display: flex;
  gap: 10px;
  align-items: center;
}

.modal__input {
  flex: 1;
  background: var(--bg);
  color: var(--text-primary);
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-full);
  padding: 12px 18px;
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
}

.modal__input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-light);
  box-shadow: 0 0 0 3px rgba(63, 81, 181, 0.1);
}

.modal__input::placeholder {
  color: var(--text-light);
}

.modal__input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ========== FEEDBACK LINK ========== */

.feedback-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  padding: 12px 16px;
  background: linear-gradient(
    135deg,
    rgba(63, 81, 181, 0.08) 0%,
    rgba(103, 58, 183, 0.08) 100%
  );
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  border-radius: var(--radius-md);
  border: 1px solid rgba(63, 81, 181, 0.15);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  text-align: center;
}

.feedback-link::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  transition: left 0.5s;
}

.feedback-link:hover::before {
  left: 100%;
}

.feedback-link:hover {
  background: linear-gradient(
    135deg,
    rgba(63, 81, 181, 0.15) 0%,
    rgba(103, 58, 183, 0.15) 100%
  );
  border-color: rgba(63, 81, 181, 0.3);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.feedback-link:active {
  transform: translateY(0);
}

.feedback-link__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--accent);
  opacity: 0.8;
}

/* ========== WELCOME ========== */

.welcome {
  text-align: center;
  padding: 32px 16px;
  background: var(--bg-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 8px;
}

.welcome__icon {
  font-size: 48px;
  margin-bottom: 16px;
  animation: wave 2s infinite;
  transform-origin: 70% 70%;
  display: inline-block;
}

@keyframes wave {
  0%,
  100% {
    transform: rotate(0deg);
  }
  10%,
  30% {
    transform: rotate(14deg);
  }
  20% {
    transform: rotate(-8deg);
  }
  40% {
    transform: rotate(-4deg);
  }
  50% {
    transform: rotate(10deg);
  }
  60% {
    transform: rotate(0deg);
  }
}

.welcome__title {
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
}

.welcome__text {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  max-width: 320px;
  margin: 0 auto;
}

.welcome__feedback-link {
  display: inline-block;
  margin-top: 16px;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background: rgba(63, 81, 181, 0.1);
  transition: var(--transition);
}

.welcome__feedback-link:hover {
  background: rgba(63, 81, 181, 0.2);
  transform: translateY(-2px);
}

/* ========== MESSAGES ========== */

.message {
  display: flex;
  margin-bottom: 8px;
  animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message__content {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.message--user {
  justify-content: flex-end;
}

.message--user .message__content {
  background: var(--user-msg);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.message--bot {
  justify-content: flex-start;
}

.message--bot .message__content {
  background: var(--bot-msg);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
}

.message--error {
  justify-content: center;
}

.message--error .message__content {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error);
  border-left-width: 4px;
  max-width: 90%;
}

.message--status {
  justify-content: center;
  animation: messageSlide 0.3s ease;
}

.message--status .message__content {
  background: linear-gradient(
    135deg,
    rgba(63, 81, 181, 0.1) 0%,
    rgba(103, 58, 183, 0.1) 100%
  );
  color: var(--accent);
  border: 1px solid rgba(63, 81, 181, 0.2);
  border-left-width: 4px;
  border-left-color: var(--accent);
  max-width: 90%;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
}

.message--status-success .message__content {
  background: linear-gradient(
    135deg,
    rgba(72, 187, 120, 0.1) 0%,
    rgba(56, 161, 105, 0.1) 100%
  );
  color: var(--success);
  border-color: rgba(72, 187, 120, 0.3);
  border-left-color: var(--success);
}

/* Spinner animation for status messages */
.status-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(63, 81, 181, 0.3);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.message__content p {
  margin: 0 0 8px 0;
}

.message__content p:last-child {
  margin-bottom: 0;
}

.message__content ul,
.message__content ol {
  margin: 8px 0;
  padding-left: 20px;
}

.message__content li {
  margin: 4px 0;
}

.message__content code {
  background: var(--bg-dark);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: "Courier New", monospace;
}

.message__content pre {
  background: var(--bg-dark);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 8px 0;
}

/* ========== TYPING INDICATOR ========== */

.typing {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  background: var(--bot-msg);
  border-radius: var(--radius-md);
  border-bottom-left-radius: 4px;
  max-width: fit-content;
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
}

.typing__dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: #a0aec0;
  animation: bounce 1.4s infinite ease-in-out;
}

.typing__dot:nth-child(1) {
  animation-delay: 0s;
}
.typing__dot:nth-child(2) {
  animation-delay: 0.2s;
}
.typing__dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* ========== RESPONSE TIME ========== */

.message__time {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 11px;
  color: var(--text-light);
  font-weight: 500;
}

.message--user .message__time {
  color: rgba(255, 255, 255, 0.7);
  border-top-color: rgba(255, 255, 255, 0.2);
}

/* ========== RESPONSIVE ========== */

@media (max-width: 767px) {
  /* En móviles siempre es modal de pantalla completa */
  .overlay {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    pointer-events: all;
  }

  .modal {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .btn.btn--floating {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
  }

  .chat-icon {
    /* Floating btn icon */
    width: 24px;
    height: 24px;
  }

  /* Ocultar el botón de maximizar en móviles */
  #maximize-btn {
    display: none;
  }
}
