/* ============================================================
   SortMe — Pages CSS: Per-screen layout styles
   ============================================================ */

/* ── Welcome / Splash ─────────────────────────────────────── */
.welcome-page {
  background: var(--clr-white);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) var(--space-6);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.welcome-page::before {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59,91,219,0.08) 0%, transparent 70%);
  top: -100px; right: -100px;
}

.welcome-page::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(76,110,245,0.06) 0%, transparent 70%);
  bottom: -60px; left: -80px;
}

.app-logo {
  width: 80px; height: 80px;
  background: var(--gradient-primary);
  border-radius: var(--radius-xl);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto var(--space-8);
  box-shadow: var(--shadow-xl);
  font-size: var(--fs-2xl);
  font-weight: var(--fw-black);
  color: white;
  letter-spacing: -1px;
  position: relative;
  z-index: 1;
}

.welcome-title {
  font-size: 2rem;
  font-weight: var(--fw-black);
  color: var(--clr-text);
  margin-bottom: var(--space-3);
  line-height: 1.2;
}

.welcome-sub {
  color: var(--clr-muted);
  font-size: var(--fs-md);
  margin-bottom: var(--space-10);
  max-width: 280px;
}

.welcome-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  max-width: 320px;
  position: relative; z-index: 1;
}

.welcome-footer {
  position: absolute;
  bottom: var(--space-6);
  font-size: var(--fs-xs);
  color: var(--clr-muted);
}

/* ── Auth Pages (Login / Signup) ─────────────────────────── */
.auth-page {
  background: var(--clr-white);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.auth-header {
  padding: var(--space-10) var(--space-6) var(--space-6);
  background: linear-gradient(180deg, var(--clr-bg) 0%, var(--clr-white) 100%);
}

.auth-header .app-logo-sm {
  width: 48px; height: 48px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-lg);
  font-weight: var(--fw-black);
  color: white;
  margin-bottom: var(--space-5);
}

.auth-body {
  flex: 1;
  padding: 0 var(--space-6) var(--space-10);
  overflow-y: auto;
}

.auth-footer {
  text-align: center;
  padding: var(--space-4) var(--space-6) var(--space-8);
  font-size: var(--fs-sm);
  color: var(--clr-muted);
}

.auth-footer a, .auth-footer button {
  color: var(--clr-primary);
  font-weight: var(--fw-semi);
}

/* ── OTP Page ─────────────────────────────────────────────── */
.otp-page {
  min-height: 100vh;
  background: var(--clr-white);
  display: flex;
  flex-direction: column;
  padding: var(--space-10) var(--space-6);
}

.otp-icon {
  width: 72px; height: 72px;
  background: rgba(59,91,219,0.08);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--clr-primary);
  margin-bottom: var(--space-6);
}

.resend-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--clr-muted);
  margin-top: var(--space-4);
}

.resend-btn {
  color: var(--clr-primary);
  font-weight: var(--fw-semi);
  cursor: pointer;
  background: none;
  border: none;
  font-size: var(--fs-sm);
}
.resend-btn:disabled { color: var(--clr-muted); cursor: not-allowed; }

/* ── Dashboard ────────────────────────────────────────────── */
.dashboard-page {
  min-height: 100vh;
  background: var(--clr-bg);
  padding-bottom: calc(var(--nav-h) + var(--space-4));
}

.dashboard-top {
  background: var(--clr-primary);
  padding: calc(var(--space-6) + env(safe-area-inset-top, 20px)) var(--space-5) calc(var(--space-10) * 1.5);
  border-bottom-left-radius: 32px;
  border-bottom-right-radius: 32px;
  color: white;
  position: relative;
  overflow: hidden;
}

.dashboard-top::after {
  content: '\20B5';
  position: absolute;
  right: -10px;
  bottom: -40px;
  font-size: 15rem;
  font-weight: 900;
  color: white;
  opacity: 0.05;
  pointer-events: none;
  user-select: none;
  line-height: 1;
  z-index: 0;
}

.dashboard-top > * {
  position: relative;
  z-index: 1;
}

.dashboard-greeting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.greeting-text .salute { font-size: var(--fs-sm); color: rgba(255, 255, 255, 0.8); }
.greeting-text .name   { font-size: var(--fs-lg); font-weight: var(--fw-bold); color: white; }

.greeting-avatar {
  width: 44px; height: 44px;
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: white;
  flex-shrink: 0;
}

.dashboard-content { padding: var(--space-5); }

.stats-row {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}
.stats-row::-webkit-scrollbar { display: none; }

.kyc-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: linear-gradient(135deg, rgba(245,158,11,0.1), rgba(245,158,11,0.05));
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
  cursor: pointer;
}

.kyc-banner .kyc-icon { color: var(--clr-warning); flex-shrink: 0; }
.kyc-banner .kyc-text { flex: 1; }
.kyc-banner .kyc-title { font-size: var(--fs-sm); font-weight: var(--fw-semi); color: #92400e; }
.kyc-banner .kyc-sub   { font-size: var(--fs-xs); color: var(--clr-warning); }

.section-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  color: var(--clr-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: var(--space-3);
}

/* Active loan card on dashboard */
.active-loan-card {
  background: var(--clr-white);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-5);
  margin-top: -80px;
  position: relative;
  z-index: 10;
  overflow: hidden;
}

