/* ============================================================
   FAMILYSEARCH MANAGER — Design System
   ============================================================ */
:root {
  --primary-deep:   #2563eb;
  --primary-light:  #60a5fa;
  --accent-gold:    #f59e0b;
  --accent-orange:  #fbbf24;
  --feedback-green: #10b981;
  --white:          #ffffff;
  --light-gray:     #f8fafc;
  --dark-text:      #1e293b;
  --soft-blue:      #eff6ff;
  --gradient-main:  linear-gradient(135deg, var(--primary-deep) 0%, var(--primary-light) 100%);
  --gradient-gold:  linear-gradient(135deg, var(--accent-gold) 0%, var(--accent-orange) 100%);
  --gradient-fresh: linear-gradient(135deg, #10b981 0%, #34d399 100%);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.1);
  --shadow-md: 0 10px 25px -5px rgba(37,99,235,.1), 0 8px 10px -6px rgba(37,99,235,.1);
  --shadow-lg: 0 20px 40px -10px rgba(37,99,235,.15);
  --radius-lg: 1.5rem;
  --radius-xl: 2.5rem;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body { font-family: 'Inter', sans-serif; background: var(--light-gray); color: var(--dark-text); overflow: hidden; height: 100vh; }
h1,h2,h3,.brand { font-family: 'Outfit', sans-serif; font-weight: 700; }

/* ── LOADING ── */
#loadingScreen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--gradient-main);
  display: flex; align-items: center; justify-content: center;
}
.loading-logo { text-align: center; color: white; }
.fs-logo {
  width: 88px; height: 88px; margin: 0 auto 1.25rem;
  background: rgba(255,255,255,.15); border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(255,255,255,.3);
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.fs-logo svg { width: 50px; height: 50px; }
.loading-logo h1 { font-size: 2rem; font-weight: 900; }
.loading-logo p  { opacity: .85; margin-top: .25rem; font-size: .9rem; }
.loading-spinner {
  width: 36px; height: 36px; margin: 1.5rem auto 0;
  border: 3px solid rgba(255,255,255,.25); border-top-color: white;
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── APP SHELL ── */
#app {
  display: none; flex-direction: column;
  height: 100vh; max-width: 480px; margin: 0 auto;
  background: white; position: relative;
  box-shadow: 0 0 80px rgba(0,0,0,.08);
}

/* ── HEADER ── */
.main-header {
  background: linear-gradient(180deg, var(--primary-deep) 0%, var(--primary-light) 100%);
  color: white; padding: 1.75rem 1.5rem 3.5rem;
  border-radius: 0 0 2.5rem 2.5rem; text-align: center;
  position: relative; overflow: hidden; flex-shrink: 0;
  box-shadow: 0 10px 30px rgba(37,99,235,.2);
}
.main-header::before {
  content:''; position:absolute; top:-50px; right:-50px;
  width:200px; height:200px;
  background: radial-gradient(circle, rgba(255,255,255,.4) 0%, transparent 70%);
  border-radius:50%; filter:blur(20px);
}
.main-header::after {
  content:''; position:absolute; bottom:-20px; left:-20px;
  width:150px; height:150px;
  background: radial-gradient(circle, rgba(255,255,255,.2) 0%, transparent 70%);
  border-radius:50%; filter:blur(15px);
}
.logo-container {
  display: flex; flex-direction: row;
  align-items: center; justify-content: center;
  gap: 16px; text-align: left; position: relative; z-index:1;
}
.logo-container h1 { font-size: 1.7rem; font-weight: 900; letter-spacing:.3px; line-height:1.1; text-shadow:0 2px 4px rgba(0,0,0,.1); }
.logo-container p  { font-size: .9rem; opacity: .88; font-weight: 500; }
.header-icon {
  width: 58px; height: 58px; flex-shrink: 0;
  background: rgba(255,255,255,.2); border-radius: 16px;
  border: 2px solid rgba(255,255,255,.35);
  display: flex; align-items: center; justify-content: center; font-size: 1.8rem;
}
.header-user-badge {
  position: absolute; top: 1rem; right: 1rem; z-index: 2;
  display: none; align-items: center; gap: .4rem;
}
.user-chip {
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3);
  color: white; padding: .3rem .75rem; border-radius: 20px;
  font-size: .75rem; font-weight: 600;
}
.btn-logout-header {
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.25);
  color: white; padding: .35rem .65rem; border-radius: 10px;
  cursor: pointer; font-size: .75rem; font-weight: 600;
  font-family: 'Inter',sans-serif; transition: background .2s;
}
.btn-logout-header:hover { background: rgba(255,255,255,.25); }

