/* ============================================
   Punjab Roots Realty — Sheets Module CSS
   ============================================ */

/* ---- Sheet Tab Bar ---- */
.sheets-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--clr-bg-tertiary);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 10px 16px 0;
  border-bottom: 2px solid var(--clr-bg-tertiary);
  overflow-x: auto;
  scrollbar-width: none;
}
.sheets-bar::-webkit-scrollbar { display: none; }

.sheet-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--clr-text-secondary);
  cursor: pointer;
  background: transparent;
  border: none;
  white-space: nowrap;
  transition: all var(--transition-fast);
  position: relative;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.sheet-tab:hover {
  background: var(--clr-bg-card-hover);
  color: var(--clr-text-primary);
}
.sheet-tab.active {
  background: var(--clr-bg-card);
  color: var(--clr-primary);
  font-weight: var(--fw-semibold);
  border-bottom: 3px solid var(--clr-primary);
  box-shadow: var(--shadow-sm);
}
.sheet-tab .tab-icon {
  font-size: 16px;
}

/* ---- Sheet Content Wrapper ---- */
.sheets-content {
  background: var(--clr-bg-card);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* ---- Sheet Toolbar ---- */
.sheet-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--clr-bg-secondary);
  border-bottom: 1px solid var(--glass-border);
  flex-wrap: wrap;
}
.sheet-toolbar .toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 8px;
  border-right: 1px solid var(--glass-border);
}
.sheet-toolbar .toolbar-group:last-child {
  border-right: none;
}
.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--clr-bg-card);
  color: var(--clr-text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.toolbar-btn:hover {
  background: var(--clr-primary);
  color: #fff;
  border-color: var(--clr-primary);
}
.toolbar-btn .material-icons-round { font-size: 16px; }

.toolbar-btn.danger:hover {
  background: var(--clr-danger);
  border-color: var(--clr-danger);
}
.toolbar-btn.success:hover {
  background: var(--clr-success);
  border-color: var(--clr-success);
}

.sheet-search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--clr-bg-input);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  margin-left: auto;
}
.sheet-search input {
  border: none;
  background: transparent;
  font-size: var(--text-sm);
  color: var(--clr-text-primary);
  outline: none;
  width: 180px;
}
.sheet-search .material-icons-round { font-size: 16px; color: var(--clr-text-muted); }

/* ---- Spreadsheet Grid ---- */
.sheet-grid-wrapper {
  overflow: auto;
  max-height: calc(100vh - 320px);
  min-height: 400px;
  position: relative;
}

.sheet-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  font-family: var(--font-body);
}

/* Column header row */
.sheet-grid thead tr th {
  background: var(--clr-bg-tertiary);
  color: var(--clr-text-secondary);
  font-weight: var(--fw-semibold);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 8px 12px;
  border: 1px solid var(--glass-border);
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.sheet-grid thead tr th:first-child {
  width: 40px;
  text-align: center;
  cursor: default;
  background: var(--clr-bg-secondary);
  z-index: 11;
  left: 0;
}
.sheet-grid thead tr th:hover:not(:first-child) {
  background: var(--clr-primary-glow);
  color: var(--clr-primary);
}
.sheet-grid thead tr th .sort-icon {
  font-size: 12px;
  vertical-align: middle;
  opacity: 0.4;
  transition: opacity var(--transition-fast);
}
.sheet-grid thead tr th:hover .sort-icon { opacity: 1; }
.sheet-grid thead tr th.sorted { background: rgba(46,125,50,0.08); color: var(--clr-primary); }
.sheet-grid thead tr th.sorted .sort-icon { opacity: 1; color: var(--clr-primary); }

/* Body rows */
.sheet-grid tbody tr {
  transition: background var(--transition-fast);
}
.sheet-grid tbody tr:hover td {
  background: rgba(46,125,50,0.04);
}
.sheet-grid tbody tr.selected-row td {
  background: rgba(46,125,50,0.08) !important;
}
.sheet-grid tbody tr.new-row td {
  animation: rowSlideIn 0.3s ease;
}
@keyframes rowSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sheet-grid td {
  border: 1px solid var(--glass-border);
  padding: 0;
  position: relative;
  vertical-align: middle;
}
.sheet-grid td:first-child {
  background: var(--clr-bg-tertiary);
  color: var(--clr-text-muted);
  font-size: 11px;
  text-align: center;
  width: 40px;
  font-weight: var(--fw-medium);
  position: sticky;
  left: 0;
  z-index: 5;
  padding: 6px;
  user-select: none;
  cursor: pointer;
}
.sheet-grid td:first-child:hover { background: var(--clr-primary-glow); color: var(--clr-primary); }

/* Editable cell */
.cell-input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  padding: 8px 10px;
  font-size: var(--text-sm);
  font-family: var(--font-body);
  color: var(--clr-text-primary);
  outline: none;
  min-width: 90px;
  box-sizing: border-box;
}
.cell-input:focus {
  background: rgba(46,125,50,0.06);
  box-shadow: inset 0 0 0 2px var(--clr-primary);
  border-radius: 2px;
}
.cell-input.number { text-align: right; font-variant-numeric: tabular-nums; }
.cell-input.currency { text-align: right; color: var(--clr-primary-dark); font-weight: var(--fw-semibold); }
.cell-input.computed { background: rgba(46,125,50,0.04); color: var(--clr-success); font-weight: var(--fw-semibold); pointer-events: none; }

