@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Instrument+Serif:ital@0;1&display=swap");

:root {
  --tool-bg: #f5f2ea;
  --tool-bg-2: #fbfaf6;
  --tool-panel: #ffffff;
  --tool-panel-soft: #f7f8f4;
  --tool-ink: #101827;
  --tool-muted: #667085;
  --tool-soft: #98a2b3;
  --tool-border: #e4e0d5;
  --tool-border-strong: #d6d0c2;
  --tool-brand: #0f766e;
  --tool-brand-2: #14b8a6;
  --tool-brand-soft: #dff8f3;
  --tool-blue: #2563eb;
  --tool-blue-soft: #e8f0ff;
  --tool-amber: #c77803;
  --tool-amber-soft: #fff2d2;
  --tool-red: #d92d20;
  --tool-red-soft: #fff1ef;
  --tool-green: #12805c;
  --tool-green-soft: #e5f8ef;
  --tool-shadow: 0 16px 46px rgba(16, 24, 40, 0.09);
  --tool-shadow-soft: 0 10px 28px rgba(16, 24, 40, 0.06);
  --tool-radius: 8px;
  --tool-radius-sm: 6px;
  --tool-focus: 0 0 0 4px rgba(20, 184, 166, 0.18);
}

* {
  box-sizing: border-box;
}

body.saas-page,
body.auth-page,
body.dashboard-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 0 0, rgba(20, 184, 166, 0.16), transparent 34rem),
    linear-gradient(135deg, #fbfaf6 0%, #f5f2ea 47%, #eef4f1 100%);
  color: var(--tool-ink);
  font-family: "Plus Jakarta Sans", "Aptos", "Segoe UI", sans-serif;
  letter-spacing: -0.01em;
}

a {
  color: var(--tool-brand);
}

a:hover {
  color: #0b5f59;
}

.spin {
  animation: tool-spin 1s linear infinite;
}

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

@keyframes tool-rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.tool-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.tool-logo-mark {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: var(--tool-radius);
  color: #fff;
  background: linear-gradient(135deg, var(--tool-brand), #0b3f3b);
  box-shadow: 0 12px 26px rgba(15, 118, 110, 0.24);
}

.btn-tool {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--tool-border);
  border-radius: var(--tool-radius);
  padding: 10px 16px;
  background: #fff;
  color: var(--tool-ink);
  font-weight: 700;
  text-decoration: none;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background 180ms ease;
}

.btn-tool:hover {
  border-color: var(--tool-border-strong);
  box-shadow: var(--tool-shadow-soft);
  color: var(--tool-ink);
  transform: translateY(-1px);
}

.btn-tool-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--tool-brand-2), var(--tool-brand));
  color: #fff;
  box-shadow: 0 18px 34px rgba(15, 118, 110, 0.22);
}

.btn-tool-primary:hover {
  color: #fff;
  box-shadow: 0 20px 38px rgba(15, 118, 110, 0.28);
}

.btn-tool-danger {
  border-color: rgba(217, 45, 32, 0.18);
  background: var(--tool-red-soft);
  color: var(--tool-red);
}

.tool-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--tool-border);
  border-radius: 999px;
  padding: 5px 10px;
  background: #fff;
  color: var(--tool-muted);
  font-size: 12px;
  font-weight: 700;
}

.tool-badge.success {
  border-color: rgba(18, 128, 92, 0.22);
  background: var(--tool-green-soft);
  color: var(--tool-green);
}

.tool-badge.warning {
  border-color: rgba(199, 120, 3, 0.24);
  background: var(--tool-amber-soft);
  color: var(--tool-amber);
}

.tool-badge.info {
  border-color: rgba(37, 99, 235, 0.2);
  background: var(--tool-blue-soft);
  color: var(--tool-blue);
}

.saas-card {
  border: 1px solid var(--tool-border);
  border-radius: var(--tool-radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--tool-shadow-soft);
}

