/* ============================================================
   Nelson Realty Group — Transaction Manager
   Premium Real Estate Platform Stylesheet
   ============================================================ */

:root {
  --navy: #1B2A4A;
  --dark-navy: #0F1B33;
  --gold: #C9A84C;
  --light-gold: #E8D5A0;
  --light-gray: #F5F6F8;
  --border-gray: #E2E5EA;
  --white: #FFFFFF;
  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;
  --text: #1E293B;
  --muted: #64748B;
  --buyer-color: #3B82F6;
  --buyer-bg: #EFF6FF;
  --seller-color: #8B5CF6;
  --seller-bg: #F5F3FF;
  --sidebar-width: 240px;
  --topbar-height: 60px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.1);
  --transition: 0.15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--light-gray); color: var(--text); line-height: 1.55; min-height: 100vh; }
a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--gold); }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar { position: fixed; top: 0; left: 0; width: var(--sidebar-width); height: 100vh; background: var(--dark-navy); color: var(--white); display: flex; flex-direction: column; z-index: 1000; overflow-y: auto; }
.sidebar-brand { padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-brand a { display: flex; align-items: center; gap: 10px; color: var(--white); }
.brand-icon { width: 36px; height: 36px; background: var(--gold); color: var(--dark-navy); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-family: Georgia, serif; font-weight: 700; font-size: 1.2rem; flex-shrink: 0; }
.brand-name { font-family: Georgia, serif; font-size: 1rem; font-weight: 600; color: var(--gold); display: block; line-height: 1.2; }
.brand-sub { font-size: 0.7rem; color: rgba(255,255,255,0.5); display: block; }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: rgba(255,255,255,0.7); font-size: 0.87rem; font-weight: 500; transition: all var(--transition); }
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.sidebar-nav a.active { background: rgba(201,168,76,0.15); color: var(--gold); }
.sidebar-user { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.08); display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--gold); color: var(--dark-navy); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.8rem; font-weight: 600; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.7rem; color: rgba(255,255,255,0.5); }
.user-logout { color: rgba(255,255,255,0.4); }
.user-logout:hover { color: var(--danger); }

/* ── Main Content ────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-width); min-height: 100vh; }
.top-bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 28px; background: var(--white); border-bottom: 1px solid var(--border-gray); position: sticky; top: 0; z-index: 100; min-height: var(--topbar-height); }
.page-title { font-size: 1.25rem; font-weight: 700; color: var(--navy); }
.content-area { padding: 24px 28px; }

/* ── Buttons ─────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: var(--radius-sm); font-family: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all var(--transition); white-space: nowrap; }
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: var(--gold); color: var(--dark-navy); }
.btn-secondary { background: var(--light-gray); color: var(--text); border: 1px solid var(--border-gray); }
.btn-secondary:hover { background: var(--border-gray); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-icon { background: none; border: none; padding: 6px; cursor: pointer; color: var(--muted); border-radius: var(--radius-sm); }
.btn-icon:hover { background: var(--light-gray); color: var(--navy); }
.btn-block { width: 100%; justify-content: center; }
.btn-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--muted); line-height: 1; }

/* ── Forms ────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.3px; }
.form-control { width: 100%; padding: 9px 12px; border: 1px solid var(--border-gray); border-radius: var(--radius-sm); font-family: inherit; font-size: 0.9rem; color: var(--text); background: var(--white); transition: border var(--transition); }
.form-control:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,168,76,0.15); }
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.9rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Cards ────────────────────────────────────────────── */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border-gray); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border-gray); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 0.95rem; font-weight: 700; color: var(--navy); }
.card-body { padding: 20px; }

/* ── Stats Grid ──────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border-gray); padding: 20px; display: flex; align-items: center; gap: 16px; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.active-icon { background: #EFF6FF; color: var(--info); }
.pending-icon { background: #FEF3C7; color: var(--warning); }
.closing-icon { background: #F5F3FF; color: #8B5CF6; }
.closed-icon { background: #F0FDF4; color: var(--success); }
.stat-number { font-size: 1.6rem; font-weight: 700; color: var(--navy); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--muted); font-weight: 500; margin-top: 2px; }

/* ── Deals Dashboard ─────────────────────────────────── */
.deals-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.deals-column { min-width: 0; }
.column-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid var(--border-gray); }
.column-header h2 { font-size: 1rem; font-weight: 700; color: var(--navy); }
.deals-list { display: flex; flex-direction: column; gap: 10px; }

.deal-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border-gray); padding: 16px 18px; cursor: pointer; transition: all var(--transition); border-left: 4px solid transparent; }
.deal-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.deal-card.buyer { border-left-color: var(--buyer-color); }
.deal-card.seller { border-left-color: var(--seller-color); }
.deal-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 6px; }
.deal-client { font-weight: 700; font-size: 0.95rem; color: var(--navy); }
.deal-address { font-size: 0.82rem; color: var(--muted); margin-bottom: 8px; }
.deal-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.deal-meta-item { font-size: 0.75rem; color: var(--muted); display: flex; align-items: center; gap: 4px; }

