/* =========================================================
   Pitru Paksha Yajna 2026 — Spreadsheet View
   One Single Row per Devotee (Google Sheet Style)
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;450;500;550;600;650;700&display=swap');

:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Spreadsheet Palette */
  --bg-app: #F8F9FA;
  --bg-table: #FFFFFF;
  --bg-row-alt: #FDFDFD;
  --bg-row-hover: #F1F3F5;
  --border-cell: #E5E7EB;
  --border-dark: #D1D5DB;

  --text-primary: #111827;
  --text-secondary: #4B5563;
  --text-muted: #6B7280;
  --text-dim: #9CA3AF;

  --accent-dark: #18181B;

  /* Action States */
  --green-active: #16A34A;
  --green-hover: #15803D;
  --green-soft: #DCFCE7;
  --green-text: #166534;

  --gift-active: #18181B;
  --gift-soft: #F4F4F5;
  --gift-border: #D4D4D8;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-pill: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
  --bg-app: #09090B;
  --bg-table: #121215;
  --bg-row-alt: #16161A;
  --bg-row-hover: #1E1E24;
  --border-cell: #27272A;
  --border-dark: #3F3F46;

  --text-primary: #FAFAFA;
  --text-secondary: #D4D4D8;
  --text-muted: #A1A1AA;
  --text-dim: #71717A;

  --accent-dark: #FAFAFA;

  --green-soft: #052E16;
  --green-text: #4ADE80;

  --gift-active: #FAFAFA;
  --gift-soft: #27272A;
  --gift-border: #3F3F46;
}

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

body {
  font-family: var(--font);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.4;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

.sheet-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
}

/* =========================================================
   Compact Top Toolbar
   ========================================================= */
.sheet-toolbar {
  background: var(--bg-table);
  border-bottom: 1px solid var(--border-cell);
  padding: 8px 12px;
  flex-shrink: 0;
  z-index: 30;
}

.toolbar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.search-box {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-dim);
  pointer-events: none;
}

.search-input {
  width: 100%;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 450;
  padding: 7px 30px 7px 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-cell);
  background: var(--bg-app);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease;
}

.search-input:focus {
  border-color: var(--border-dark);
  background: var(--bg-table);
}

.search-clear-btn {
  position: absolute;
  right: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--border-cell);
  color: var(--text-secondary);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
}

.search-clear-btn.visible {
  display: flex;
}

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

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-cell);
  background: var(--bg-table);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.icon-btn.syncing svg {
  animation: spin 1s linear infinite;
}

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

/* Filter Strip */
.filter-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  margin-top: 6px;
  padding-bottom: 2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.filter-strip::-webkit-scrollbar {
  display: none;
}

.pill {
  flex-shrink: 0;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pill:hover {
  background: var(--bg-row-hover);
  color: var(--text-primary);
}

.pill.active {
  background: var(--bg-app);
  color: var(--text-primary);
  border-color: var(--border-cell);
  font-weight: 600;
}

.pill span {
  font-size: 0.68rem;
  font-feature-settings: 'tnum';
  opacity: 0.85;
}

/* =========================================================
   Spreadsheet Main Table View (One Single Row)
   ========================================================= */
.sheet-main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-table);
}

.table-scroll-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.72rem;
  table-layout: fixed;
  white-space: nowrap;
}

/* Sticky Header */
.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-app);
  color: var(--text-muted);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 6px 3px;
  border-bottom: 1px solid var(--border-dark);
  border-right: 1px solid var(--border-cell);
  z-index: 10;
  user-select: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table thead th:last-child {
  border-right: none;
}

/* Table Body Rows (Single Row per devotee) */
.data-table tbody tr {
  border-bottom: 1px solid var(--border-cell);
  transition: background-color 0.1s ease;
  height: 36px;
}

.data-table tbody tr:nth-child(even) {
  background-color: var(--bg-row-alt);
}

.data-table tbody tr:hover {
  background-color: var(--bg-row-hover);
}

