:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --text: #10213b;
  --muted: #60708a;
  --primary: #0b5bd3;
  --primary-strong: #0948a8;
  --line: #dbe4f0;
  --scroll-track: rgba(133, 160, 202, 0.14);
  --scroll-thumb: rgba(111, 141, 186, 0.34);
  --scroll-thumb-hover: rgba(92, 125, 173, 0.5);
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* Scrollbar styling */
.main,
.sidebar-nav,
.conv-items,
.thread-body,
.modal-body,
[class*="list"] {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

.main::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar,
.conv-items::-webkit-scrollbar,
.thread-body::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
[class*="list"]::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.main::-webkit-scrollbar-track,
.sidebar-nav::-webkit-scrollbar-track,
.conv-items::-webkit-scrollbar-track,
.thread-body::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
[class*="list"]::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 999px;
}

.main::-webkit-scrollbar-thumb,
.sidebar-nav::-webkit-scrollbar-thumb,
.conv-items::-webkit-scrollbar-thumb,
.thread-body::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
[class*="list"]::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
  border: 1px solid transparent;
}

.main::-webkit-scrollbar-thumb:hover,
.sidebar-nav::-webkit-scrollbar-thumb:hover,
.conv-items::-webkit-scrollbar-thumb:hover,
.thread-body::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
[class*="list"]::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(16, 33, 59, 0.04);
}

.muted {
  color: var(--muted);
}

.is-hidden {
  display: none !important;
}

.app-lottie-loader {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

.app-lottie-loader__anim {
  width: 82px;
  height: 82px;
  position: relative;
}

.app-lottie-loader--sm .app-lottie-loader__anim {
  width: 62px;
  height: 62px;
}

.app-lottie-loader--lg .app-lottie-loader__anim {
  width: 110px;
  height: 110px;
}

.app-lottie-loader__anim dotlottie-wc {
  width: 100%;
  height: 100%;
  display: block;
}

.app-lottie-loader__fallback {
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  border: 3px solid #d8e4f7;
  border-top-color: #0d5bd7;
  animation: appLoaderSpin 0.9s linear infinite;
}

.has-dotlottie .app-lottie-loader__fallback {
  display: none;
}

.app-lottie-loader__copy strong {
  display: block;
  color: #123a78;
  font-size: 14px;
}

.app-lottie-loader__copy p {
  margin: 4px 0 0;
  color: #617896;
  font-size: 13px;
  line-height: 1.4;
}

.app-global-loader {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(13, 91, 215, 0.08), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(12, 142, 96, 0.08), transparent 40%),
    rgba(245, 249, 255, 0.78);
  backdrop-filter: blur(1.5px);
}

.app-global-loader.is-active {
  display: flex;
}

.app-global-loader__card {
  width: min(460px, calc(100vw - 28px));
  border: 1px solid #dbe4f0;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(16, 33, 59, 0.15);
  padding: 22px 20px;
}

.app-global-loader .app-lottie-loader {
  gap: 12px;
}

.app-global-loader .app-lottie-loader__anim {
  width: 210px;
  height: 210px;
}

.app-global-loader .app-lottie-loader__copy strong {
  font-size: 19px;
}

.app-global-loader .app-lottie-loader__copy p {
  font-size: 14px;
}

@media (max-width: 640px) {
  .app-global-loader .app-lottie-loader__anim {
    width: 160px;
    height: 160px;
  }
}

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

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 13px;
  color: #314461;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  outline: none;
  background: #fff;
}

input:focus {
  border-color: #9dbaf2;
  box-shadow: 0 0 0 3px rgba(11, 91, 211, 0.12);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-strong);
}

.btn-outline {
  border: 1px solid #b8c9e3;
  background: #fff;
  color: #214777;
}

.msg {
  min-height: 20px;
  margin: 0;
  font-size: 13px;
}

.msg-error {
  color: #b42318;
}

.msg-ok {
  color: #027a48;
}

/* Global topbar (reutilizable en todas las vistas) */
.topbar {
  padding: 0 10px;
  height: 52px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  overflow: hidden;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar-title {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
}

.badge {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 999px;
  background: #eff4fd;
  color: #264c7d;
  border: 1px solid #d8e3f5;
  font-size: 11px;
  white-space: nowrap;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge--soft {
  background: #f6f8fc;
  color: #4a5e7c;
}

.btn-menu {
  width: 32px;
  min-width: 32px;
  padding: 5px 0;
  border-radius: 8px;
  font-size: 14px;
}

#btnLogout {
  padding: 7px 12px;
}

@media (max-width: 980px) {
  .topbar {
    height: 50px;
    padding: 6px 10px;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .topbar-actions {
    gap: 4px;
    overflow-x: auto;
    max-width: 60%;
    scrollbar-width: none;
  }

  .topbar-actions::-webkit-scrollbar {
    display: none;
  }
}
