@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=Syne:wght@600;700;800&display=swap");

:root {
  --bg-1: #0b3d3a;
  --bg-2: #145c57;
  --bg-3: #1a7a6d;
  --surface: rgba(255, 255, 255, 0.92);
  --ink: #0f2e2c;
  --muted: #4a6b68;
  --line: rgba(15, 46, 44, 0.1);
  --accent: #f0b429;
  --accent-ink: #1a1200;
  --ok: #0f766e;
  --danger: #b91c1c;
  --shadow: 0 24px 60px rgba(8, 40, 38, 0.28);
  --radius: 28px;
  --font-display: "Syne", sans-serif;
  --font-body: "Outfit", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 60% at 10% 0%, rgba(240, 180, 41, 0.22), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 10%, rgba(255, 255, 255, 0.12), transparent 50%),
    linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 45%, var(--bg-3) 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

.page {
  position: relative;
  z-index: 1;
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3.5rem 0 4rem;
}

.brand {
  text-align: center;
  color: #f5fffd;
  margin-bottom: 2.75rem;
  animation: rise 0.7s ease both;
}

.brand__mark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  letter-spacing: -0.03em;
  margin: 0 0 0.85rem;
}

.brand__mark svg {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
}

.brand__title {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand__sub {
  margin: 0 auto;
  max-width: 28rem;
  color: rgba(245, 255, 253, 0.78);
  font-size: 1.05rem;
  line-height: 1.55;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  max-width: 960px;
  margin: 0 auto;
}

.qr-empty {
  text-align: center;
  color: rgba(245, 255, 253, 0.75);
  padding: 2rem 1rem;
}

.qr-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem 1.35rem 1.6rem;
  box-shadow: var(--shadow);
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(10px);
  animation: rise 0.75s ease both;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.qr-card:nth-child(1) { animation-delay: 0.08s; }
.qr-card:nth-child(2) { animation-delay: 0.16s; }
.qr-card:nth-child(3) { animation-delay: 0.24s; }

.qr-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 32px 70px rgba(8, 40, 38, 0.35);
}

.qr-card__frame {
  aspect-ratio: 1;
  border-radius: 20px;
  background:
    linear-gradient(145deg, #f7fffe, #e8f5f2);
  padding: 0.85rem;
  margin-bottom: 1.15rem;
  border: 1px solid var(--line);
  overflow: hidden;
}

.qr-card__frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
}

