:root {
  --bg: #f4f7fb;
  --text: #1f2a37;
  --surface: #ffffff;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --muted: #5b6875;
  --border: #d9e2ec;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: radial-gradient(circle at 10% 20%, #e8f4ff 0%, #f4f7fb 35%, #f7fafc 100%);
  color: var(--text);
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.2s ease;
}

.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #1f2937 100%);
  color: #fff;
  padding: 24px 18px;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.brand {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex: 0 0 auto;
}

.collapse-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  padding: 0;
}

.collapse-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #e5e7eb;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 10px;
  transition: background 0.2s;
}

.menu-link .icon {
  width: 20px;
  height: 20px;
}

.menu-link:hover {
  background: rgba(255, 255, 255, 0.12);
}

.menu-link.logout {
  margin-top: 24px;
  background: rgba(239, 68, 68, 0.22);
}

.layout.collapsed {
  grid-template-columns: 84px 1fr;
}

.layout.collapsed .label {
  display: none;
}

.layout.collapsed .brand {
  justify-content: center;
}

.layout.collapsed .menu-link {
  justify-content: center;
}

.layout.collapsed .sidebar-top {
  justify-content: center;
  gap: 8px;
}

.layout.collapsed .collapse-btn .icon {
  transform: rotate(180deg);
}

.content {
  padding: 28px;
}

h1 {
  margin-top: 0;
}

.muted {
  color: var(--muted);
}

.auth-wrapper {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  position: relative;
  background-color: #061737;
  background-image: url('/static/Fondo_Login.png');
  background-size: min(644px, 101vw);
  background-position: center 6%;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.auth-wrapper::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(90deg, rgba(6, 23, 55, 0.22) 0%, rgba(6, 23, 55, 0.10) 40%, rgba(6, 23, 55, 0.52) 100%);
  pointer-events: none;
}

.auth-card {
  background: var(--surface);
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
  position: relative;
  z-index: 1;
}

.auth-form {
  display: grid;
  gap: 10px;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

button {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: var(--primary-dark);
}

.alerts {
  margin: 12px 0;
}

.alert {
  border-radius: 8px;
  padding: 10px;
  font-size: 0.92rem;
  margin-bottom: 8px;
}

.alert.error {
  background: #fee2e2;
  color: #7f1d1d;
}

.chat-section {
  max-width: 900px;
}

.chat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 320px;
  max-height: 55vh;
  overflow-y: auto;
  padding: 14px;
  margin-bottom: 12px;
}

.message {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  white-space: pre-wrap;
}

.message.user {
  background: #dbeafe;
}

.message.assistant {
  background: #ecfccb;
}

.chat-form {
  display: grid;
  gap: 10px;
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.history-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 10px;
}

@media (max-width: 860px) {
  .auth-wrapper {
    background-size: min(495px, 106vw);
    background-position: center 2%;
  }

  .auth-wrapper::before {
    background: linear-gradient(180deg, rgba(6, 23, 55, 0.32) 0%, rgba(6, 23, 55, 0.26) 100%);
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .layout.collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
  }

  .collapse-btn {
    display: none;
  }

  .brand {
    margin-bottom: 0;
  }

  .brand .label {
    display: none;
  }

  .sidebar-top {
    margin-bottom: 0;
    width: auto;
  }

  .sidebar nav {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .menu-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    margin-bottom: 0;
  }

  .menu-link .label {
    display: none;
  }

  .layout.collapsed .label {
    display: none;
  }
}
