/* ==============================================
   2 Wings Risk Services — Funding System Styles
   ============================================== */

/* --- Stats cards --- */
.funding-stats { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 130px; background: white; border: 1px solid var(--border); border-radius: 12px; padding: 16px; text-align: center; }
.stat-card .stat-value { font-size: 1.4rem; font-weight: 700; color: var(--accent-primary); }
.stat-card .stat-label { font-size: 0.8rem; color: #777; margin-top: 4px; }
.stat-card.highlight { border-color: var(--accent-primary); background: rgba(43,138,150,0.04); }

/* --- Toolbar --- */
.funding-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.funding-toolbar input[type="text"],
.funding-toolbar input[type="search"] {
  flex: 1; min-width: 180px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 0.9rem;
}
.funding-toolbar select {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.9rem;
}

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: none; border-radius: 8px;
  font-size: 0.9rem; cursor: pointer; font-weight: 500;
  transition: background 0.2s, box-shadow 0.2s; text-decoration: none;
}
.btn-primary { background: var(--accent-primary); color: white; }
.btn-primary:hover { background: var(--nav-bg); }
.btn-secondary { background: var(--bg-sidebar); color: var(--text-heading); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: #dc3545; color: white; }
.btn-danger:hover { background: #c82333; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

/* --- Data table --- */
.funding-table-wrap { overflow-x: auto; margin: 0 -4px; }
.funding-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.funding-table th {
  background: var(--bg-sidebar); padding: 10px 10px;
  text-align: left; font-weight: 600; color: var(--text-heading);
  border-bottom: 2px solid var(--border); white-space: nowrap;
  cursor: pointer; user-select: none; position: sticky; top: 0;
}
.funding-table th:hover { background: #d5e1e3; }
.funding-table th .sort-arrow { font-size: 0.7rem; margin-left: 3px; opacity: 0.4; }
.funding-table th.sorted .sort-arrow { opacity: 1; }
.funding-table td { padding: 8px 10px; border-bottom: 1px solid #eee; vertical-align: middle; }
.funding-table tr:hover td { background: rgba(43,138,150,0.04); }
.funding-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.funding-table .nowrap { white-space: nowrap; }

/* --- Status badges --- */
.status-badge {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
}
.status-requested { background: #ffe0b2; color: #e65100; }
.status-pending { background: #fff3cd; color: #856404; }
.status-lawyer-signed { background: #cce5ff; color: #004085; }
.status-active { background: #d4edda; color: #155724; }
.status-collected { background: #d1ecf1; color: #0c5460; }
.status-lost { background: #f8d7da; color: #721c24; }
.status-substituted { background: #ffeeba; color: #856404; }

/* --- Modals --- */
.funding-modal {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45); z-index: 1000;
  align-items: flex-start; justify-content: center;
  padding: 30px 16px; overflow-y: auto;
}
.funding-modal.active { display: flex; }
.modal-card {
  background: white; border-radius: 16px; width: 100%; max-width: 720px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25); animation: modalIn 0.2s ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid #eee;
}
.modal-header h2 { margin: 0; font-size: 1.15rem; color: var(--text-heading); }
.modal-close {
  background: none; border: none; font-size: 1.5rem; cursor: pointer;
  color: #999; padding: 0; line-height: 1;
}
.modal-close:hover { color: #333; }
.modal-body { padding: 24px; max-height: 70vh; overflow-y: auto; }
.modal-footer {
  padding: 14px 24px; border-top: 1px solid #eee;
  display: flex; gap: 8px; justify-content: flex-end;
}

/* --- Forms --- */
.form-row { display: flex; gap: 16px; margin-bottom: 14px; }
.form-row > .form-group { flex: 1; margin-bottom: 0; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-heading); margin-bottom: 3px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.9rem; box-sizing: border-box;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent-primary); outline: none; box-shadow: 0 0 0 3px rgba(43,138,150,0.12); }
.form-group textarea { min-height: 70px; resize: vertical; }
.form-hint { font-size: 0.75rem; color: #999; margin-top: 2px; }
.form-section {
  font-size: 0.88rem; font-weight: 700; color: var(--accent-primary);
  margin: 20px 0 10px; padding-bottom: 5px;
  border-bottom: 2px solid var(--bg-sidebar);
}
.form-section:first-child { margin-top: 0; }

/* --- Login --- */
.login-container { max-width: 420px; margin: 50px auto; }
.login-card {
  background: white; border: 1px solid var(--border);
  border-radius: 16px; padding: 36px 32px; text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}
.login-card h2 { color: var(--text-heading); margin: 0 0 6px; font-size: 1.4rem; }
.login-card .login-subtitle { color: #888; font-size: 0.9rem; margin-bottom: 24px; }
.login-card .form-group { text-align: left; }
.login-tabs {
  display: flex; margin-bottom: 24px;
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.login-tab {
  flex: 1; padding: 10px; border: none; background: var(--bg-sidebar);
  cursor: pointer; font-weight: 600; font-size: 0.88rem; color: #666;
  transition: background 0.2s, color 0.2s;
}
.login-tab.active { background: var(--accent-primary); color: white; }
.login-error { color: #dc3545; font-size: 0.85rem; margin-top: 10px; display: none; }
.login-error.visible { display: block; }

/* --- Client portal --- */
.client-welcome { margin-bottom: 24px; }
.client-welcome h2 { color: var(--text-heading); margin: 0 0 6px; }
.client-welcome p { color: #666; margin: 0; }
.contract-card {
  background: white; border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; margin-bottom: 16px;
  transition: box-shadow 0.2s;
}
.contract-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
.contract-card-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px;
}
.contract-card-header h3 { margin: 0; font-size: 1rem; color: var(--text-heading); }
.contract-detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px;
}
.detail-item .detail-label {
  font-size: 0.72rem; color: #999; text-transform: uppercase; letter-spacing: 0.5px;
}
.detail-item .detail-value { font-size: 0.95rem; color: #333; font-weight: 500; }

/* --- Rates table --- */
.rates-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.rates-table th, .rates-table td { padding: 8px 12px; border-bottom: 1px solid #eee; text-align: left; }
.rates-table th { background: var(--bg-sidebar); font-weight: 600; font-size: 0.85rem; }
.rates-table td { font-size: 0.9rem; }

/* --- Contract detail modal --- */
.detail-section { margin-bottom: 20px; }
.detail-section h3 { font-size: 0.9rem; color: var(--accent-primary); margin: 0 0 10px; padding-bottom: 4px; border-bottom: 1px solid #eee; }
.detail-row { display: flex; padding: 4px 0; font-size: 0.88rem; }
.detail-row .dl { color: #888; width: 160px; flex-shrink: 0; }
.detail-row .dv { color: #333; font-weight: 500; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* --- Empty state --- */
.empty-state { text-align: center; padding: 50px 20px; color: #999; }
.empty-state p { margin: 6px 0; }

/* --- Link button --- */
.link-btn {
  background: none; border: none; color: var(--accent-primary);
  cursor: pointer; font-size: 0.84rem; text-decoration: underline; padding: 0;
}
.link-btn:hover { color: var(--nav-bg); }

/* --- Token display --- */
.token-display {
  font-family: 'Courier New', monospace; font-size: 0.85rem;
  background: #f5f5f5; padding: 6px 10px; border-radius: 6px;
  border: 1px solid #ddd; display: inline-block; user-select: all;
}

/* --- Notifications --- */
.notif-bar { background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 12px 16px; margin-bottom: 20px; }
.notif-item { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 0.88rem; gap: 12px; }
.notif-item + .notif-item { border-top: 1px solid #fde68a; }

/* --- Sidebar badge --- */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: #dc3545; color: white; font-size: 0.7rem; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  margin-left: 6px; vertical-align: middle;
}

/* --- Logout link --- */
.logout-link {
  margin-top: 2px !important;
  border-top: 1px solid var(--border);
  font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.logout-link svg { flex-shrink: 0; }

/* --- Client info box --- */
.client-info-box {
  background: var(--bg-sidebar); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 16px; font-size: 0.88rem;
  margin-bottom: 14px; line-height: 1.5;
}

/* --- E-signature box --- */
.esign-box {
  margin-top: 20px; padding: 16px;
  background: #f0fdf4; border: 1px solid #86efac; border-radius: 8px;
}

/* --- Registration wider login card --- */
#registerCard .login-container { max-width: 520px; }

/* --- 2FA OTP banner --- */
.otp-demo-banner {
  background: #eff6ff; border: 1px solid #93c5fd; border-radius: 8px;
  padding: 10px 14px; font-size: 0.88rem; color: #1e40af; margin-top: 8px;
}

/* --- Encryption indicator --- */
.enc-icon { font-size: 0.75rem; color: #22c55e; cursor: help; }

/* --- Verified badges --- */
.verified-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 0.72rem; font-weight: 600; white-space: nowrap;
}
.verified-badge.verified { background: #d4edda; color: #155724; }
.verified-badge.unverified { background: #f8d7da; color: #721c24; }

/* --- Password strength meter --- */
.pwd-strength { margin-top: 6px; }
.pwd-strength-bar { height: 4px; border-radius: 2px; background: #e0e0e0; overflow: hidden; }
.pwd-strength-fill { height: 100%; border-radius: 2px; transition: width 0.3s, background 0.3s; width: 0; }
.pwd-strength-fill.weak { width: 25%; background: #dc3545; }
.pwd-strength-fill.fair { width: 50%; background: #f59e0b; }
.pwd-strength-fill.good { width: 75%; background: #84cc16; }
.pwd-strength-fill.strong { width: 100%; background: #22c55e; }
.pwd-strength-label { font-size: 0.75rem; margin-top: 3px; font-weight: 600; display: inline-block; }
.pwd-strength-label.weak { color: #dc3545; }
.pwd-strength-label.fair { color: #f59e0b; }
.pwd-strength-label.good { color: #84cc16; }
.pwd-strength-label.strong { color: #22c55e; }
.pwd-reqs { margin: 6px 0 0; padding: 0; font-size: 0.78rem; color: #888; }
.pwd-reqs li { margin: 2px 0; list-style: none; padding-left: 18px; position: relative; }
.pwd-reqs li::before { content: '\25CB'; position: absolute; left: 0; color: #ccc; font-size: 0.7rem; top: 1px; }
.pwd-reqs li.pass { color: #555; }
.pwd-reqs li.pass::before { content: '\2713'; color: #22c55e; }
.pwd-reqs li.fail::before { content: '\2717'; color: #dc3545; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .funding-stats { gap: 8px; }
  .stat-card { min-width: 100px; padding: 12px 8px; }
  .stat-card .stat-value { font-size: 1.1rem; }
  .form-row { flex-direction: column; gap: 0; }
  .funding-toolbar { flex-direction: column; align-items: stretch; }
  .funding-toolbar input[type="text"],
  .funding-toolbar input[type="search"] { min-width: auto; }
  .modal-card { margin: 8px; border-radius: 12px; }
  .modal-body { max-height: 60vh; padding: 16px; }
  .detail-row { flex-direction: column; }
  .detail-row .dl { width: auto; margin-bottom: 2px; }
  .login-container { margin: 20px auto; }
  .contract-detail-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .contract-detail-grid { grid-template-columns: 1fr; }
  .funding-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .stat-card { min-width: 0; padding: 10px 4px; }
  .stat-card .stat-value { font-size: 0.95rem; }
  .stat-card .stat-label { font-size: 0.7rem; }
  .funding-table { font-size: 0.78rem; }
  .funding-table th, .content-card .funding-table td { padding: 6px 6px; display: table-cell; }
  .funding-table th { white-space: normal; }
}

/* file-input drop zones (funding-api.js wraps every input[type=file]) */
.file-drop {
  border: 1.5px dashed var(--border-color, #b9c4c4);
  border-radius: 8px;
  padding: 12px 12px 10px;
  transition: border-color .15s, background .15s;
}
.file-drop-hint {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary, #667);
  text-align: center;
}
.file-drop.drag {
  border-color: var(--accent-primary, #1c7c86);
  background: rgba(28, 124, 134, 0.07);
}

/* "?" hover hints (user decision Aug 27: tooltips instead of hint paragraphs) */
.hint-q {
  display: inline-block; width: 16px; height: 16px; line-height: 16px;
  text-align: center; border-radius: 50%;
  background: var(--accent-primary, #1c7c86); color: #fff;
  font-size: 11px; font-weight: 700; cursor: help;
  margin-left: 6px; vertical-align: middle;
}

/* uniform button height regardless of glyphs in the label (em-dashes render taller) */
.btn { line-height: 18px; }

/* Touch-scroll hardening (Surface report Aug 27): no scroll-anchoring jumps
   when lists re-render; the pending list paints on its own layer */
body { overflow-anchor: none; }
#pendingList { transform: translateZ(0); }
.seller-filter { max-width: 280px; margin: 0 0 12px; }
.rate-display { padding: 10px 2px; font-weight: 600; font-size: 1rem; }