/* ── VIEW CONTAINER ── */
#view-container {
  flex: 1; overflow-y: auto; padding: 1.5rem;
  padding-bottom: 6rem; background: #fdfdfd; scrollbar-width: none;
}
#view-container::-webkit-scrollbar { display: none; }

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: absolute; bottom: 0; left: 0; right: 0; height: 80px;
  background: rgba(255,255,255,.95); backdrop-filter: blur(15px);
  display: none; justify-content: space-around; align-items: center;
  border-top: 1px solid rgba(0,0,0,.05); padding: 0 1rem 10px; z-index: 100;
}
.nav-item {
  background: none; border: none; display: flex; flex-direction: column;
  align-items: center; gap: 5px; color: #94a3b8; cursor: pointer;
  transition: all .3s cubic-bezier(.175,.885,.32,1.275); flex: 1;
}
.nav-item.active { color: var(--primary-deep); transform: translateY(-8px); }
.nav-icon { font-size: 22px; }
.nav-item label { font-size: .72rem; font-weight: 700; pointer-events: none; }

/* ── CARDS ── */
.card {
  background: white; border-radius: var(--radius-lg);
  padding: 1.5rem; margin-bottom: 1.25rem;
  box-shadow: var(--shadow-md); border: 1px solid rgba(0,0,0,.03);
  transition: all .3s ease; position: relative; overflow: hidden;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card h3 { font-size: 1rem; font-weight: 700; color: var(--dark-text); margin-bottom: .75rem; }

/* ── FORMS ── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block; font-size: .78rem; font-weight: 600;
  color: #64748b; margin-bottom: .4rem;
  text-transform: uppercase; letter-spacing: .4px;
}
.input-field {
  background: #f8fafc; border: 2px solid #e2e8f0; border-radius: 1rem;
  padding: .8rem 1rem; width: 100%; font-size: .95rem;
  font-family: 'Inter',sans-serif; color: var(--dark-text);
  transition: all .2s; outline: none;
}
.input-field:focus { background: white; border-color: var(--primary-light); box-shadow: 0 0 0 4px var(--soft-blue); }
select.input-field {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right .6rem center; background-repeat: no-repeat; background-size: 1.4em; padding-right: 2.5rem;
}
.input-group { display: flex; gap: .75rem; }
.input-group .form-group { flex: 1; margin-bottom: 0; }
.input-wrapper { position: relative; margin-bottom: 1rem; }
.input-wrapper svg {
  position: absolute; left: 1rem; top: 50%;
  transform: translateY(-50%); color: #94a3b8;
  width: 18px; height: 18px; pointer-events: none; transition: color .2s;
}
.input-wrapper:focus-within svg { color: var(--primary-light); }
.input-field.with-icon { padding-left: 3rem; }
.input-hint { font-size: .78rem; color: #94a3b8; margin-top: .25rem; display: block; }
.pw-wrapper { position: relative; }
.pw-wrapper .input-field { padding-right: 3rem; }
.toggle-pw {
  position: absolute; right: .9rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: #94a3b8; padding: 0;
}
.toggle-pw svg { width: 18px; height: 18px; }

/* ── CHECKBOX CARDS ── */
.checkbox-group { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: 1.25rem; }
.checkbox-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem .9rem; background: #f8fafc; border: 1.5px solid #e2e8f0;
  border-radius: 12px; cursor: pointer; transition: all .2s; user-select: none;
}
.checkbox-card:hover { border-color: var(--primary-light); }
.checkbox-card:has(input:checked) { background: var(--soft-blue); border-color: var(--primary-light); }
.checkbox-card span { font-size: .82rem; font-weight: 600; color: #475569; }
.checkbox-card:has(input:checked) span { color: var(--primary-deep); }
.checkbox-card input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--primary-deep); cursor: pointer; }

/* ── BUTTONS ── */
.btn-primary {
  background: var(--primary-deep); padding: .85rem 1.75rem; border: none;
  border-radius: var(--radius-lg); color: white;
  font-family: 'Inter',sans-serif; font-weight: 700; font-size: .95rem;
  cursor: pointer; box-shadow: 0 4px 12px rgba(37,99,235,.25);
  transition: transform .2s, box-shadow .2s;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(37,99,235,.3); }
