/* ============================================
   SOJO Singer Directory — Styles
   Navy / Gold / White — Clean & Professional
   ============================================ */

:root {
  --navy:        #1a3a5c;
  --navy-dark:   #0f2540;
  --navy-light:  #2a5a8c;
  --gold:        #c4952a;
  --gold-light:  #e8b84b;
  --gold-pale:   #fdf6e3;
  --white:       #ffffff;
  --cream:       #f8f6f0;
  --gray-light:  #f0f0f0;
  --gray:        #d0d0d0;
  --gray-mid:    #999999;
  --text-dark:   #1a1a2e;
  --text-mid:    #4a5568;
  --text-light:  #718096;

  /* Attendance colors */
  --att-present: #22863a;
  --att-present-bg: #dcffe4;
  --att-out:     #b45309;
  --att-out-bg:  #fef3c7;
  --att-unknown: #718096;
  --att-unknown-bg: #f0f0f0;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.10);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.12);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.16);
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --header-h:   60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--cream);
  color: var(--text-dark);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============ SCREENS ============ */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.screen.active { transform: translateX(0); }
.screen.slide-out { transform: translateX(-28%); }

/* ============ HEADER ============ */
.app-header {
  background: var(--navy);
  color: var(--white);
  height: var(--header-h);
  flex-shrink: 0;
  padding: 0 12px;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-md);
  z-index: 10;
}

.header-content {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.header-icon { font-size: 22px; flex-shrink: 0; }

.header-title h1 {
  font-size: 17px;
  font-weight: 700;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.last-updated {
  font-size: 10px;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
}

.header-back-label {
  font-size: 14px;
  color: rgba(255,255,255,0.8);
  flex: 1;
}

.header-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  background: rgba(255,255,255,0.12);
  border: none;
  color: var(--white);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.icon-btn:active { background: rgba(255,255,255,0.25); }

.save-btn {
  background: var(--gold);
  color: var(--white);
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s;
}

.save-btn:active { background: var(--gold-light); }

/* ============ SEARCH & FILTER ============ */
.search-filter-bar {
  background: var(--navy-dark);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

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

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

#search-input {
  width: 100%;
  background: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 32px 9px 32px;
  font-size: 14px;
  color: var(--text-dark);
}

#search-input:focus { outline: 2px solid var(--gold); }

.clear-btn {
  position: absolute;
  right: 8px;
  background: var(--gray);
  border: none;
  color: var(--text-mid);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 1px;
}

.clear-btn.hidden { display: none; }

.filter-row {
  display: flex;
  gap: 8px;
}

.select-wrapper {
  flex: 1;
  position: relative;
}

.select-wrapper select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-sm);
  padding: 7px 28px 7px 10px;
  font-size: 13px;
  color: var(--white);
  cursor: pointer;
}

.select-wrapper select:focus { outline: none; border-color: var(--gold); }
.select-wrapper select option { background: var(--navy); color: var(--white); }

/* ============ SINGER COUNT ============ */
.singer-count {
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-light);
  background: var(--cream);
  border-bottom: 1px solid var(--gray);
  flex-shrink: 0;
}

/* ============ SINGER LIST ============ */
.singer-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 10px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

.section-group { margin-bottom: 16px; }

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--navy);
  padding: 4px 6px;
  margin-bottom: 4px;
  border-bottom: 2px solid var(--gold);
}

.singer-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s, box-shadow 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.singer-card:active {
  transform: scale(0.98);
  box-shadow: none;
}

.singer-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.singer-avatar.soprano { background: #7c3aed; }
.singer-avatar.alto    { background: #059669; }
.singer-avatar.tenor   { background: #d97706; }
.singer-avatar.bass    { background: #1a3a5c; }

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

.singer-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.singer-sub {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 1px;
}

.singer-badges {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 100px;
  white-space: nowrap;
}

.badge-new    { background: #dbeafe; color: #1d4ed8; }
.badge-verify { background: #dcfce7; color: #15803d; }
.badge-iphone { background: #f3f4f6; color: #6b7280; }

/* ============ LOADING ============ */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(248,246,240,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 50;
  font-size: 14px;
  color: var(--text-mid);
}

.loading-overlay.hidden { display: none; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============ PROFILE ============ */
.profile-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(24px + var(--safe-bottom));
}

.profile-hero {
  background: var(--navy);
  padding: 20px 16px 24px;
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--white);
  flex-shrink: 0;
  border: 2px solid var(--gold);
}

.profile-name {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.profile-position {
  font-size: 13px;
  color: var(--gold-light);
  margin-top: 4px;
}

.profile-badges {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.profile-body { padding: 0 14px; }

.info-section { margin-top: 18px; }

.info-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--navy);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 4px;
  margin-bottom: 10px;
}

.info-row {
  display: flex;
  align-items: flex-start;
  padding: 7px 0;
  border-bottom: 1px solid var(--gray-light);
  gap: 10px;
}

.info-label {
  font-size: 12px;
  color: var(--text-light);
  width: 90px;
  flex-shrink: 0;
  padding-top: 1px;
}

.info-value {
  font-size: 14px;
  color: var(--text-dark);
  flex: 1;
  word-break: break-word;
}

.info-value a {
  color: var(--navy-light);
  text-decoration: none;
}

.info-value.empty { color: var(--text-light); font-style: italic; }

/* ============ ATTENDANCE GRID ============ */
.attendance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.att-cell {
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  text-align: center;
  font-size: 11px;
}

.att-cell .att-date {
  font-weight: 600;
  color: var(--text-mid);
  font-size: 10px;
  margin-bottom: 2px;
}

.att-cell .att-code {
  font-size: 14px;
  font-weight: 700;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.att-X  { background: var(--att-present-bg); }
.att-X .att-code { color: var(--att-present); }
.att-O  { background: var(--att-out-bg); }
.att-O .att-code { color: var(--att-out); }
.att-blank { background: var(--att-unknown-bg); }
.att-blank .att-code { color: var(--att-unknown); }

/* Attendance legend */
.att-legend {
  display: flex;
  gap: 14px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-mid);
}

.att-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-X     { background: var(--att-present-bg); border: 1.5px solid var(--att-present); }
.legend-O     { background: var(--att-out-bg);     border: 1.5px solid var(--att-out); }
.legend-blank { background: var(--att-unknown-bg); border: 1.5px solid var(--gray); }

/* ============ EDIT FORM ============ */
.edit-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  padding-bottom: calc(24px + var(--safe-bottom));
}

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

.form-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--navy);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 4px;
  margin-bottom: 12px;
}

.form-row {
  margin-bottom: 12px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 4px;
}

.form-input, .form-select {
  width: 100%;
  background: var(--white);
  border: 1.5px solid var(--gray);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-dark);
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--navy);
}

.form-select { appearance: none; -webkit-appearance: none; }

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

.form-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.form-checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--navy);
}

