/* ─── TIDEWAY SHARED DESIGN SYSTEM ─────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Syne:wght@700;800&display=swap');

:root {
  --deep: #0a1628;
  --ocean: #0f3460;
  --tide: #16a3b8;
  --foam: #e0f7fa;
  --sand: #f5e6c8;
  --gold: #d4a855;
  --white: #ffffff;
  --gray: #8899aa;
  --light-gray: #f0f4f8;
  --border: rgba(10,22,40,0.08);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 4px 24px rgba(10,22,40,0.06);
  --shadow-lg: 0 20px 60px rgba(10,22,40,0.1);
}

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

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  color: var(--deep);
  background: var(--light-gray);
  min-height: 100vh;
}

/* ─── LAYOUT ─────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--deep);
  color: var(--white);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
}

.sidebar-logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--white);
  padding: 0 8px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 24px;
}

.sidebar-logo span { color: var(--tide); }

.sidebar-nav { flex: 1; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--gray);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  margin-bottom: 4px;
  cursor: pointer;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.06);
  color: var(--white);
}

.sidebar-link.active {
  background: rgba(22,163,184,0.15);
  color: var(--tide);
}

.sidebar-link .icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--ocean);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--tide);
}

.sidebar-username {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--white);
}

.sidebar-email {
  font-size: 0.7rem;
  color: var(--gray);
}

.main-content {
  margin-left: 260px;
  flex: 1;
  padding: 32px;
  min-height: 100vh;
}

/* ─── HEADER ─────────────────────────────────────────────── */
.page-header {
  margin-bottom: 32px;
}

.page-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--deep);
  letter-spacing: -0.5px;
}

.page-subtitle {
  color: var(--gray);
  font-size: 0.95rem;
  margin-top: 4px;
}

/* ─── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
  transition: all 0.2s;
}

.card:hover {
  box-shadow: var(--shadow);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

/* ─── STAT CARDS ─────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--ocean);
}

.stat-icon {
  font-size: 1.5rem;
  margin-bottom: 12px;
}

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: 'Plus Jakarta Sans', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--tide);
  color: var(--white);
}

.btn-primary:hover {
  background: #129aa8;
  box-shadow: 0 4px 16px rgba(22,163,184,0.3);
}

.btn-secondary {
  background: var(--foam);
  color: var(--tide);
}

.btn-secondary:hover {
  background: #c8eef2;
}

.btn-ghost {
  background: transparent;
  color: var(--gray);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--light-gray);
  color: var(--deep);
}

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
}

.btn-danger:hover {
  background: #fee2e2;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

/* ─── FORMS ──────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--deep);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: 'Plus Jakarta Sans', sans-serif;
  color: var(--deep);
  background: var(--white);
  transition: all 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--tide);
  box-shadow: 0 0 0 3px rgba(22,163,184,0.1);
}

textarea.form-input {
  resize: vertical;
  min-height: 100px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--gray);
  margin-top: 4px;
}

/* ─── TABLE ──────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 14px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

tr:hover td {
  background: var(--light-gray);
}

/* ─── BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-active {
  background: #d1fae5;
  color: #059669;
}

.badge-inactive {
  background: #f3f4f6;
  color: #6b7280;
}

.badge-ai {
  background: var(--foam);
  color: var(--tide);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ─── CHAT ───────────────────────────────────────────────── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header-info h3 {
  font-size: 1rem;
  font-weight: 700;
}

.chat-header-info p {
  font-size: 0.8rem;
  color: var(--gray);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-msg {
  max-width: 70%;
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.6;
}

.chat-msg.guest {
  background: var(--light-gray);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-msg.host {
  background: var(--tide);
  color: var(--white);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-msg.host.ai {
  background: linear-gradient(135deg, var(--tide), var(--ocean));
}

.chat-msg-meta {
  font-size: 0.7rem;
  margin-top: 6px;
  opacity: 0.6;
}

.chat-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
}

.chat-input {
  flex: 1;
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.9rem;
  font-family: 'Plus Jakarta Sans', sans-serif;
  outline: none;
}

.chat-input:focus {
  border-color: var(--tide);
}

.chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--tide);
  color: var(--white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.2s;
}

.chat-send:hover {
  background: #129aa8;
}

/* ─── MODAL ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,22,40,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 32px;
  transform: translateY(20px);
  transition: all 0.2s;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--gray);
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--light-gray);
  color: var(--deep);
}

/* ─── EMPTY STATE ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--gray);
  font-size: 0.9rem;
  max-width: 400px;
  margin: 0 auto 20px;
}

/* ─── TOAST ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--white);
  background: var(--deep);
  box-shadow: var(--shadow-lg);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
  z-index: 300;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ─── LOADING ────────────────────────────────────────────── */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--tide);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  gap: 12px;
  color: var(--gray);
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: 20px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .chat-msg {
    max-width: 85%;
  }
}