/* select cell */
.cell-select {
  width: 100%;
  border: none;
  background: transparent;
  padding: 8px 10px;
  font-size: var(--text-sm);
  font-family: var(--font-body);
  color: var(--clr-text-primary);
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
}
.cell-select:focus {
  background: rgba(46,125,50,0.06);
  box-shadow: inset 0 0 0 2px var(--clr-primary);
}

/* Status badges inside cells */
.cell-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}
.cell-badge.paid     { background: var(--clr-success-bg); color: var(--clr-success); }
.cell-badge.pending  { background: var(--clr-warning-bg); color: var(--clr-warning); }
.cell-badge.overdue  { background: var(--clr-danger-bg);  color: var(--clr-danger); }
.cell-badge.done     { background: var(--clr-info-bg);    color: var(--clr-info); }
.cell-badge.active   { background: var(--clr-success-bg); color: var(--clr-success); }

/* Row action button */
.row-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  color: var(--clr-text-muted);
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
}
.row-action-btn:hover { color: var(--clr-danger); background: var(--clr-danger-bg); }
.row-action-btn .material-icons-round { font-size: 16px; }

/* ---- Summary Bar (Footer) ---- */
.sheet-summary {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 16px;
  background: var(--clr-bg-secondary);
  border-top: 1px solid var(--glass-border);
  font-size: var(--text-xs);
  color: var(--clr-text-muted);
  flex-wrap: wrap;
}
.sheet-summary .sum-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sheet-summary .sum-label { color: var(--clr-text-muted); }
.sheet-summary .sum-value {
  font-weight: var(--fw-semibold);
  color: var(--clr-text-primary);
  font-variant-numeric: tabular-nums;
}
.sheet-summary .sum-value.green { color: var(--clr-success); }
.sheet-summary .sum-value.red   { color: var(--clr-danger); }
.sheet-summary .sum-value.gold  { color: var(--clr-gold); }
.sheet-count {
  margin-left: auto;
  color: var(--clr-text-muted);
  font-size: var(--text-xs);
}

/* ---- Empty State ---- */
.sheet-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--clr-text-muted);
}
.sheet-empty .material-icons-round { font-size: 48px; margin-bottom: 12px; color: var(--clr-text-muted); }
.sheet-empty p { font-size: var(--text-sm); margin-bottom: 16px; }

/* ---- Import/Export area ---- */
.sheet-drop-zone {
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  color: var(--clr-text-muted);
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
  cursor: pointer;
  margin: 12px 16px;
}
.sheet-drop-zone:hover, .sheet-drop-zone.dragover {
  border-color: var(--clr-primary);
  background: var(--clr-primary-glow);
  color: var(--clr-primary);
}