.form-checkbox-row label {
  font-size: 14px;
  color: var(--text-dark);
  cursor: pointer;
}

/* ============ ATTENDANCE SCREEN ============ */
.attendance-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  padding-bottom: calc(24px + var(--safe-bottom));
}

.att-date-picker {
  margin-bottom: 16px;
}

.att-date-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 6px;
}

.att-date-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--white);
  border: 1.5px solid var(--gray);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-dark);
  font-family: inherit;
}

.att-date-select:focus { outline: none; border-color: var(--navy); }

.att-section-group { margin-bottom: 20px; }

.att-section-header {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--navy);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 4px;
  margin-bottom: 8px;
}

.att-singer-row {
  display: flex;
  align-items: center;
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 4px;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.att-singer-name {
  flex: 1;
  font-size: 14px;
  color: var(--text-dark);
  font-weight: 500;
}

.att-buttons {
  display: flex;
  gap: 4px;
}

.att-btn {
  width: 36px;
  height: 32px;
  border: 1.5px solid var(--gray);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.att-btn.active-X {
  background: var(--att-present-bg);
  border-color: var(--att-present);
  color: var(--att-present);
}

.att-btn.active-O {
  background: var(--att-out-bg);
  border-color: var(--att-out);
  color: var(--att-out);
}

.att-btn.active-blank {
  background: var(--att-unknown-bg);
  border-color: var(--gray);
  color: var(--att-unknown);
}

/* ============ PIN MODAL ============ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}

.modal-box {
  position: relative;
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  width: 300px;
  max-width: 90vw;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.modal-box h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}

.modal-box p {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 20px;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--gray);
  transition: background 0.15s, border-color 0.15s;
}

.pin-dot.filled {
  background: var(--navy);
  border-color: var(--navy);
}

.pin-error {
  font-size: 12px;
  color: #dc2626;
  margin-bottom: 8px;
  height: 16px;
}

.pin-error.hidden { visibility: hidden; }

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.pin-key {
  background: var(--gray-light);
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.pin-key:active { background: var(--gray); }
.pin-cancel { background: #fee2e2; color: #dc2626; }
.pin-delete { background: var(--gray-light); font-size: 16px; }

/* ============ UPDATE BANNER ============ */
.update-banner {
  position: fixed;
  bottom: calc(12px + var(--safe-bottom));
  left: 12px;
  right: 12px;
  background: var(--navy-dark);
  color: var(--white);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  animation: slideUp 0.3s ease;
}

.update-banner.hidden { display: none; }
.update-banner span { flex: 1; font-size: 13px; font-weight: 600; }

#btn-update {
  background: var(--gold);
  color: var(--white);
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.dismiss-update {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  cursor: pointer;
}

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

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.empty-state svg { margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray); border-radius: 2px; }

/* ============ BOTTOM SHEET ============ */
.bottom-sheet {
  position: fixed;
  inset: 0;
  z-index: 150;
}

.bottom-sheet.hidden { display: none; }

.bottom-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
}

.bottom-sheet-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-radius: 18px 18px 0 0;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideUpSheet 0.3s ease;
  padding-bottom: var(--safe-bottom);
}

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

.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--gray);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

.bottom-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--gray-light);
  flex-shrink: 0;
}

.bottom-sheet-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
}

.close-btn {
  background: var(--gray-light);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-mid);
  line-height: 1;
  padding-bottom: 1px;
}

.share-content {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px 16px;
}

.share-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--navy);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 4px;
  margin: 14px 0 8px;
}

.share-section-title:first-child { margin-top: 0; }

.share-group {
  background: var(--gray-light);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.share-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.share-group-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
}

.share-group-count {
  font-size: 11px;
  color: var(--text-light);
  background: var(--white);
  padding: 2px 8px;
  border-radius: 100px;
}

.share-numbers {
  font-size: 12px;
  color: var(--text-mid);
  line-height: 1.6;
  margin-bottom: 8px;
  word-break: break-all;
}

.share-btn {
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s;
  margin-right: 6px;
  margin-top: 4px;
}

.share-btn:active { background: var(--navy-light); }

.share-btn.gold {
  background: var(--gold);
}

.share-btn.gold:active { background: var(--gold-light); }

.share-email-list {
  font-size: 12px;
  color: var(--text-mid);
  line-height: 1.6;
  margin-bottom: 8px;
  word-break: break-all;
}

.share-summary {
  font-size: 13px;
  color: var(--text-mid);
  margin-bottom: 12px;
}

.share-summary strong { color: var(--navy); }