.saas-section-title {
  margin: 0;
  color: var(--tool-ink);
  font-size: clamp(1.45rem, 2.2vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -0.055em;
}

.saas-section-kicker {
  margin: 0 0 10px;
  color: var(--tool-brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Auth surfaces */
.auth-page {
  overflow-x: hidden;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1.05fr) minmax(440px, 0.95fr);
}

.auth-story {
  position: relative;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(28px, 5vw, 64px);
  overflow: hidden;
  color: #f8fbfb;
  background:
    linear-gradient(135deg, rgba(12, 91, 85, 0.96), rgba(8, 16, 32, 0.98)),
    radial-gradient(circle at 15% 15%, rgba(251, 188, 5, 0.22), transparent 26rem);
}

.auth-story::before {
  content: "";
  position: absolute;
  inset: auto -12% -16% 20%;
  height: 42%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(20, 184, 166, 0.2), rgba(37, 99, 235, 0.08));
  transform: rotate(-9deg);
}

.auth-story > * {
  position: relative;
  z-index: 1;
}

.auth-copy {
  max-width: 720px;
  animation: tool-rise 500ms ease both;
}

.auth-copy h1 {
  margin: 0;
  font-size: clamp(3rem, 6vw, 6.5rem);
  font-weight: 800;
  letter-spacing: -0.08em;
  line-height: 0.96;
}

.auth-copy p {
  max-width: 640px;
  margin: 22px 0 0;
  color: rgba(248, 251, 251, 0.74);
  font-size: clamp(1rem, 1.45vw, 1.35rem);
  line-height: 1.75;
}

.auth-proof-list {
  display: grid;
  max-width: 760px;
  gap: 14px;
  margin-top: 36px;
}

.auth-proof-item {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--tool-radius);
  padding: 17px 18px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(248, 251, 251, 0.9);
  backdrop-filter: blur(14px);
}

.auth-proof-item i {
  color: #a7f3d0;
  font-size: 20px;
}

.auth-footnote {
  color: rgba(248, 251, 251, 0.55);
  font-size: 14px;
}

.auth-form-side {
  display: grid;
  min-height: 100vh;
  align-items: center;
  padding: clamp(24px, 5vw, 76px);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(22px);
}

.auth-card {
  width: min(100%, 540px);
  margin-inline: auto;
  animation: tool-rise 650ms ease both;
}

.auth-card h2 {
  margin: 0;
  color: var(--tool-ink);
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.07em;
}

.auth-card .lead {
  margin: 12px 0 34px;
  color: var(--tool-muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.auth-form {
  display: grid;
  gap: 18px;
}

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

.auth-field label {
  color: var(--tool-ink);
  font-size: 14px;
  font-weight: 800;
}

.auth-input-wrap {
  display: flex;
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--tool-border);
  border-radius: var(--tool-radius);
  background: #fff;
  overflow: hidden;
  transition: box-shadow 180ms ease, border-color 180ms ease;
}

.auth-input-wrap:focus-within {
  border-color: var(--tool-brand-2);
  box-shadow: var(--tool-focus);
}

.auth-input-wrap > i {
  margin-left: 18px;
  color: var(--tool-soft);
}

.auth-input-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 16px 18px;
  background: transparent;
  color: var(--tool-ink);
  font-size: 1rem;
}

.auth-input-wrap .auth-toggle {
  display: grid;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--tool-muted);
}

.auth-actions {
  display: grid;
  gap: 14px;
  margin-top: 4px;
}

.auth-actions .btn-tool {
  width: 100%;
}

.auth-switch {
  margin: 22px 0 0;
  color: var(--tool-muted);
  text-align: center;
}

.auth-note {
  border: 1px solid var(--tool-border);
  border-radius: var(--tool-radius);
  padding: 14px 16px;
  background: var(--tool-panel-soft);
  color: var(--tool-muted);
  font-size: 13px;
  line-height: 1.6;
}

.alert {
  border-radius: var(--tool-radius);
}

/* Dashboard compatibility layer */
body.dashboard-page {
  background: #f5f2ea;
}