.active-loan-card::after {
  content: '\20B5';
  position: absolute;
  right: -5px;
  bottom: -15px;
  font-size: 8rem;
  font-weight: 900;
  color: var(--clr-primary);
  opacity: 0.05;
  pointer-events: none;
  user-select: none;
  line-height: 1;
  z-index: 0;
}

.active-loan-card > * {
  position: relative;
  z-index: 1;
}

/* ── Apply for Loan ───────────────────────────────────────── */
.apply-page {
  background: var(--clr-white);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--space-10);
}

.amount-display {
  text-align: center;
  margin: var(--space-4) 0;
}

.amount-display .currency { font-size: var(--fs-lg); color: var(--clr-muted); vertical-align: top; margin-top: 8px; display: inline-block; }
.amount-display .amount   { font-size: 3rem; font-weight: var(--fw-black); color: var(--clr-text); line-height: 1; }

.interest-info-card {
  background: var(--clr-bg);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.interest-info-card .info-item { text-align: center; }
.interest-info-card .info-label { font-size: var(--fs-xs); color: var(--clr-muted); }
.interest-info-card .info-val   { font-size: var(--fs-base); font-weight: var(--fw-bold); color: var(--clr-text); }
.interest-info-card .info-val.highlight { color: var(--clr-primary); }

/* ── KYC Pages ────────────────────────────────────────────── */
.kyc-page {
  background: var(--clr-white);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.kyc-body {
  flex: 1;
  padding: var(--space-5) var(--space-5) var(--space-10);
  overflow-y: auto;
}

.ghana-card-preview {
  background: linear-gradient(135deg, #1a3a5c 0%, #2563eb 100%);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  color: white;
  margin-bottom: var(--space-5);
  position: relative;
  overflow: hidden;
  min-height: 120px;
}

.ghana-card-preview::after {
  content: 'GHANA';
  position: absolute;
  right: 16px; top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
  font-weight: var(--fw-black);
  opacity: 0.08;
  letter-spacing: -2px;
}

/* ── Profile Page ─────────────────────────────────────────── */
.profile-page {
  background: var(--clr-bg);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + var(--space-4));
}

.profile-header {
  background: var(--gradient-primary);
  padding: var(--space-10) var(--space-5) var(--space-8);
  text-align: center;
  color: white;
  position: relative;
}

.profile-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  color: white;
  margin: 0 auto var(--space-3);
  border: 3px solid rgba(255,255,255,0.3);
}

.profile-name { font-size: var(--fs-xl); font-weight: var(--fw-bold); margin-bottom: var(--space-1); }
.profile-phone { font-size: var(--fs-sm); opacity: 0.8; }

.referral-card {
  background: linear-gradient(135deg, var(--clr-white) 0%, var(--clr-bg-alt) 100%);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin: var(--space-4) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.referral-code {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--clr-primary-dark);
  letter-spacing: 2px;
  background: rgba(59, 91, 219, 0.08); /* faint primary */
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ── History Page ─────────────────────────────────────────── */
.history-page {
  background: var(--clr-bg);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + var(--space-4));
}

/* ── Loan Details ─────────────────────────────────────────── */
.loan-details-page {
  background: var(--clr-bg);
  min-height: 100vh;
  padding-bottom: var(--space-10);
}

.loan-hero {
  background: var(--gradient-primary);
  padding: var(--space-6) var(--space-5) var(--space-10);
  color: white;
  text-align: center;
}

.loan-hero .loan-amount { font-size: var(--fs-3xl); font-weight: var(--fw-black); }
.loan-hero .loan-label  { font-size: var(--fs-sm); opacity: 0.75; margin-bottom: var(--space-2); }

.loan-details-card {
  background: var(--clr-white);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  margin-top: -24px;
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
}

/* ── Admin Layout ─────────────────────────────────────────── */
.admin-layout {
  display: flex;
  min-height: 100vh;
  background: var(--clr-bg);
}

.admin-sidebar {
  width: 240px;
  background: var(--clr-white);
  border-right: 1px solid var(--clr-border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: transform var(--dur-base) var(--ease);
}

.admin-sidebar-logo {
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--clr-border-light);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.admin-sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: var(--gradient-primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-md);
  font-weight: var(--fw-black);
  color: white;
}

.admin-sidebar-logo .logo-text { font-size: var(--fs-md); font-weight: var(--fw-bold); color: var(--clr-text); }
.admin-sidebar-logo .logo-sub  { font-size: var(--fs-xs); color: var(--clr-muted); }

.admin-nav { flex: 1; padding: var(--space-4) var(--space-3); overflow-y: auto; }

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  color: var(--clr-muted);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  margin-bottom: 2px;
}