.data-table td {
  padding: 4px 3px;
  border-right: 1px solid var(--border-cell);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table td:last-child {
  border-right: none;
}

/* Column 1: Actions (Now expanded with comfortable tap targets) */
.col-act, td.cell-actions {
  width: 70px;
  max-width: 70px;
  text-align: center;
  padding: 3px 4px !important;
}

.action-pair {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

/* Action Icon Buttons */
.act-btn {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-cell);
  background: var(--bg-table);
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s ease;
  user-select: none;
  padding: 0;
  flex-shrink: 0;
}

.act-btn svg {
  width: 13px;
  height: 13px;
}

.act-btn:hover {
  border-color: var(--border-dark);
  color: var(--text-primary);
}

.act-btn:active {
  transform: scale(0.90);
}

/* State: Present Active */
.act-btn.present-active {
  background: var(--green-active);
  border-color: var(--green-active);
  color: #FFFFFF;
}

.act-btn.present-active:hover {
  background: var(--green-hover);
}

/* State: Gift Active */
.act-btn.gift-active {
  background: var(--gift-active);
  border-color: var(--gift-active);
  color: #FFFFFF;
}

[data-theme="dark"] .act-btn.gift-active {
  color: #18181B;
}

/* Column 2: Name */
.col-name, td.cell-name {
  width: 35%;
  font-weight: 600;
  font-size: 0.76rem;
  color: var(--text-primary);
  cursor: pointer;
}

.cell-name:hover {
  text-decoration: underline;
}

/* Column 3: Phone */
.col-phone, td.cell-phone {
  width: 28%;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: -0.01em;
}

.phone-link {
  color: var(--text-secondary);
  text-decoration: none;
}

.phone-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

/* Column 4: Email */
.col-email, td.cell-email {
  width: 37%;
  color: var(--text-muted);
  font-size: 0.70rem;
  letter-spacing: -0.01em;
}

/* Status Highlight */
tr.row-present td.cell-name {
  color: var(--green-text);
}

/* =========================================================
   Bottom Status Footer
   ========================================================= */
.status-footer {
  height: 28px;
  background: var(--bg-app);
  border-top: 1px solid var(--border-cell);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
  font-feature-settings: 'tnum';
}

/* =========================================================
   Toast with Instant Undo
   ========================================================= */
.toast-shelf {
  position: fixed;
  bottom: 38px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 90%;
  max-width: 360px;
  pointer-events: none;
}

.toast-item {
  background: #18181B;
  color: #FAFAFA;
  border: 1px solid #27272A;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: auto;
  animation: fadeIn 0.12s ease;
}

[data-theme="dark"] .toast-item {
  background: #27272A;
  color: #FAFAFA;
}

.toast-undo-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #FAFAFA;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  cursor: pointer;
}

.toast-undo-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Empty Cell */
.empty-cell {
  text-align: center;
  padding: 40px !important;
  color: var(--text-muted);
}

/* =========================================================
   Detail Drawer
   ========================================================= */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.drawer-backdrop.is-open {
  display: flex;
}

.drawer-panel {
  background: var(--bg-table);
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  box-shadow: var(--shadow-modal);
  overflow-y: auto;
  padding: 16px 16px 28px 16px;
  animation: slideUp 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.drawer-handle {
  width: 32px;
  height: 4px;
  background: var(--border-dark);
  border-radius: var(--radius-pill);
  margin: 0 auto 12px auto;
}

.drawer-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.drawer-title {
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--text-primary);
}

.drawer-close {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-xs);
  background: var(--bg-app);
  border: 1px solid var(--border-cell);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
}

.drawer-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
}

.drawer-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  background: var(--bg-app);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-cell);
}

.drawer-cell-key {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.drawer-cell-val {
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-word;
}

.drawer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.drawer-btn {
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-cell);
  background: var(--bg-table);
  color: var(--text-primary);
  cursor: pointer;
  text-align: center;
}

.drawer-btn.act-present {
  background: var(--green-soft);
  color: var(--green-text);
  border-color: var(--green-active);
}

.drawer-btn.act-gift {
  background: var(--gift-soft);
  color: var(--text-primary);
  border-color: var(--gift-active);
}