.qr-card__name {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.qr-card__desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.foot {
  margin-top: 2.5rem;
  text-align: center;
  color: rgba(245, 255, 253, 0.55);
  font-size: 0.85rem;
  animation: rise 0.8s ease 0.3s both;
}

.foot a {
  color: rgba(245, 255, 253, 0.8);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s, color 0.2s;
}

.foot a:hover {
  color: #fff;
  border-bottom-color: rgba(255, 255, 255, 0.5);
}

/* Admin / Login */
.admin-shell {
  width: min(920px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.5rem 0 3.5rem;
  position: relative;
  z-index: 1;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.55);
  animation: rise 0.55s ease both;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.panel__head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  letter-spacing: -0.03em;
}

.panel__actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.65rem 1.15rem;
  border-radius: 999px;
  border: none;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.btn--primary {
  background: var(--ink);
  color: #f5fffd;
}

.btn--primary:hover {
  background: #163f3c;
}

.btn--accent {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn--ghost:hover {
  background: rgba(15, 46, 44, 0.05);
}

.field {
  margin-bottom: 1.1rem;
}

.field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.field input[type="text"],
.field input[type="password"],
.field input[type="file"] {
  width: 100%;
  min-height: 44px;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-family: var(--font-body);
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
}

.field input[type="file"] {
  padding: 0.55rem;
  cursor: pointer;
}

.field input:focus-visible {
  outline: 3px solid rgba(240, 180, 41, 0.55);
  outline-offset: 1px;
  border-color: var(--accent);
}

.admin-item {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1.25rem;
  padding: 1.25rem 0;
  border-top: 1px solid var(--line);
}

.admin-item:first-of-type {
  border-top: none;
  padding-top: 0;
}

.admin-preview {
  border-radius: 16px;
  background: #eef8f5;
  border: 1px solid var(--line);
  padding: 0.65rem;
  aspect-ratio: 1;
}

.admin-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.flash {
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  font-weight: 500;
}

.flash--ok {
  background: #ccfbf1;
  color: var(--ok);
}

.flash--error {
  background: #fee2e2;
  color: var(--danger);
}

.admin-section-title {
  margin: 1.75rem 0 1rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  border-top: 1px solid var(--line);
  padding-top: 1.25rem;
}

.admin-section-title:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0.5rem;
}

.admin-create {
  display: grid;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.admin-empty {
  color: var(--muted);
  margin: 0 0 1rem;
}

.admin-item__actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.admin-delete-form {
  display: inline-block;
}

.btn--danger {
  background: #fee2e2;
  color: var(--danger);
}

.btn--danger:hover {
  background: #fecaca;
}

.admin-preview__empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-wrap {
  width: min(400px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 18vh 0 3rem;
  position: relative;
  z-index: 1;
}

.login-wrap .panel h1 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.6rem;
}

.login-wrap .hint {
  margin: 0 0 1.4rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.login-wrap .btn {
  width: 100%;
  margin-top: 0.5rem;
}

.error-inline {
  margin: 0 0 1rem;
  color: var(--danger);
  font-size: 0.95rem;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 860px) {
  .qr-grid {
    grid-template-columns: 1fr;
    max-width: 360px;
    margin: 0 auto;
  }

  .admin-item {
    grid-template-columns: 1fr;
  }

  .admin-preview {
    max-width: 180px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Chat widget (visitor) ---------- */
.chat-fab {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 40;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.chat-fab:hover {
  transform: translateY(-3px) scale(1.03);
}

.chat-fab:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.chat-fab svg {
  width: 28px;
  height: 28px;
}

.chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-badge[hidden] {
  display: none !important;
}

.chat-badge[hidden] {
  display: none !important;
}

.chat-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 5.5rem;
  z-index: 41;
  width: min(380px, calc(100vw - 1.5rem));
  height: min(560px, calc(100vh - 7rem));
  display: flex;
  flex-direction: column;
  background: #f7fffe;
  border-radius: 22px;
  box-shadow: 0 28px 70px rgba(8, 40, 38, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.7);
  overflow: hidden;
  animation: rise 0.25s ease both;
}

.chat-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  background: linear-gradient(135deg, #0f3d3a, #1a7a6d);
  color: #f5fffd;
}

.chat-panel__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.chat-panel__head p {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  opacity: 0.8;
}

.chat-panel__close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background:
    radial-gradient(circle at 0 0, rgba(26, 122, 109, 0.08), transparent 40%),
    #eef8f5;
}

.chat-bubble {
  max-width: 82%;
  padding: 0.7rem 0.85rem 0.45rem;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.45;
  box-shadow: 0 4px 14px rgba(15, 46, 44, 0.06);
}

.chat-bubble p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble img {
  max-width: 100%;
  border-radius: 10px;
  cursor: zoom-in;
}

.chat-bubble__time {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  opacity: 0.55;
}

.chat-bubble--me {
  align-self: flex-end;
  background: #0f3d3a;
  color: #f5fffd;
  border-bottom-right-radius: 6px;
}

.chat-bubble--them {
  align-self: flex-start;
  background: #fff;
  color: var(--ink);
  border-bottom-left-radius: 6px;
}

.chat-compose {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.75rem;
  background: #fff;
  border-top: 1px solid var(--line);
}

.chat-compose input[type="text"] {
  flex: 1;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
}

.chat-compose input[type="text"]:focus-visible {
  outline: 3px solid rgba(240, 180, 41, 0.45);
  border-color: var(--accent);
}

.chat-icon-btn,
.chat-send-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-icon-btn {
  background: #e8f5f2;
  color: var(--ink);
}

.chat-send-btn {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  width: auto;
  padding: 0 1rem;
  border-radius: 999px;
}

.chat-icon-btn:hover,
.chat-send-btn:hover {
  transform: translateY(-1px);
}

/* ---------- Admin chat console ---------- */
.admin-nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chat-console {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
  position: relative;
  z-index: 1;
}

.chat-console__panel {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: min(720px, calc(100vh - 4rem));
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.conv-side {
  border-right: 1px solid var(--line);
  background: #f3faf8;
  display: flex;
  flex-direction: column;
}

.conv-side__head {
  padding: 1.1rem 1rem;
  border-bottom: 1px solid var(--line);
}

.conv-side__head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.conv-empty {
  padding: 1.5rem 1rem;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
}

.conv-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  border-radius: 14px;
  padding: 0.85rem 0.8rem;
  cursor: pointer;
  font-family: var(--font-body);
  color: var(--ink);
  transition: background 0.15s;
}

.conv-item:hover,
.conv-item.is-active {
  background: #fff;
  box-shadow: 0 4px 14px rgba(15, 46, 44, 0.06);
}

.conv-item__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.conv-unread {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.conv-item__preview {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-item__time {
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: #7a9491;
}

.room {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fff;
}

.room__head {
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.room__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.room-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  padding: 3rem 1.5rem;
  text-align: center;
}

.room .chat-messages {
  background: #eef8f5;
  flex: 1;
  min-height: 320px;
}

#chat-room {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
}

#chat-room[hidden] {
  display: none !important;
}

.chat-panel[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  .chat-console__panel {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .conv-side {
    max-height: 260px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .chat-panel {
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
    bottom: 5.25rem;
  }
}
