/* =========================================================
   Abhinav & Kaviya — Wedding Invitation Checklist
   Palette:
     #E9EDF0 (RGB 233, 237, 240) - Pale Mist Slate
     #2E3A46 (RGB 46, 58, 70)   - Deep Slate Navy
     #5B6B7A (RGB 91, 107, 122) - Muted Steel Slate
   Font: Inter & Outfit (Maximum Readability)
   ========================================================= */

:root {
  /* Exact User Palette */
  --c-light: #E9EDF0;        /* RGB 233, 237, 240 */
  --c-dark: #2E3A46;         /* RGB 46, 58, 70 */
  --c-muted: #5B6B7A;        /* RGB 91, 107, 122 */

  /* UI Theme Variables */
  --bg-page: #F2F5F8;
  --bg-card: #FFFFFF;
  --bg-subtle: #E9EDF0;

  --border-light: #DCE3E8;
  --border-hover: #B8C5CE;
  --border-focus: #5B6B7A;

  --text-main: #2E3A46;
  --text-secondary: #5B6B7A;
  --text-subtle: #8495A5;

  /* Status Colors */
  --status-pending: #2E3A46;
  --status-invited: #2E7D5B;
  --status-invited-light: #EAF4EE;
  --status-invited-border: #C1E1D1;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(46, 58, 70, 0.05);
  --shadow-md: 0 4px 14px rgba(46, 58, 70, 0.08);
  --shadow-float: 0 8px 24px rgba(46, 58, 70, 0.28);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', 'Inter', -apple-system, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(85px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}

.app-container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 12px 14px;
}

@media (min-width: 600px) {
  .app-container {
    padding: 24px 18px;
  }
}

/* =========================================================
   1. Compact Clean Header
   ========================================================= */

.app-header-compact {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}

.header-main-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.header-titles {
  display: flex;
  flex-direction: column;
}

.couple-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--c-dark);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.ring-emoji {
  font-size: 1.25rem;
}

.header-progress-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 3px;
  font-weight: 500;
}

.header-progress-text span {
  font-weight: 700;
}

#statPendingText {
  color: var(--c-dark);
}

#statInvitedText {
  color: var(--status-invited);
}

#statPercentText {
  color: var(--text-secondary);
}

/* Menu Dropdown Icon */
.btn-menu-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-menu-icon:hover {
  background-color: var(--c-light);
  color: var(--c-dark);
}

/* Sleek Progress Line */
.progress-bar-bg {
  width: 100%;
  height: 6px;
  background-color: var(--c-light);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c-muted), var(--status-invited));
  border-radius: var(--radius-full);
  transition: width 0.35s ease;
}

/* Dropdown Menu */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(46, 58, 70, 0.15);
  min-width: 220px;
  padding: 6px;
  z-index: 60;
  display: none;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--c-dark);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background-color 0.12s ease;
}

.dropdown-item:hover {
  background-color: var(--c-light);
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border-light);
  margin: 4px 0;
}

.dropdown-item.text-danger {
  color: #c53030;
}

.dropdown-item.text-danger:hover {
  background-color: #fee2e2;
}

/* =========================================================
   2. The 2 Main Tabs: To Invite vs Invited
   ========================================================= */

.primary-tabs-wrapper {
  margin-bottom: 12px;
}

.primary-tabs {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  padding: 4px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  gap: 6px;
}

.tab-button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 12px;
  border: none;
  background: transparent;
  color: var(--c-muted);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.18s ease;
}

.tab-button:active {
  transform: scale(0.98);
}

.tab-icon {
  font-size: 1rem;
}

.tab-count {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--c-light);
  color: var(--c-dark);
}

/* Active tab: To Invite (Deep Slate Navy #2E3A46) */
.tab-button.active[data-status="pending"] {
  background: var(--c-dark);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(46, 58, 70, 0.25);
}