.admin-nav-item:hover { background: var(--clr-bg); color: var(--clr-text); }
.admin-nav-item.active { background: rgba(59,91,219,0.1); color: var(--clr-primary); font-weight: var(--fw-semi); }

.admin-content {
  margin-left: 240px;
  flex: 1;
  padding: var(--space-6) var(--space-8);
  max-width: calc(100% - 240px);
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.admin-stat-card {
  background: var(--clr-white);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
}

.admin-stat-card .asc-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--space-3);
}

.admin-stat-card .asc-value { font-size: var(--fs-2xl); font-weight: var(--fw-bold); color: var(--clr-text); }
.admin-stat-card .asc-label { font-size: var(--fs-xs); color: var(--clr-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Admin Table ──────────────────────────────────────────── */
.admin-table-wrap {
  background: var(--clr-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.admin-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--clr-border-light);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  color: var(--clr-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--clr-bg-alt);
}

td {
  padding: var(--space-4);
  font-size: var(--fs-sm);
  color: var(--clr-text);
  border-bottom: 1px solid var(--clr-border-light);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--clr-bg-alt); }

.table-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: white;
  flex-shrink: 0;
}

/* ── Admin Login ──────────────────────────────────────────── */
.admin-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--clr-bg);
  padding: var(--space-6);
}

.admin-login-card {
  background: var(--clr-white);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-xl);
}

/* ── Admin Applicant Detail ───────────────────────────────── */
.applicant-detail {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-6);
  background: var(--clr-white);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.applicant-left {
  background: var(--clr-bg-alt);
  padding: var(--space-6);
  border-right: 1px solid var(--clr-border-light);
}

.applicant-right { padding: var(--space-6); }

.applicant-photo {
  width: 100px; height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--clr-primary);
  margin-bottom: var(--space-4);
}

.doc-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--clr-white);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--clr-primary);
  border: 1px solid var(--clr-border);
  transition: all var(--dur-fast) var(--ease);
  margin-bottom: var(--space-2);
}

.doc-link:hover { background: rgba(59,91,219,0.04); border-color: var(--clr-primary); }

/* ── Settings Sliders ─────────────────────────────────────── */
.settings-section {
  background: var(--clr-white);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-5);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

/* ── Liability View ───────────────────────────────────────── */
.liability-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.liability-item {
  background: var(--clr-white);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.liability-item .li-label { font-size: var(--fs-xs); color: var(--clr-muted); margin-bottom: var(--space-1); }
.liability-item .li-value { font-size: var(--fs-md); font-weight: var(--fw-bold); color: var(--clr-text); }
.liability-item.outstanding .li-value { color: var(--clr-danger); }
.liability-item.paid .li-value        { color: var(--clr-success); }

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
  display: flex;
  background: var(--clr-white);
  border-bottom: 1px solid var(--clr-border-light);
  padding: 0 var(--space-6);
}

.tab-btn {
  padding: var(--space-4) var(--space-5);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--clr-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--dur-fast) var(--ease);
  white-space: nowrap;
}

.tab-btn.active { color: var(--clr-primary); border-bottom-color: var(--clr-primary); }

/* ── Search Bar ───────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--clr-white);
  border: 1.5px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 10px var(--space-4);
}

.search-bar input {
  flex: 1; border: none; outline: none;
  font-size: var(--fs-sm); color: var(--clr-text);
  background: transparent;
}

/* ── Mobile admin overlay ─────────────────────────────────── */
@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .admin-content {
    margin-left: 0;
    max-width: 100%;
    padding: var(--space-4);
  }
  .applicant-detail {
    grid-template-columns: 1fr;
  }
  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .liability-summary {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
  gap: var(--space-4);
}

.empty-icon {
  width: 72px; height: 72px;
  background: var(--clr-bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--clr-muted);
}

.empty-title { font-size: var(--fs-lg); font-weight: var(--fw-semi); color: var(--clr-text); }
.empty-sub   { font-size: var(--fs-sm); color: var(--clr-muted); max-width: 240px; }

/* ── Utility ──────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.font-bold   { font-weight: var(--fw-bold); }
.text-muted  { color: var(--clr-muted); }
.text-primary{ color: var(--clr-primary); }
.text-success{ color: var(--clr-success); }
.text-danger { color: var(--clr-danger); }
.mt-2  { margin-top: var(--space-2); }
.mt-4  { margin-top: var(--space-4); }
.mt-6  { margin-top: var(--space-6); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.flex  { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.px-5   { padding-left: var(--space-5); padding-right: var(--space-5); }
.py-4   { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.p-5    { padding: var(--space-5); }

/* ── Admin Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .admin-content {
    margin-left: 0;
    max-width: 100%;
    padding: var(--space-4);
  }
  #sidebar-toggle {
    display: flex !important;
  }
  .admin-stats {
    grid-template-columns: 1fr;
  }
  .admin-table-wrap {
    overflow-x: auto;
  }
}
@media (min-width: 769px) {
  #sidebar-toggle {
    display: none !important;
  }
}
