/* ─── DigiRG Agreements — Global Stylesheet ─────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* ─── CSS Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg:          #0d0d1a;
  --bg2:         #12122a;
  --surface:     #1a1a35;
  --surface2:    #22224a;
  --border:      #2a2a5a;
  --accent:      #6366f1;
  --accent2:     #818cf8;
  --accent-glow: rgba(99,102,241,0.25);
  --success:     #10b981;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --text:        #e8e8f8;
  --text2:       #a0a0c8;
  --text3:       #6060a0;
  --white:       #ffffff;
  --mono:        'DM Mono', monospace;
  --sans:        'Space Grotesk', sans-serif;
  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   20px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 40px rgba(99,102,241,0.15);
  --transition:  all 0.2s cubic-bezier(0.4,0,0.2,1);
}

/* ─── Reset & Base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ─── Typography ─────────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5 { font-weight: 700; line-height: 1.2; }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.8rem); }
h3 { font-size: 1.2rem; }
p  { color: var(--text2); }
a  { color: var(--accent2); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--white); }

/* ─── Layout ─────────────────────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.flex      { display: flex; }
.flex-col  { flex-direction: column; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1  { gap: 8px; }
.gap-2  { gap: 16px; }
.gap-3  { gap: 24px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* ─── Admin Sidebar Layout ───────────────────────────────────────────────────── */
.admin-wrapper { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-mark {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--white);
}
.sidebar-logo .logo-mark span { color: var(--accent); }
.sidebar-logo .logo-sub {
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text3);
  padding: 8px 12px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: var(--transition);
  cursor: pointer;
}
.nav-item:hover, .nav-item.active {
  background: var(--surface);
  color: var(--white);
}
.nav-item.active { color: var(--accent2); }
.nav-icon { width: 18px; height: 18px; opacity: 0.8; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0;
}
.user-info .name { font-size: 13px; font-weight: 600; }
.user-info .role { font-size: 11px; color: var(--text3); }

/* ─── Main Content ───────────────────────────────────────────────────────────── */
.main-content {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}

.page-content { padding: 32px; flex: 1; }
.page-header { margin-bottom: 28px; }
.page-header h1 { margin-bottom: 4px; }

/* ─── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card-sm { padding: 16px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text2); }

/* ─── Stat Cards ─────────────────────────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
}
.stat-card.green::before { background: var(--success); }
.stat-card.amber::before { background: var(--warning); }
.stat-card.red::before   { background: var(--danger); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-glow); }

.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text3); margin-bottom: 10px; }
.stat-value { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.stat-sub   { font-size: 12px; color: var(--text3); margin-top: 8px; }
.stat-icon  { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); opacity: 0.08; font-size: 60px; }

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent2); transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); }
.btn-outline  { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--surface2); color: var(--white); border-color: var(--accent); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-ghost    { background: transparent; color: var(--text2); padding: 8px 12px; }
.btn-ghost:hover { color: var(--white); background: var(--surface2); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-full { width: 100%; justify-content: center; }

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
.form-group  { margin-bottom: 20px; }
.form-label  { display: block; font-size: 12px; font-weight: 600; letter-spacing: 0.5px; color: var(--text2); margin-bottom: 8px; }
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  transition: var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text3); }
.form-control.error { border-color: var(--danger); }
.form-hint { font-size: 11px; color: var(--text3); margin-top: 6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ─── Table ──────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
tbody tr { transition: var(--transition); border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--surface2); }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 14px 16px; color: var(--text2); vertical-align: middle; }
tbody td strong { color: var(--text); }
.mono { font-family: var(--mono); font-size: 12px; }

/* ─── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.badge::before { content: '●'; font-size: 7px; }
.badge-pending { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-signed  { background: rgba(16,185,129,0.15); color: var(--success); }

/* ─── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid;
}
.alert-error   { background: rgba(239,68,68,0.1);  color: #fca5a5; border-color: rgba(239,68,68,0.3); }
.alert-success { background: rgba(16,185,129,0.1); color: #6ee7b7; border-color: rgba(16,185,129,0.3); }
.alert-info    { background: rgba(99,102,241,0.1); color: var(--accent2); border-color: rgba(99,102,241,0.3); }
.alert-warn    { background: rgba(245,158,11,0.1); color: #fcd34d; border-color: rgba(245,158,11,0.3); }

/* ─── Login Page ─────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,0.12) 0%, transparent 70%);
  top: -200px; right: -200px;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,0.08) 0%, transparent 70%);
  bottom: -100px; left: -100px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow), var(--shadow-glow);
}
.login-logo { text-align: center; margin-bottom: 36px; }
.login-logo .mark { font-size: 32px; font-weight: 900; letter-spacing: 4px; color: var(--white); }
.login-logo .mark span { color: var(--accent); }
.login-logo .sub { font-size: 11px; color: var(--text3); letter-spacing: 2px; text-transform: uppercase; margin-top: 4px; }

/* ─── Client Agreement Page ──────────────────────────────────────────────────── */
.client-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0d0d1a 0%, #12122a 100%);
}
.client-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.client-body { padding: 24px; max-width: 720px; margin: 0 auto; }