.tab-button.active[data-status="pending"] .tab-count {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

/* Active tab: Invited (Sage Green #2E7D5B) */
.tab-button.active[data-status="invited"] {
  background: var(--status-invited);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(46, 125, 91, 0.25);
}

.tab-button.active[data-status="invited"] .tab-count {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

/* =========================================================
   3. Single Compact Filter & Search Row
   ========================================================= */

.filter-row {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 11px;
  color: var(--text-subtle);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 10px 28px 10px 34px;
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  font-size: 16px; /* Prevents auto-zoom on mobile */
  font-family: var(--font-sans);
  color: var(--c-dark);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(91, 107, 122, 0.15);
}

.clear-btn {
  position: absolute;
  right: 8px;
  border: none;
  background: var(--c-light);
  color: var(--c-muted);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.filter-select {
  padding: 10px 24px 10px 10px;
  border: 1px solid var(--border-light);
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  font-size: 0.83rem;
  font-weight: 600;
  font-family: var(--font-sans);
  color: var(--c-dark);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235B6B7A' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  box-shadow: var(--shadow-sm);
  max-width: 130px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-select:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* =========================================================
   4. Category Headers & Guest Cards
   ========================================================= */

.category-group {
  margin-bottom: 16px;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.category-header:hover {
  background-color: #f7fafc;
  border-color: var(--border-hover);
}

.category-header:active {
  transform: scale(0.99);
}

.category-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-toggle-icon {
  transition: transform 0.2s ease;
  color: var(--c-muted);
}

.category-group.collapsed .category-toggle-icon {
  transform: rotate(-90deg);
}

.category-title {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--c-dark);
}

.category-badge-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background-color: var(--c-light);
  color: var(--c-muted);
}

.category-progress-mini {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--c-muted);
}

.guest-card-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.category-group.collapsed .guest-card-list {
  display: none;
}

/* Guest Cards */
.guest-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
  transition: all 0.18s ease;
  min-height: 54px;
}

.guest-card:hover {
  border-color: var(--border-hover);
}

/* Circular Checkbox Trigger */
.check-trigger {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  border: 2px solid #C5D0D8;
  background-color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: transparent;
  padding: 0;
}

.check-trigger:active {
  transform: scale(0.85);
}

.check-trigger:hover {
  border-color: var(--status-invited);
  background-color: var(--status-invited-light);
}

.check-trigger svg {
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  transition: stroke-dashoffset 0.2s ease;
}

/* Invited Card State */
.guest-card.is-invited {
  background-color: #fafdfc;
  border-color: var(--status-invited-border);
}

.guest-card.is-invited .check-trigger {
  background-color: var(--status-invited);
  border-color: var(--status-invited);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(46, 125, 91, 0.25);
}

.guest-card.is-invited .check-trigger svg {
  stroke-dashoffset: 0;
}

.guest-info {
  flex: 1;
  min-width: 0;
}

.guest-main-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.guest-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--c-dark);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.guest-tags {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 3px;
}

/* Harmonious Badges using #E9EDF0 and slate tones */
.tag-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.tag-reception {
  background-color: var(--c-light);
  color: var(--c-dark);
  border: 1px solid #D2DBE2;
}

.tag-wedding {
  background-color: #e2e8ee;
  color: #1f2a36;
  border: 1px solid #c9d5df;
}

.tag-both {
  background-color: #edf2f7;
  color: #2b3b4a;
  border: 1px solid #d7e0ea;
}

.tag-mom {
  background-color: #f0f4f8;
  color: var(--c-muted);
  border: 1px solid #dce4ec;
}

.tag-dad {
  background-color: #eaf1f7;
  color: #2c4c66;
  border: 1px solid #d0e0ed;
}

.tag-neighbours {
  background-color: var(--status-invited-light);
  color: var(--status-invited);
  border: 1px solid var(--status-invited-border);
}

.tag-friends {
  background-color: #f1ecf9;
  color: #5c3b8c;
  border: 1px solid #ded5ee;
}

.tag-default {
  background-color: var(--c-light);
  color: var(--c-muted);
  border: 1px solid var(--border-light);
}

.guest-note-text {
  font-size: 0.76rem;
  color: var(--text-subtle);
  margin-top: 2px;
}

.invited-timestamp {
  font-size: 0.74rem;
  color: var(--status-invited);
  font-weight: 700;
  margin-top: 2px;
}

