/* BTH Messaging PWA - Redesign (Clean, Minimal, Warm) */

:root {
  /* Color Palette - Slate/Zinc inspired */
  --bg-app: #f8fafc; /* Slate 50 */
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9; /* Slate 100 */
  
  --text-primary: #1e293b; /* Slate 800 */
  --text-secondary: #64748b; /* Slate 500 */
  --text-tertiary: #94a3b8; /* Slate 400 */

  /* Accents */
  --primary: #4f46e5; /* Indigo 600 - Warm & Approachable */
  --primary-soft: #e0e7ff; /* Indigo 100 */
  --primary-dark: #4338ca; /* Indigo 700 */

  --success: #10b981; /* Emerald 500 */
  --success-soft: #d1fae5; /* Emerald 100 */
  
  --warning: #f59e0b; /* Amber 500 */
  --warning-soft: #fef3c7; /* Amber 100 */

  --danger: #ef4444; /* Red 500 */
  --danger-soft: #fee2e2; /* Red 100 */

  --border-color: #e2e8f0; /* Slate 200 */
  
  /* Layout */
  --max-width: 480px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);

  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

#app {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg-app);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1, h2, h3 {
  margin: 0;
  font-weight: 600;
  color: var(--text-primary);
}

p {
  margin: 0 0 1rem 0;
}

/* Header */
.header {
  background: var(--bg-app);
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(8px);
  background: rgba(248, 250, 252, 0.9);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.header.scrolled {
  border-bottom-color: var(--border-color);
}

.header h1 {
  font-size: 20px;
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

body.menu-open {
  overflow: hidden;
}

/* Global Menu */
.menu-scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 250;
}

.menu-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(320px, 86vw);
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.12);
  transform: translateX(100%);
  transition: transform 0.22s ease;
  z-index: 260;
  display: flex;
  flex-direction: column;
}

body.menu-open .menu-scrim {
  opacity: 1;
  pointer-events: auto;
}

body.menu-open .menu-drawer {
  transform: translateX(0);
}

.menu-header {
  padding: 20px 20px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.menu-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  position: relative;
}

.menu-avatar::after {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}