.agreement-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}
.agreement-card-header {
  background: linear-gradient(90deg, var(--accent) 0%, #7c3aed 100%);
  padding: 20px 24px;
  color: #fff;
}
.agreement-card-body { padding: 24px; }

.detail-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.detail-item label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text3);
  display: block;
  margin-bottom: 4px;
}
.detail-item span {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.amount-big {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent2);
}

.agreement-scroll {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  max-height: 280px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.9;
  color: var(--text2);
  margin: 20px 0;
}
.agreement-scroll::-webkit-scrollbar { width: 6px; }
.agreement-scroll::-webkit-scrollbar-track { background: var(--bg2); }
.agreement-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.agreement-scroll p { margin-bottom: 14px; }
.agreement-scroll ol { padding-left: 20px; }
.agreement-scroll li { margin-bottom: 8px; }

/* ─── Signature Canvas ───────────────────────────────────────────────────────── */
.sig-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.sig-tab {
  flex: 1;
  padding: 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
}
.sig-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.sig-canvas-wrap {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
#signatureCanvas {
  display: block;
  width: 100%;
  cursor: crosshair;
  touch-action: none;
}
.sig-placeholder {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text3);
  font-size: 13px;
  pointer-events: none;
  text-align: center;
}

/* ─── Location Block ─────────────────────────────────────────────────────────── */
.location-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.location-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.loc-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text3);
  flex-shrink: 0;
  transition: var(--transition);
}
.loc-dot.loading { background: var(--warning); animation: pulse 1s infinite; }
.loc-dot.success { background: var(--success); }
.loc-dot.error   { background: var(--danger); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.loc-addr { font-size: 12px; color: var(--text3); margin-top: 6px; }

/* ─── Checkbox ───────────────────────────────────────────────────────────────── */
.checkbox-wrap {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.checkbox-wrap input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
}
.checkbox-wrap label { font-size: 13px; color: var(--text2); cursor: pointer; line-height: 1.5; }

/* ─── Success/Error States ───────────────────────────────────────────────────── */
.success-screen {
  text-align: center;
  padding: 48px 24px;
}
.success-icon {
  width: 80px; height: 80px;
  background: rgba(16,185,129,0.15);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 24px;
  font-size: 36px;
}

/* ─── Detail View ────────────────────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}
.info-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }
.info-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text3); }
.info-value { font-size: 14px; color: var(--text); font-weight: 500; }
.info-mono  { font-family: var(--mono); font-size: 12px; }

/* ─── Mobile Sidebar Toggle ──────────────────────────────────────────────────── */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

/* ─── Utilities ──────────────────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-sm     { font-size: 12px; }
.text-xs     { font-size: 11px; }
.text-muted  { color: var(--text3); }
.text-accent { color: var(--accent2); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.copy-btn {
  background: none; border: none; color: var(--text3);
  cursor: pointer; font-size: 12px; padding: 2px 6px;
  border-radius: 4px; transition: var(--transition);
}
.copy-btn:hover { color: var(--accent2); background: var(--surface2); }

/* ─── Breadcrumb ─────────────────────────────────────────────────────────────── */
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text3); }
.breadcrumb a { color: var(--text3); }
.breadcrumb a:hover { color: var(--text2); }
.breadcrumb span { color: var(--text2); }

/* ─── Empty State ────────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { margin-bottom: 8px; }

/* ─── Loading Spinner ────────────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.visible { display: block; }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4, .detail-grid { grid-template-columns: 1fr; }
  .page-content { padding: 20px 16px; }
  .detail-row { grid-template-columns: 1fr; }
  .login-card { padding: 36px 24px; margin: 20px; }
  .client-body { padding: 16px; }
}