/* Guest Actions Right */
.guest-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.btn-icon-subtle {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-icon-subtle:hover {
  background-color: var(--c-light);
  color: var(--c-dark);
}

.btn-icon-subtle.delete:hover {
  background-color: #fee2e2;
  color: #dc2626;
}

.btn-undo {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--status-invited-light);
  color: var(--status-invited);
  border: 1px solid var(--status-invited-border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.74rem;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
}

.btn-undo:active {
  transform: scale(0.95);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 44px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-light);
  margin-top: 8px;
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.empty-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--c-dark);
  margin-bottom: 3px;
}

.empty-desc {
  font-size: 0.84rem;
  color: var(--c-muted);
  margin-bottom: 14px;
}

.btn-clean-primary {
  background: var(--c-dark);
  color: #ffffff;
  border: none;
  padding: 9px 18px;
  font-size: 0.86rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-sans);
}

/* =========================================================
   5. Single Floating Action Button (+)
   ========================================================= */

.single-fab {
  position: fixed;
  right: 18px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--c-dark);
  color: #ffffff;
  border: none;
  box-shadow: var(--shadow-float);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 70;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.15s ease;
}

.single-fab:hover {
  background-color: #212c36;
}

.single-fab:active {
  transform: scale(0.9);
}

@media (min-width: 680px) {
  .single-fab {
    right: max(20px, calc(50vw - 320px));
  }
}

/* =========================================================
   6. Unified Add Modal (Single & Paste)
   ========================================================= */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(46, 58, 70, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end; /* Mobile bottom sheet */
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

@media (min-width: 600px) {
  .modal-backdrop {
    align-items: center;
    padding: 16px;
  }
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 16px 18px 24px 18px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 10px 30px rgba(46, 58, 70, 0.2);
}

@media (min-width: 600px) {
  .modal-dialog {
    border-radius: var(--radius-lg);
    max-width: 480px;
    transform: translateY(20px) scale(0.98);
  }
}

.modal-backdrop.open .modal-dialog {
  transform: translateY(0);
}

@media (min-width: 600px) {
  .modal-backdrop.open .modal-dialog {
    transform: translateY(0) scale(1);
  }
}

.mobile-drag-indicator {
  width: 32px;
  height: 4px;
  background-color: var(--border-light);
  border-radius: 99px;
  margin: 0 auto 12px auto;
}

@media (min-width: 600px) {
  .mobile-drag-indicator {
    display: none;
  }
}

.modal-mode-switch {
  display: flex;
  background: var(--c-light);
  padding: 3px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  gap: 4px;
}

.mode-tab {
  flex: 1;
  padding: 9px 8px;
  border: none;
  background: transparent;
  color: var(--c-muted);
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-tab.active {
  background: #ffffff;
  color: var(--c-dark);
  box-shadow: 0 2px 6px rgba(46, 58, 70, 0.08);
}

.form-group {
  margin-bottom: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--c-dark);
  margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 16px; /* Prevents iOS auto-zoom */
  font-family: var(--font-sans);
  color: var(--c-dark);
  background: #ffffff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}

.form-group textarea {
  resize: vertical;
  line-height: 1.4;
  font-family: monospace;
}

.bulk-count-preview {
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--c-muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.btn-cancel {
  background: var(--c-light);
  border: none;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--c-muted);
  cursor: pointer;
  font-family: var(--font-sans);
}

.btn-save {
  background: var(--c-dark);
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  font-weight: 700;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(46, 58, 70, 0.25);
  font-family: var(--font-sans);
}

/* =========================================================
   Toast Notification
   ========================================================= */

.toast-container {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 200;
  pointer-events: none;
  width: 90%;
  max-width: 360px;
}

.toast {
  background: rgba(46, 58, 70, 0.96);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: var(--radius-full);
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(46, 58, 70, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: auto;
}

.toast.toast-success {
  background-color: rgba(46, 125, 91, 0.96);
}

/* Print Styles */
@media print {
  body {
    background: #ffffff;
    padding: 0;
  }
  .app-header-compact .header-right,
  .primary-tabs-wrapper,
  .filter-row,
  .single-fab,
  .modal-backdrop,
  .btn-icon-subtle,
  .btn-undo {
    display: none !important;
  }
  .app-container {
    max-width: 100%;
    padding: 0;
  }
  .guest-card {
    border: 1px solid #ccc;
    box-shadow: none;
    page-break-inside: avoid;
    margin-bottom: 4px;
  }
}