.dashboard-wrapper {
  background:
    radial-gradient(circle at 10% 8%, rgba(20, 184, 166, 0.1), transparent 34rem),
    linear-gradient(135deg, #fbfaf6 0%, #f4f0e7 100%);
}

.dashboard-sidebar {
  background: rgba(255, 255, 255, 0.86) !important;
  border-right: 1px solid var(--tool-border) !important;
  backdrop-filter: blur(18px);
}

.dashboard-main {
  background: transparent !important;
}

.page-header,
.chat-list-panel,
.chat-panel,
.visitor-info-panel,
.modern-card,
.stat-card,
.agent-stat,
.setup-wizard {
  border-color: var(--tool-border) !important;
  border-radius: var(--tool-radius) !important;
  background: rgba(255, 255, 255, 0.9) !important;
  box-shadow: var(--tool-shadow-soft) !important;
}

.sidebar-logo {
  color: var(--tool-ink) !important;
}

.sidebar-logo i,
.page-title i,
.card-title i,
.panel-title i {
  color: var(--tool-brand) !important;
}

.nav-item {
  border-radius: var(--tool-radius) !important;
}

.nav-item.active,
.filter-chip.active {
  background: var(--tool-brand-soft) !important;
  color: var(--tool-brand) !important;
}

.btn-primary,
.btn.btn-primary {
  border-color: transparent !important;
  background: linear-gradient(135deg, var(--tool-brand-2), var(--tool-brand)) !important;
  color: #fff !important;
}

.btn-success,
.btn.btn-success {
  border-color: transparent !important;
  background: var(--tool-green) !important;
  color: #fff !important;
}

.form-control:focus,
.form-select:focus,
.message-input:focus,
input:focus,
textarea:focus,
select:focus {
  border-color: var(--tool-brand-2) !important;
  box-shadow: var(--tool-focus) !important;
}

.chat-area {
  gap: 16px !important;
}

.chat-item {
  border-radius: var(--tool-radius) !important;
}

.chat-item.active {
  border-color: rgba(15, 118, 110, 0.28) !important;
  background: var(--tool-brand-soft) !important;
}

.message-bubble {
  border-radius: var(--tool-radius) !important;
}

.message-bubble.agent {
  background: #0f766e !important;
}

.message-bubble.visitor {
  background: #fff !important;
  border: 1px solid var(--tool-border) !important;
}

.mobile-menu-toggle {
  border-radius: var(--tool-radius) !important;
  background: var(--tool-brand) !important;
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.26) !important;
}

/* Admin compatibility */
.admin-navbar {
  border-bottom: 1px solid var(--tool-border);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--tool-shadow-soft);
  backdrop-filter: blur(16px);
}

.admin-navbar .navbar-brand,
.admin-navbar .nav-link {
  color: var(--tool-ink);
}

.admin-navbar .nav-link:hover,
.admin-navbar .nav-link:focus {
  color: var(--tool-brand);
}

.admin-navbar .navbar-toggler {
  border-color: var(--tool-border);
}

.dashboard-page .card,
.dashboard-page .table,
.dashboard-page .modal-content {
  border-color: var(--tool-border);
  border-radius: var(--tool-radius);
}

.dashboard-page .card {
  box-shadow: var(--tool-shadow-soft);
}

.dashboard-page .table thead th {
  color: var(--tool-muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

@media (max-width: 1060px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-story,
  .auth-form-side {
    min-height: auto;
  }

  .auth-story {
    padding-bottom: 42px;
  }

  .auth-footnote {
    margin-top: 42px;
  }
}

@media (max-width: 768px) {
  body.auth-page {
    background: #fff;
  }

  .auth-story {
    padding: 24px;
  }

  .auth-copy h1 {
    font-size: clamp(2.5rem, 13vw, 4.5rem);
  }

  .auth-proof-list {
    margin-top: 24px;
  }

  .auth-proof-item {
    align-items: flex-start;
    padding: 14px;
  }

  .auth-form-side {
    padding: 28px 20px 42px;
  }

  .auth-card h2 {
    font-size: 2.25rem;
  }

  .dashboard-wrapper {
    min-height: 100vh;
  }

  .page-title {
    font-size: 1.65rem !important;
  }

  .chat-area {
    grid-template-columns: 1fr !important;
    height: auto !important;
    min-height: calc(100vh - 120px);
  }

  .chat-list-panel,
  .chat-panel,
  .visitor-info-panel {
    min-height: 460px;
  }

  .chat-panel-header,
  .chat-list-header {
    flex-wrap: wrap;
    gap: 12px;
  }

  .stats-bar,
  .agent-stats-bar {
    grid-template-columns: 1fr !important;
  }

  .content-area {
    padding: 16px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