/* ── Badges ──────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-buyer { background: var(--buyer-bg); color: var(--buyer-color); }
.badge-seller { background: var(--seller-bg); color: var(--seller-color); }
.badge-active { background: #DBEAFE; color: #1D4ED8; }
.badge-under_contract { background: #FEF3C7; color: #B45309; }
.badge-pending { background: #FEF3C7; color: #B45309; }
.badge-closed { background: #D1FAE5; color: #065F46; }
.badge-cancelled { background: #FEE2E2; color: #991B1B; }
.badge-draft { background: var(--light-gray); color: var(--muted); }
.badge-sent { background: #DBEAFE; color: #1D4ED8; }
.badge-signed { background: #D1FAE5; color: #065F46; }
.badge-declined { background: #FEE2E2; color: #991B1B; }
.badge-secondary { background: var(--light-gray); color: var(--muted); }

/* ── Deal Detail ─────────────────────────────────────── */
.deal-summary { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border-gray); padding: 20px 24px; margin-bottom: 16px; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 20px; }
.summary-item label { display: block; font-size: 0.72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 3px; }
.summary-item span { font-size: 0.95rem; font-weight: 600; color: var(--navy); }

.deadlines-bar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.deadline-chip { display: flex; align-items: center; gap: 8px; background: var(--white); border: 1px solid var(--border-gray); border-radius: var(--radius); padding: 10px 14px; font-size: 0.82rem; }
.deadline-chip.urgent { border-color: var(--danger); background: #FEF2F2; }
.deadline-chip.past { border-color: var(--danger); background: #FEE2E2; opacity: 0.8; }
.deadline-days { font-weight: 700; min-width: 28px; }
.deadline-label { color: var(--muted); font-weight: 500; }
.deadline-date { font-weight: 600; color: var(--navy); }

/* ── Tabs ────────────────────────────────────────────── */
.tab-nav { display: flex; gap: 0; border-bottom: 2px solid var(--border-gray); margin-bottom: 16px; }
.tab-btn { padding: 10px 20px; border: none; background: none; font-family: inherit; font-size: 0.87rem; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all var(--transition); }
.tab-btn:hover { color: var(--navy); }
.tab-btn.active { color: var(--gold); border-bottom-color: var(--gold); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Document List ───────────────────────────────────── */
.doc-list { padding: 0; }
.doc-item { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border-gray); transition: background var(--transition); }
.doc-item:last-child { border-bottom: none; }
.doc-item:hover { background: var(--light-gray); }
.doc-info { display: flex; align-items: center; gap: 12px; }
.doc-icon { width: 36px; height: 36px; background: #FEE2E2; color: var(--danger); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; flex-shrink: 0; }
.doc-name { font-weight: 600; font-size: 0.9rem; color: var(--navy); }
.doc-category { font-size: 0.75rem; color: var(--muted); }
.doc-actions { display: flex; align-items: center; gap: 8px; }

/* ── Fields Form ─────────────────────────────────────── */
.fields-form { padding: 20px; }
.field-section { margin-bottom: 24px; }
.field-section-title { font-size: 0.8rem; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border-gray); }
.field-row { display: grid; grid-template-columns: 200px 1fr; gap: 10px; align-items: center; padding: 6px 0; }
.field-label { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.field-desc { font-size: 0.72rem; color: var(--muted); }

/* ── Activity Log ────────────────────────────────────── */
.activity-log { padding: 16px 20px; }
.activity-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-gray); }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); margin-top: 6px; flex-shrink: 0; }
.activity-text { font-size: 0.85rem; color: var(--text); }
.activity-time { font-size: 0.75rem; color: var(--muted); }

/* ── Search Box ──────────────────────────────────────── */
.search-box { display: flex; align-items: center; gap: 8px; background: var(--light-gray); border: 1px solid var(--border-gray); border-radius: var(--radius-sm); padding: 0 12px; }
.search-box input { border: none; background: none; padding: 8px 0; font-size: 0.87rem; outline: none; width: 220px; }
.search-box svg { color: var(--muted); flex-shrink: 0; }

/* ── Modals ──────────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 2000; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.active { display: flex; }
.modal { background: var(--white); border-radius: var(--radius); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border-gray); display: flex; align-items: center; justify-content: space-between; font-weight: 700; color: var(--navy); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border-gray); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Deal Type Picker ────────────────────────────────── */
.deal-type-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.type-option input { display: none; }
.type-card { border: 2px solid var(--border-gray); border-radius: var(--radius); padding: 20px; text-align: center; cursor: pointer; transition: all var(--transition); }
.type-card strong { display: block; margin-top: 8px; }
.type-card small { color: var(--muted); font-size: 0.78rem; }
.type-option input:checked + .buyer-card { border-color: var(--buyer-color); background: var(--buyer-bg); }
.type-option input:checked + .seller-card { border-color: var(--seller-color); background: var(--seller-bg); }

