/* ═══════════════════════════════════════════════════════════════════════
   SignDigital — Design System
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --primary: #1e3a5f;
  --primary-light: #2d5a8e;
  --primary-bg: #e8f0fe;
  --success: #15803d;
  --success-bg: #dcfce7;
  --warning: #b45309;
  --warning-bg: #fef9c3;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #0369a1;
  --info-bg: #e0f2fe;
  --gray-50: #f8f9fc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --white: #ffffff;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.1), 0 4px 10px rgba(0,0,0,.05);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --transition: 0.2s ease;
}

/* ── Reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); color: var(--gray-800); background: var(--gray-50); line-height: 1.6; min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Typography ────────────────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; color: var(--gray-900); }
h2 { font-size: 1.35rem; font-weight: 600; color: var(--gray-800); }
h3 { font-size: 1.1rem; font-weight: 600; color: var(--gray-700); }

/* ── Layout ────────────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.page-wrap { min-height: 100vh; }
.section { display: none; }
.section.active { display: block; }

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; font-size: .875rem; font-weight: 600; border: none;
  border-radius: var(--radius); cursor: pointer; transition: var(--transition);
  font-family: var(--font); line-height: 1.4; white-space: nowrap;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-outline { background: var(--white); color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-bg); }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }

/* ── Forms ─────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .85rem; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px; font-size: .9rem; font-family: var(--font);
  border: 1.5px solid var(--gray-300); border-radius: var(--radius);
  background: var(--white); color: var(--gray-800); transition: var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,58,95,.1);
}
.form-input::placeholder { color: var(--gray-400); }
.form-textarea { resize: vertical; min-height: 120px; }

/* ── Cards ─────────────────────────────────────────────────────────── */
.card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h2, .card-header h3 { margin: 0; }

/* ── Stats Cards ───────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
  padding: 20px; text-align: center; box-shadow: var(--shadow);
}
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--gray-900); }
.stat-card .stat-label { font-size: .8rem; color: var(--gray-500); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }

/* ── Badges ────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 10px; font-size: .725rem; font-weight: 700;
  border-radius: 20px; text-transform: uppercase; letter-spacing: .5px; line-height: 1.5;
}
.badge-draft     { background: var(--gray-200); color: var(--gray-600); }
.badge-pending   { background: var(--primary-bg); color: var(--primary); }
.badge-partial   { background: var(--warning-bg); color: var(--warning); }
.badge-completed { background: var(--success-bg); color: var(--success); }
.badge-cancelled { background: var(--danger-bg); color: var(--danger); }
.badge-expired   { background: var(--gray-300); color: var(--gray-700); }
.badge-signed    { background: var(--success-bg); color: var(--success); }
.badge-sent      { background: var(--info-bg); color: var(--info); }
.badge-viewed    { background: #e0e7ff; color: #3730a3; }

/* ── Tables ────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%; border-collapse: collapse; font-size: .875rem;
}
.table th {
  text-align: left; padding: 12px 16px; font-size: .75rem; font-weight: 700;
  color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 2px solid var(--gray-200); background: var(--gray-50);
}
.table td {
  padding: 14px 16px; border-bottom: 1px solid var(--gray-100); vertical-align: middle;
}
.table tr:hover td { background: var(--gray-50); }
.table .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Modals ────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.6);
  z-index: 999; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--white); border-radius: var(--radius-lg); width: 100%; max-width: 800px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--gray-200);
}
.modal-header h2 { margin: 0; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--gray-400); padding: 4px; line-height: 1; }
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 12px; }

/* ── Toast ─────────────────────────────────────────────────────────── */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 14px 20px; border-radius: var(--radius); font-size: .875rem; font-weight: 600;
  box-shadow: var(--shadow-lg); animation: slideIn .3s ease; min-width: 320px; max-width: 480px;
  display: flex; align-items: center; gap: 10px;
}
.toast-success { background: var(--success); color: var(--white); }
.toast-error   { background: var(--danger); color: var(--white); }
.toast-warning { background: var(--warning); color: var(--white); }
.toast-info    { background: var(--info); color: var(--white); }
@keyframes slideIn { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }

/* ── Header / Nav ──────────────────────────────────────────────────── */
.app-header {
  background: var(--white); border-bottom: 1px solid var(--gray-200);
  padding: 0 24px; height: 64px; display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow);
}
.app-header .logo { font-size: 1.25rem; font-weight: 700; color: var(--primary); }
.app-header .logo span { color: var(--gray-400); font-weight: 400; }
.app-header .user-info { display: flex; align-items: center; gap: 16px; font-size: .875rem; color: var(--gray-600); }

/* ── Filters ───────────────────────────────────────────────────────── */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.filter-chip {
  padding: 6px 16px; border-radius: 20px; font-size: .8rem; font-weight: 600;
  cursor: pointer; border: 1.5px solid var(--gray-300); background: var(--white);
  color: var(--gray-600); transition: var(--transition);
}
.filter-chip:hover, .filter-chip.active { border-color: var(--primary); background: var(--primary-bg); color: var(--primary); }

/* ── Login Page ────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, #0f172a 100%);
  padding: 20px;
}
.login-card {
  background: var(--white); border-radius: var(--radius-lg); padding: 40px;
  width: 100%; max-width: 440px; box-shadow: var(--shadow-lg);
}
.login-card .login-logo { text-align: center; margin-bottom: 28px; }
.login-card .login-logo h1 { color: var(--primary); font-size: 1.5rem; }

/* ── Signer Cards ──────────────────────────────────────────────────── */
.signer-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.signer-card {
  background: var(--white); border: 2px solid var(--gray-200); border-radius: var(--radius);
  padding: 16px; transition: var(--transition);
}
.signer-card .signer-role {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  margin-bottom: 10px;
}
.signer-card.lawyer    .signer-role { color: #1d4ed8; }
.signer-card.debtor    .signer-role { color: #dc2626; }
.signer-card.witness_1 .signer-role { color: #7c3aed; }
.signer-card.witness_2 .signer-role { color: #7c3aed; }

/* ── Timeline ──────────────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: ''; position: absolute; left: 8px; top: 4px; bottom: 4px;
  width: 2px; background: var(--gray-200);
}
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-item::before {
  content: ''; position: absolute; left: -24px; top: 4px;
  width: 12px; height: 12px; border-radius: 50%; background: var(--primary);
  border: 2px solid var(--white); box-shadow: 0 0 0 2px var(--primary);
}
.timeline-item .tl-time { font-size: .75rem; color: var(--gray-400); }
.timeline-item .tl-text { font-size: .875rem; color: var(--gray-700); }

/* ── Document Preview ──────────────────────────────────────────────── */
.doc-preview {
  border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
  padding: 24px; background: var(--white); max-height: 500px; overflow-y: auto;
  box-shadow: var(--shadow); font-size: .9rem; line-height: 1.7;
}

/* ── Signing Page ──────────────────────────────────────────────────── */
.sign-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--gray-100); padding: 20px;
}
.sign-card {
  background: var(--white); border-radius: var(--radius-lg); padding: 32px;
  width: 100%; max-width: 700px; box-shadow: var(--shadow-lg);
}
.sign-card .sign-status {
  text-align: center; padding: 20px; border-radius: var(--radius); margin-bottom: 20px;
}

/* ── Utility ───────────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.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; }
.flex { display: flex; } .flex-center { align-items: center; justify-content: center; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.hidden { display: none !important; }
.spinner {
  display: inline-block; width: 18px; height: 18px; border: 2px solid var(--gray-300);
  border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--gray-500); gap: 10px;
}
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-400); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .container { padding: 0 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .signer-cards { grid-template-columns: 1fr; }
  .app-header { padding: 0 16px; }
  .app-header .logo { font-size: 1rem; }
  .table th, .table td { padding: 10px 12px; font-size: .8rem; }
  .modal { max-width: 95vw; }
  .login-card { padding: 24px; }
  .btn { padding: 8px 14px; font-size: .8rem; }
}