@media (max-width: 500px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── AUTH PAGES ─────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(175deg, var(--white) 0%, var(--foam) 40%, var(--white) 100%);
  padding: 20px;
}

.auth-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.8rem;
  color: var(--ocean);
  text-align: center;
  margin-bottom: 8px;
}

.auth-logo span { color: var(--tide); }

.auth-subtitle {
  text-align: center;
  color: var(--gray);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.auth-form .btn {
  width: 100%;
  justify-content: center;
  padding: 14px;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.85rem;
  color: var(--gray);
}

.auth-footer a {
  color: var(--tide);
  text-decoration: none;
  font-weight: 600;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-error {
  background: #fef2f2;
  color: var(--danger);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}

.auth-error.show { display: block; }

/* ─── GUEST CHAT PAGE ────────────────────────────────────── */
.guest-page {
  min-height: 100vh;
  background: var(--light-gray);
}

.guest-nav {
  background: var(--white);
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.guest-nav .logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--ocean);
}

.guest-nav .logo span { color: var(--tide); }

.guest-chat-wrap {
  max-width: 700px;
  margin: 32px auto;
  padding: 0 16px;
}

.guest-intro-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 32px;
  border: 1px solid var(--border);
  margin-bottom: 24px;
  text-align: center;
}

.guest-intro-card h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.guest-intro-card p {
  color: var(--gray);
  font-size: 0.9rem;
}

.guest-form {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.guest-chat-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  height: 500px;
  display: flex;
  flex-direction: column;
}

.guest-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ─── CONVERSATION LIST ──────────────────────────────────── */
.convo-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.convo-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
}

.convo-item:hover {
  border-color: var(--tide);
  box-shadow: var(--shadow);
}

.convo-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--foam);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.convo-info {
  flex: 1;
  min-width: 0;
}

.convo-name {
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.convo-preview {
  font-size: 0.8rem;
  color: var(--gray);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.convo-meta {
  text-align: right;
  flex-shrink: 0;
}

.convo-time {
  font-size: 0.75rem;
  color: var(--gray);
}

.convo-count {
  background: var(--tide);
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  margin-top: 4px;
  display: inline-block;
}

/* ─── PROPERTY CARDS ─────────────────────────────────────── */
.property-card-dash {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
  transition: all 0.2s;
  cursor: pointer;
}

.property-card-dash:hover {
  border-color: var(--tide);
  box-shadow: var(--shadow);
}

.property-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.property-card-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.property-card-location {
  font-size: 0.8rem;
  color: var(--gray);
  margin-top: 2px;
}

.property-card-stats {
  display: flex;
  gap: 16px;
}

.property-card-stat {
  text-align: center;
}

.property-card-stat-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--ocean);
}

.property-card-stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray);
  font-weight: 600;
}

/* ─── FLEX HELPERS ───────────────────────────────────────── */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.hidden { display: none !important; }