/* ── Tables ──────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 10px 16px; text-align: left; font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; border-bottom: 2px solid var(--border-gray); background: var(--light-gray); }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border-gray); font-size: 0.87rem; }
.data-table tbody tr:hover { background: #F8FAFC; }
.data-table tbody tr { cursor: pointer; }

/* ── Toast ────────────────────────────────────────────── */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: var(--radius-sm); font-size: 0.87rem; font-weight: 500; box-shadow: var(--shadow-md); transition: all 0.3s; min-width: 280px; }
.toast-success { background: #065F46; color: var(--white); }
.toast-error { background: #991B1B; color: var(--white); }
.toast-info { background: var(--navy); color: var(--white); }
.toast-warning { background: #92400E; color: var(--white); }
.toast-icon { font-size: 1.1rem; }

/* ── Alerts ──────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 0.87rem; font-weight: 500; }
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-danger { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }

/* ── Login ────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--dark-navy) 0%, var(--navy) 100%); }
.login-container { width: 100%; max-width: 380px; padding: 0 20px; }
.login-brand { text-align: center; margin-bottom: 32px; }
.login-logo { width: 64px; height: 64px; margin: 0 auto 16px; background: var(--gold); color: var(--dark-navy); border-radius: 16px; display: flex; align-items: center; justify-content: center; font-family: Georgia, serif; font-weight: 700; font-size: 2rem; }
.login-brand h1 { font-family: Georgia, serif; font-size: 1.4rem; color: var(--gold); }
.login-brand p { color: rgba(255,255,255,0.5); font-size: 0.85rem; }
.login-form { background: var(--white); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow-lg); }
.login-form .btn { margin-top: 8px; padding: 11px; font-size: 0.95rem; }

/* ── Settings Grid ───────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; }

/* ── Upload Zone ─────────────────────────────────────── */
.upload-zone { border: 2px dashed var(--border-gray); border-radius: var(--radius); padding: 32px; text-align: center; cursor: pointer; transition: all var(--transition); }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--gold); background: rgba(201,168,76,0.05); }

/* ── Admin Field Editor ──────────────────────────────── */
.field-editor-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; min-height: 400px; }
.field-list-panel { overflow-y: auto; max-height: 60vh; }
.field-edit-card { border: 1px solid var(--border-gray); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 8px; }
.field-edit-card .form-group { margin-bottom: 8px; }
.pdf-preview-box { border: 1px solid var(--border-gray); border-radius: var(--radius-sm); height: 60vh; background: #FAFAFA; display: flex; align-items: center; justify-content: center; }
.field-preview-panel { position: sticky; top: 0; }

/* ── Field Coordinate Inputs ───────────────────────── */
.modal-xxl { max-width: 1280px; }
.pdf-preview-box { position: relative; overflow: auto; }
/* Field coordinate inputs */
.field-coords-row { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border-gray); }
.coords-inputs { display: grid; grid-template-columns: 60px 1fr 1fr 1fr 1fr; gap: 6px; }
.coords-inputs div { display: flex; flex-direction: column; }
.coords-inputs label { font-size: 0.68rem; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.coords-inputs input { font-size: 0.8rem; padding: 4px 6px; text-align: center; }

/* ── Skeleton ────────────────────────────────────────── */
.skeleton-card { height: 80px; background: linear-gradient(90deg, #F0F0F0 25%, #E0E0E0 50%, #F0F0F0 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Hamburger ───────────────────────────────────────── */
.hamburger { display: none; position: fixed; top: 14px; left: 14px; z-index: 1100; background: var(--white); border: 1px solid var(--border-gray); border-radius: var(--radius-sm); width: 40px; height: 40px; cursor: pointer; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.hamburger span { width: 18px; height: 2px; background: var(--navy); transition: 0.2s; }

/* ── Utilities ───────────────────────────────────────── */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.hidden { display: none !important; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state svg { margin: 0 auto 12px; opacity: 0.4; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .hamburger { display: flex; }
  .main-content { margin-left: 0; }
  .top-bar { padding: 12px 16px; padding-left: 60px; }
  .content-area { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .deals-columns { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .search-box input { width: 140px; }
  .field-editor-layout { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .deal-type-picker { grid-template-columns: 1fr; }
  .tab-btn { padding: 10px 12px; font-size: 0.8rem; }
  .modal { max-width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: 14px; }
  .stat-icon { display: none; }
}
