/* =====================================================
   TAX DEED ANALYSIS SYSTEM — Main Stylesheet
   ===================================================== */

:root {
  --primary: #1a4480;
  --primary-light: #2563b0;
  --accent: #e8a000;
  --accent-light: #fbbf24;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f0f4f8;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-w: 240px;
  --rec-a: #16a34a;
  --rec-b: #d97706;
  --rec-c: #dc2626;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ---- LAYOUT ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.sidebar-brand p {
  font-size: 11px;
  opacity: 0.65;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section {
  padding: 8px 16px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.5;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 14px;
  transition: all 0.15s;
}

.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,0.12);
  color: white;
}

.nav-link.active {
  border-left: 3px solid var(--accent);
}

.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: var(--primary);
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info .name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { font-size: 11px; opacity: 0.6; text-transform: capitalize; }

.btn-logout {
  background: none; border: none; color: rgba(255,255,255,0.5);
  cursor: pointer; padding: 4px; border-radius: 4px; flex-shrink: 0;
  transition: color 0.15s;
}
.btn-logout:hover { color: white; }

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-header h2 { font-size: 18px; font-weight: 700; }
.page-header p  { color: var(--text-muted); font-size: 13px; }

.page-body { padding: 24px 28px; flex: 1; }

/* ---- CARDS ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title { font-size: 15px; font-weight: 600; }

/* ---- STATS GRID ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
}

.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat-value.green  { color: var(--rec-a); }
.stat-value.yellow { color: var(--rec-b); }
.stat-value.red    { color: var(--rec-c); }
.stat-value.blue   { color: var(--primary); }

/* ---- PROPERTY TABLE ---- */
.table-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E") no-repeat 10px center / 16px;
}

.search-input:focus { outline: none; border-color: var(--primary-light); }

.filter-select {
  padding: 8px 28px 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  appearance: none;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E") no-repeat right 8px center / 14px;
  cursor: pointer;
}

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

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  cursor: pointer;
}

tbody tr:hover { background: #f8fafc; }

td { padding: 12px 14px; font-size: 13px; }

td.address { font-weight: 500; max-width: 280px; }
td.address span { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---- RECOMMENDATION BADGES ---- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 13px;
}

.badge-A { background: #dcfce7; color: var(--rec-a); }
.badge-B { background: #fef3c7; color: var(--rec-b); }
.badge-C { background: #fee2e2; color: var(--rec-c); }
.badge-none { background: var(--border); color: var(--text-muted); font-size: 11px; }

/* ---- DECISION BADGES ---- */
.decision {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.decision-Bid      { background: #dcfce7; color: #15803d; }
.decision-Pass     { background: #fee2e2; color: #b91c1c; }
.decision-Redeemed { background: #e0f2fe; color: #0369a1; }
.decision-Withdrawn{ background: #f1f5f9; color: #475569; }
.decision-Pending  { background: #fef9c3; color: #854d0e; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-accent    { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-light); }
.btn-success   { background: var(--success); color: white; }
.btn-danger    { background: var(--danger); color: white; }
.btn-sm        { padding: 5px 10px; font-size: 12px; }
.btn-icon      { padding: 6px; }
.btn svg       { width: 15px; height: 15px; }

/* ---- MODALS ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-lg { max-width: 900px; }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; background: white; z-index: 1;
}

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-body    { padding: 20px 24px; }
.modal-footer  { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---- FORMS ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 5px; }

label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }

input, select, textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
  background: white;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37,99,176,0.1);
}

textarea { resize: vertical; min-height: 80px; }

.form-hint { font-size: 11px; color: var(--text-muted); }

/* ---- LINKS FORM ---- */
.links-section { margin-top: 20px; }
.links-section h4 { font-size: 13px; font-weight: 600; margin-bottom: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.link-label {
  width: 200px;
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
}

.link-input { flex: 1; font-size: 12px; }

.link-preview {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: var(--border);
  color: var(--text-muted);
  flex-shrink: 0;
  text-decoration: none;
  transition: all 0.15s;
}

.link-preview:hover, .link-preview.active { background: var(--primary); color: white; }

/* ---- COSTS TABLE ---- */
.costs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.costs-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.bid-table { width: 100%; margin-top: 16px; }
.bid-table th { padding: 8px 12px; background: var(--bg); font-size: 11px; text-transform: uppercase; color: var(--text-muted); }
.bid-table td { padding: 8px 12px; text-align: right; }
.bid-table tr.highlight td { background: #fffbeb; font-weight: 700; color: var(--primary); }
.bid-table td:first-child { text-align: left; font-weight: 600; }

/* ---- LOGIN PAGE ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, #0d2d5e 100%);
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .icon {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
}

.login-logo .icon svg { width: 30px; height: 30px; color: white; }
.login-logo h1 { font-size: 20px; font-weight: 800; color: var(--primary); }
.login-logo p  { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.login-form .form-group { margin-bottom: 16px; }
.login-form label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--text); }
.login-form input { width: 100%; padding: 11px 14px; }

.btn-login {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.15s;
}

.btn-login:hover { background: var(--primary-light); }

.login-error {
  background: #fee2e2;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}

/* ---- TABS ---- */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  gap: 2px;
}

.tab-btn {
  padding: 10px 18px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

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

/* ---- ALERTS ---- */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-error   { background: #fee2e2; color: #991b1b; }
.alert-info    { background: #dbeafe; color: #1e40af; }

/* ---- PROPERTY TYPE TAG ---- */
.type-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.type-House { background: #e0f2fe; color: #0369a1; }
.type-Lot   { background: #f0fdf4; color: #166534; }
.type-Condo { background: #f5f3ff; color: #6d28d9; }

/* ---- LOADING ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
  gap: 12px;
}

.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; display: block; opacity: 0.3; }
.empty-state h3  { font-size: 16px; font-weight: 600; margin-bottom: 6px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .costs-grid { grid-template-columns: 1fr; }
}

/* ---- HIDDEN ---- */
.hidden { display: none !important; }

/* ---- ROLE GUARDS ---- */
[data-role-va]    { display: none; }
[data-role-owner] { display: none; }
body.role-va    [data-role-va]    { display: revert; }
body.role-owner [data-role-owner] { display: revert; }