.btn-primary:active { transform: scale(.97); }
.btn-primary.gradient { background: var(--gradient-main); }
.btn-primary.gold { background: var(--gradient-gold); box-shadow: 0 4px 15px rgba(245,158,11,.3); }
.btn-primary.gold:hover { filter: brightness(1.08); }
.btn-primary.full { width: 100%; }
.btn-sm {
  padding: .5rem 1rem; font-size: .85rem; font-weight: 600;
  border-radius: 10px; border: none; cursor: pointer;
  transition: all .2s; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  font-family: 'Inter',sans-serif;
}
.btn-sm:active { transform: scale(.95); }
.btn-sm.btn-primary { background: var(--primary-deep); color: white; }
.btn-sm.btn-secondary { background: var(--soft-blue); color: var(--primary-deep); }
.btn-sm.btn-danger { background: #fee2e2; color: #ef4444; }
.btn-icon {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; border: none;
  background: #f1f5f9; color: #475569; cursor: pointer;
  transition: all .2s;
}
.btn-icon:hover { background: var(--primary-light); color: white; transform: translateY(-2px); }
.btn-icon.delete:hover { background: #ef4444; color: white; }
.btn-icon svg { width: 16px; height: 16px; stroke-width: 2.5px; }
.btn-icon:active { transform: scale(.93); }

/* ── AUTH TABS ── */
.auth-tabs {
  display: flex; gap: .4rem; background: #f1f5f9;
  padding: .4rem; border-radius: 14px; margin-bottom: 1.75rem;
}
.btn-tab {
  flex: 1; padding: .6rem .4rem; border: none; background: transparent;
  border-radius: 10px; font-weight: 600; color: #64748b; cursor: pointer;
  transition: all .2s; font-size: .82rem; font-family: 'Inter',sans-serif;
}
.btn-tab.active { background: var(--primary-deep); color: white; font-weight: 700; box-shadow: 0 4px 12px rgba(37,99,235,.2); }
.btn-tab:hover:not(.active) { background: rgba(255,255,255,.5); }

/* ── ADMIN TABS ── */
.admin-tabs {
  display: flex; flex-wrap: wrap; gap: .4rem;
  background: #f1f5f9; padding: .4rem; border-radius: 14px; margin-bottom: 1.5rem;
}

/* ── ADMIN LIST ── */
.admin-list { display: flex; flex-direction: column; gap: .75rem; }
.admin-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.1rem 1.25rem; background: white; border-radius: var(--radius-lg);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,.05); border: 1px solid #f1f5f9;
  transition: transform .2s, box-shadow .2s;
}
.admin-item:hover { transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(0,0,0,.08); }
.admin-item-info { display: flex; flex-direction: column; gap: .28rem; flex: 1; min-width: 0; }
.admin-item-info strong { font-size: .98rem; color: var(--primary-deep); font-weight: 700; }
.admin-item-info small { color: #64748b; font-size: .8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-item-actions { display: flex; gap: .5rem; flex-shrink: 0; margin-left: .75rem; }

/* ── BADGES ── */
.badge { display: inline-block; padding: .18rem .55rem; border-radius: 20px; font-size: .7rem; font-weight: 700; }
.badge-blue  { background: var(--soft-blue); color: var(--primary-deep); }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red   { background: #fee2e2; color: #991b1b; }
.badge-gold  { background: #fef3c7; color: #92400e; }

/* ── MESSAGES ── */
.msg-box { margin-top: .75rem; padding: .75rem 1rem; border-radius: 12px; font-size: .88rem; font-weight: 500; display: none; }
.msg-box.success { background: #d1fae5; color: #065f46; border-left: 3px solid var(--feedback-green); }
.msg-box.error   { background: #fee2e2; color: #7f1d1d; border-left: 3px solid #ef4444; }
.msg-box.info    { background: var(--soft-blue); color: #1e3a8a; border-left: 3px solid var(--primary-light); }

/* ── MODAL (bottom sheet) ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15,23,42,.8); backdrop-filter: blur(5px);
  display: none; align-items: flex-end; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: white; border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  padding: 1.25rem 1.5rem 2.5rem; position: relative;
  animation: slideUp .3s cubic-bezier(.175,.885,.32,1.275);
}
.modal-handle { width: 40px; height: 4px; background: #e2e8f0; border-radius: 2px; margin: 0 auto 1.25rem; }
.modal-close {
  position: absolute; top: 1.25rem; right: 1.25rem;
  background: #f1f5f9; border: none; width: 30px; height: 30px;
  border-radius: 50%; cursor: pointer; font-size: .85rem; color: #64748b;
  display: flex; align-items: center; justify-content: center;
}
.modal-box h3 { font-size: 1.2rem; font-weight: 700; color: var(--dark-text); margin-bottom: .35rem; }
.modal-footer { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.5rem; }
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── SUCCESS OVERLAY ── */
.success-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.8); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; z-index: 2000;
  animation: fadeIn .3s ease;
}
.success-card {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid rgba(255,215,0,.3); padding: 2rem; border-radius: 20px;
  text-align: center; max-width: 90%; width: 340px;
  box-shadow: 0 0 30px rgba(255,215,0,.2);
  animation: popIn .4s cubic-bezier(.175,.885,.32,1.275) forwards;
}
.success-icon { font-size: 3.5rem; margin-bottom: .75rem; animation: bounce 1s infinite; }
.success-card h2 { color: #FFD700; font-family:'Outfit',sans-serif; margin-bottom: .4rem; }
.success-card p { color: #e2e8f0; font-size: 1rem; margin-bottom: 1.25rem; }

/* ── TOAST ── */
.toast-container { position: fixed; bottom: 88px; right: 1rem; z-index: 3000; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: white; padding: .85rem 1.25rem; border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,.12); border-left: 5px solid #333;
  display: flex; align-items: center; gap: 10px;
  min-width: 240px; font-weight: 500; font-size: .88rem;
  animation: slideInRight .3s cubic-bezier(.175,.885,.32,1.275);
}
.toast.success { border-left-color: var(--feedback-green); }
.toast.error   { border-left-color: #ef4444; }
.toast.info    { border-left-color: var(--primary-light); }

/* ── SKELETON ── */
.skeleton { background: linear-gradient(90deg, #f1f5f9 25%, #f8fafc 50%, #f1f5f9 75%); background-size: 200% 100%; animation: skeleton-loading 1.5s infinite; border-radius: 12px; }
.skeleton-item { height: 90px; width: 100%; margin-bottom: .75rem; }
@keyframes skeleton-loading { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── SEARCH ── */
.search-bar { position: relative; margin-bottom: 1.25rem; }
.search-bar svg { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: #94a3b8; width: 17px; height: 17px; }
.search-bar .input-field { padding-left: 2.9rem; }

/* ── PW REVEAL ── */
.pw-reveal { font-family: monospace; background: #f1f5f9; padding: .15rem .5rem; border-radius: 6px; font-size: .85rem; word-break: break-all; }

/* ── USER INFO BOX ── */
.user-info-box { background: var(--soft-blue); border-radius: 12px; padding: .85rem 1rem; margin-bottom: 1rem; border-left: 3px solid var(--primary-light); }
.user-info-box p { font-size: .88rem; color: #475569; margin-bottom: .2rem; }

/* ── BACKUP LOG ── */
.backup-log-item { display: flex; justify-content: space-between; align-items: center; padding: .7rem 1rem; border-bottom: 1px solid #f1f5f9; font-size: .83rem; }
.backup-log-item:last-child { border-bottom: none; }
.backup-log-item .bk-date { color: #64748b; font-size: .75rem; }
.status-ok  { color: var(--feedback-green); font-weight: 700; }
.status-err { color: #ef4444; font-weight: 700; }

/* ── ANIMATIONS ── */
.animate-in { animation: popIn .35s cubic-bezier(.175,.885,.32,1.275) forwards; }
@keyframes popIn { 0%{transform:scale(.9);opacity:0} 100%{transform:scale(1);opacity:1} }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
@keyframes slideInRight { from{transform:translateX(100%);opacity:0} to{transform:translateX(0);opacity:1} }

/* ── RESPONSIVE ── */
@media (max-width: 500px) {
  .input-group { flex-direction: column; }
  .checkbox-group { grid-template-columns: 1fr; }
  #app { max-width: 100%; box-shadow: none; }
}