.menu-user {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.menu-username {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-list {
  padding: 8px 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-item {
  width: 100%;
  text-align: left;
  padding: 12px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  position: relative;
}

.menu-item:hover {
  background: var(--bg-subtle);
}

.menu-item.active {
  font-weight: 600;
  background: var(--bg-subtle);
}

.menu-item.active::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 999px;
  background: var(--primary);
}

.menu-item.danger {
  color: var(--danger);
}

.menu-item.disabled,
.menu-item:disabled {
  color: var(--text-tertiary);
  cursor: not-allowed;
  background: transparent;
}

.menu-separator {
  height: 1px;
  background: var(--border-color);
  margin: 6px 8px;
}

.demo-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  background: #f59e0b;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover, .btn-icon:active {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.btn-icon.danger {
  color: var(--danger);
}

.btn-icon.danger:hover {
  background: var(--danger-soft);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.btn-secondary {
  background: white;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

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

/* Two-step send confirmation - armed state */
.btn.armed {
  background: var(--danger) !important;
  color: white !important;
  animation: pulse-armed 0.5s ease-in-out infinite alternate;
}

@keyframes pulse-armed {
  from { opacity: 1; }
  to { opacity: 0.85; }
}

.btn-warning {
  background: var(--warning);
  color: white;
  box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.btn-warning:active {
  background: #d97706;
}

.btn-danger {
  background: var(--bg-card);
  color: var(--danger);
  border: 1px solid var(--danger-soft);
}

.btn-danger:active {
    background: var(--danger-soft);
}

.btn-link {
    background: none;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 8px 16px;
}

/* Dashboard */
.dashboard-content {
  padding: 0 16px 80px 16px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 24px 4px 12px 4px;
}

/* Tab Switcher */
.tab-switcher {
  display: flex;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 4px;
  margin: 0 4px 16px 4px;
}

.tab-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.tab-btn:not(.active):hover {
  color: var(--text-primary);
}

/* Archive All Button */
.archive-all-container {
  margin-top: 24px;
  padding: 16px;
  text-align: center;
}

.btn-archive-all {
  background: transparent;
  border: 1px dashed var(--border-color);
  color: var(--text-tertiary);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-archive-all:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

/* ============================================
   Card Layout - Shared between Inbox and Archive (KAN-232, KAN-233)
   ============================================

   IMPORTANT: Inbox cards (.message-card-content) and Archive cards
   (.archive-card) must use the same internal structure to maintain
   visual consistency when switching tabs.

   Card structure (identical for both):
   - Row 1: Property (left) + Status/Time/Restore (right)
   - Row 2: Guest name
   - Row 3: Badges (left) + Confirmation/Dates (right)
   - Row 4: Message preview

   Shared classes:
   - .archive-row (base row with flexbox justify-content: space-between)
   - .archive-row-header, .archive-row-context, .archive-row-preview
   - .archive-property, .archive-time, .archive-guest, .archive-header-right
   - .archive-badges, .archive-trip-details
   - .trip-phase-badge, .trip-channel-badge, .trip-dates, .trip-confirmation

   Archive-only (in header row):
   - .archive-status, .btn-unarchive

   When modifying card layout, update BOTH renderInboxView() and
   renderArchiveView() in app.js to keep them in sync.
   ============================================ */

.archive-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Each row uses flexbox for left/right alignment */
.archive-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 20px;
}

/* Row 1: Header (Property + Time) */
.archive-row-header {
  margin-bottom: 2px;
}

.archive-property {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.archive-time {
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* Header right side: status + time + restore button */
.archive-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Row 2: Guest name */
.archive-guest {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Row 3: Context (Badges left, Confirmation/Dates right) */
.archive-row-context {
  margin-top: 0;
  align-items: flex-end; /* Bottom-align both sides */
}

.archive-badges {
  display: flex;
  align-items: flex-end; /* Bottom-align badges */
  gap: 6px;
  flex-shrink: 0;
}

.archive-dates {
  flex-shrink: 0;
  text-align: right;
}

/* Stacked confirmation + dates on the right */
.archive-trip-details {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end; /* Bottom-align content */
  gap: 2px;
  flex-shrink: 0;
  text-align: right;
}

/* Row 4: Footer (Confirmation left, Status/Actions right) */
.archive-row-footer {
  margin-top: 2px;
}

.archive-confirmation {
  flex: 1;
  min-width: 0;
}

.archive-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.archive-status {
  font-size: 11px;
  color: var(--text-tertiary);
}

.archive-status.sent {
  color: var(--success);
}

.archive-status.feedback {
  color: var(--primary);
}

/* Restore button */
.btn-unarchive {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-unarchive:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

/* Row 5: Message preview */
.archive-row-preview {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--bg-subtle);
}

.archive-preview {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================
   Trip Context Badges
   ============================================ */

/* Phase badges */
.trip-phase-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.phase-inquiry {
  background: #fef3c7;
  color: #92400e;
}

.phase-confirmed {
  background: #dbeafe;
  color: #1e40af;
}

.phase-current {
  background: #d1fae5;
  color: #065f46;
}

.phase-past {
  background: #f3f4f6;
  color: #6b7280;
}

.phase-canceled {
  background: #fee2e2;
  color: #991b1b;
}

/* Replied externally badge (KAN-291) */
.replied-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  background: #dbeafe;
  color: #1e40af;
  white-space: nowrap;
}

/* Channel badge (text, not emoji) */
.trip-channel-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Date range */
.trip-dates {
  color: var(--text-secondary);
  font-size: 11px;
  white-space: nowrap;
}

/* Confirmation code */
.trip-confirmation {
  color: var(--text-tertiary);
  font-size: 10px;
  font-family: ui-monospace, monospace;
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 3px;
}

/* Empty state text icon */
.empty-icon-text {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.sync-status {
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 13px;
}

.sync-status button#sync-btn {
    color: var(--primary);
    background: none;
    border: none;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}

.sync-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sync-btn-branded {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: none;
    background: var(--brand-color, var(--primary));
    color: white;
    transition: all 0.15s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sync-btn-branded:hover:not(:disabled) {
    filter: brightness(1.1);
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

.sync-btn-branded:active:not(:disabled) {
    transform: scale(0.97);
}

.sync-btn-branded:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.sync-btn-favicon {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background: white;
    padding: 1px;
}

.sync-btn-icon {
    width: 16px;
    height: 16px;
    stroke: white;
}

.sync-btn-icon.spinning {
    animation: spin 1s linear infinite;
}

/* Message List Cards */
.message-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-x: hidden; /* Prevent horizontal scrollbar on body when swiping */
}

.message-card {
  position: relative; /* For swipe context */
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  /* padding: 16px; removed padding here, moved to content */
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
  /* transition: box-shadow 0.2s, transform 0.1s; removed transform to avoid conflict with swipe */
  transition: box-shadow 0.2s;
  overflow: hidden; /* Hide the background action initially */
  touch-action: pan-y; /* Allow vertical scroll, we handle horizontal */
  user-select: none;
}

.message-card-bg {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  background-color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 24px;
  color: white;
  z-index: 1;
}

.swipe-icon {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  transform: translateX(20px);
  transition: transform 0.2s;
}

.message-card.swiping .swipe-icon,
.message-card.swipe-hint .swipe-icon {
    transform: translateX(0);
}

.message-card-content {
  position: relative;
  z-index: 2;
  background: var(--bg-card);
  padding: 12px 16px; /* Match archive-card padding */
  transition: transform 0.2s ease-out;
  height: 100%;
  width: 100%;
  /* Match archive-card layout for consistent card appearance */
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* 
.message-card:active {
  transform: scale(0.99); 
} 
Removed scale on active to not interfere with swipe logic
*/

.message-card-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.message-property {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.message-time {
  font-size: 12px;
  color: var(--text-tertiary);
}

.message-sender {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 4px;
  color: var(--text-primary);
}

/* Trip context row for inbox cards (KAN-233) */
.message-context {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 0;
  gap: 8px;
}

.message-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.message-trip-info {
  flex-shrink: 0;
  text-align: right;
}

.message-preview {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Review Screen */
.review-container {
    padding: 0 16px 100px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.review-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

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

.card-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-copy-draft {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-tertiary);
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}
.btn-copy-draft:hover {
    color: var(--text-primary);
}
.btn-copy-draft.copied {
    color: var(--success);
}

.card-content {
    padding: 16px;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.card-content.guest {
    color: var(--text-primary);
}

.card-content.suggestion {
    color: var(--text-primary);
    background: #fafafa;
}

.guest-meta {
    padding: 0 16px 12px 16px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.channel-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
}
.channel-sms { background: #e8f5e9; color: #2e7d32; }
.channel-whatsapp { background: #e8f5e9; color: #2e7d32; }
.channel-airbnb { background: #fce4ec; color: #c62828; }
.channel-vrbo { background: #e3f2fd; color: #1565c0; }
.channel-email { background: #fff3e0; color: #e65100; }

.channel-warning {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
    color: #6d4c00;
    margin-bottom: 8px;
}

/* Action Bar */
.action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    padding: 16px 20px 24px 20px;
    display: flex;
    gap: 12px;
    max-width: var(--max-width);
    margin: 0 auto;
    z-index: 50;
}

.action-bar .btn {
    flex: 1;
    height: 48px;
}

/* Edit view - inline page (no modal). Replaces review content when user taps Edit. */
.edit-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.edit-view .edit-context {
    flex-shrink: 0;
}

.edit-view .edit-form-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px 24px;
    -webkit-overflow-scrolling: touch;
}

.edit-view .action-bar {
    flex-shrink: 0;
}

/* Edit context - inquiry snippet while editing */
.edit-context {
    padding: 12px 20px;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border-color);
}

.edit-context-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.edit-context-property {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.edit-context-guest {
    font-size: 13px;
    color: var(--text-secondary);
}

.edit-context-inquiry {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.edit-context-inquiry-text {
    flex: 1;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
    /* Collapsed state - show 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.edit-context-inquiry.expanded .edit-context-inquiry-text {
    -webkit-line-clamp: unset;
    display: block;
}

.edit-context-toggle {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all 0.15s ease;
}

.edit-context-toggle:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.edit-context-toggle svg {
    display: block;
    transition: transform 0.2s ease;
}

.edit-context-inquiry.expanded .edit-context-toggle svg {
    transform: rotate(180deg);
}

.checkbox-group {
    display: flex;
    flex-direction: column; /* Stack on mobile for better touch targets */
    gap: 12px;
    margin-bottom: 20px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px 0;
}

.checkbox-item input {
    accent-color: var(--primary);
    width: 20px;
    height: 20px;
}

textarea.edit-box {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 16px; /* Prevents iOS zoom */
    line-height: 1.5;
    margin-bottom: 20px;
    resize: none;
    min-height: 150px;
    overflow-y: hidden; /* For auto-grow */
    background: var(--bg-subtle);
}

textarea.edit-box:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 2px var(--primary-soft);
}

/* Login Screen */
.login-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px 24px;
}

.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.login-header h1 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 15px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 16px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h2 {
    font-size: 18px;
    margin-bottom: 8px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: floatUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    width: max-content;
    max-width: 90%;
}

@keyframes floatUp {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.toast-with-action {
    padding-right: 12px;
}

.toast-message {
    flex: 1;
}

.toast-action-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-left: 8px;
    transition: all 0.15s ease;
}

.toast-action-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.6);
}

.toast-action-btn:active {
    transform: scale(0.95);
}

/* Update available toast - persistent, blue accent */
.toast-update {
    background: var(--primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* Utilities */
.hidden { display: none !important; }

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Welcome/Install Screen */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 40px 24px;
  text-align: center;
}

.welcome-header {
  margin-bottom: 32px;
}

.welcome-logo {
  width: 64px;
  height: 64px;
  background: var(--primary);
  color: white;
  font-size: 32px;
  font-weight: 700;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.welcome-header h1 {
  font-size: 22px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.welcome-header p {
  font-size: 15px;
  color: var(--text-secondary);
  margin: 0;
}

.welcome-install-section {
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  margin-bottom: 24px;
}

.welcome-install-section h2 {
  font-size: 17px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.welcome-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 20px 0;
}

.install-instructions {
  text-align: left;
}

.install-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 15px;
  color: var(--text-primary);
}

.install-step:last-child {
  border-bottom: none;
}

.step-number {
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.welcome-divider {
  display: flex;
  align-items: center;
  margin: 8px 0 24px;
  color: var(--text-tertiary);
  font-size: 13px;
}

.welcome-divider::before,
.welcome-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.welcome-divider span {
  padding: 0 16px;
}

.welcome-skip-note {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 12px;
}

/* iOS share icon inline */
.ios-share-icon {
  display: inline-flex;
  vertical-align: middle;
  color: var(--primary);
}

.ios-share-icon svg {
  width: 18px;
  height: 18px;
}

/* Properties Link in Dashboard */
.properties-link-container {
  margin-top: 24px;
  padding: 0 4px;
}

.properties-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.properties-link:hover {
  background: var(--bg-subtle);
}

.properties-link svg:first-child {
  color: var(--primary);
}

.properties-link span {
  flex: 1;
  text-align: left;
}

.properties-link svg:last-child {
  color: var(--text-tertiary);
}

/* Properties View */
.properties-info-banner {
  background: var(--primary-soft);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 0 4px 20px 4px;
}

.properties-info-banner p {
  margin: 0;
  font-size: 14px;
  color: var(--text-primary);
}

.properties-info-banner .properties-info-contact {
  margin-top: 8px;
  font-style: italic;
  color: var(--text-secondary);
}

.properties-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 4px;
}

.property-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.property-card:hover {
  background: var(--bg-subtle);
  border-color: var(--primary);
}

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

.property-card-name {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-primary);
}

.property-card-channel {
  font-size: 12px;
  color: var(--text-tertiary);
  background: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: 4px;
}

.property-card-address {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.property-card-action {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--primary);
  margin-top: 8px;
}

/* Property Detail View */
.property-detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Guidebook Link Section */
.property-guidebook-link {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.guidebook-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.guidebook-url {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--primary);
  text-decoration: none;
  word-break: break-all;
  -webkit-user-select: all;
  user-select: all;
}

.guidebook-url:hover {
  text-decoration: underline;
}

.btn-copy-guidebook {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.btn-copy-guidebook:hover {
  opacity: 0.9;
}

.btn-copy-guidebook:active {
  opacity: 0.8;
}

.property-detail-header {
  margin-bottom: 20px;
}

.property-detail-address {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.property-detail-channel {
  display: inline-block;
  font-size: 12px;
  color: var(--text-tertiary);
  background: var(--bg-subtle);
  padding: 4px 10px;
  border-radius: 4px;
}

.property-sender-name {
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* iCal feed section (KAN-298) */
.property-ical-section {
  background: #f9fafb;
  border: 2px solid #0d9488;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.property-ical-section label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 8px;
}

.ical-input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.ical-feed-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Courier New', monospace;
  background: white;
  color: #111827;
}

.ical-feed-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.btn-save-ical {
  padding: 10px 20px;
  background: #4f46e5; /* Explicit indigo color */
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-save-ical:hover {
  background: #4338ca; /* Darker indigo on hover */
}

.btn-save-ical:active {
  opacity: 0.9;
}

.ical-help-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

.property-knowledge {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
}

.property-knowledge h1,
.property-knowledge h2,
.property-knowledge h3 {
  color: var(--text-primary);
  margin-top: 0;
  margin-bottom: 12px;
}

.property-knowledge h1 {
  font-size: 22px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
}

.property-knowledge h2 {
  font-size: 18px;
  margin-top: 24px;
}

.property-knowledge h3 {
  font-size: 16px;
  margin-top: 20px;
}

.property-knowledge p {
  margin: 0 0 12px 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

.property-knowledge ul {
  margin: 0 0 16px 0;
  padding-left: 20px;
}

.property-knowledge li {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.property-knowledge strong {
  color: var(--text-primary);
}

.property-detail-footer {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.property-detail-footer p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.property-detail-footer .property-detail-contact {
  margin-top: 4px;
  font-style: italic;
  color: var(--text-tertiary);
}

/* Desktop Enhancements */
@media (min-width: 481px) {
    body {
        background-color: #cbd5e1; /* Slate 300 - clearly contrasting */
        background-image: radial-gradient(#94a3b8 1px, transparent 1px);
        background-size: 24px 24px;
        display: flex;
        justify-content: center;
        min-height: 100vh;
    }

    #app {
        width: 100%;
        max-width: var(--max-width);
        min-height: 100vh; /* Keep full height */
        box-shadow: 0 0 40px -5px rgba(0, 0, 0, 0.2);
        position: relative;
    }
}

@media (min-width: 900px) {
    #app {
        max-width: 980px;
        padding-left: 260px;
    }

    .menu-scrim {
        display: none;
    }

    .menu-drawer {
        position: absolute;
        left: 0;
        right: auto;
        top: 0;
        height: 100%;
        width: 260px;
        transform: none;
        border-left: none;
        border-right: 1px solid var(--border-color);
        box-shadow: none;
    }

    .header #menu-btn {
        display: none;
    }
}

/* ============ Admin Stats View (KAN-245) ============ */

.stats-view {
    padding: 16px;
}

.stats-section {
    margin-bottom: 24px;
}

.stats-section h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 12px 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-stats-list {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.user-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.user-stat-row:last-child {
    border-bottom: none;
}

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

.user-stat-email {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-stat-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.user-stat-numbers {
    display: flex;
    gap: 8px;
    margin-left: 12px;
}

.user-stat-numbers span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.user-stat-sent {
    background: var(--success-soft);
    color: var(--success);
}

.user-stat-rejected {
    background: var(--danger-soft);
    color: var(--danger);
}

.user-stat-pending {
    background: var(--warning-soft);
    color: var(--warning);
}

/* ===== Changelog View ===== */
.changelog-iframe {
    width: 100%;
    height: calc(100vh - 60px);
    border: none;
}

.changelog-view {
    padding: 20px;
    max-width: 640px;
    margin: 0 auto;
}

.changelog-view .day {
    margin-bottom: 2.5rem;
}

.changelog-view .day-header {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.changelog-view .item {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    align-items: baseline;
}

.changelog-view .time {
    color: #999;
    font-size: 0.8125rem;
    min-width: 4.5rem;
    flex-shrink: 0;
}

.changelog-view .desc {
    flex: 1;
    line-height: 1.6;
}

.changelog-footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
    color: #666;
    font-size: 0.875rem;
    line-height: 1.8;
}

@media (max-width: 480px) {
    .changelog-view .item {
        flex-direction: column;
        gap: 0.125rem;
    }
    .changelog-view .time {
        min-width: auto;
    }
}
