/* ========================================
   REINVEST CRM - COMPLETE CSS SYSTEM
   Black Steel & Ember Brand
   Version: 1.0.0
   Date: October 6, 2025
   ======================================== */

/* ========================================
   BRAND COLORS - Single Source of Truth
   ======================================== */
:root {
  /* Brand Core - Black Steel & Ember */
  --brand-black:      #0a0a0a;   /* Primary - Premium like Apple */
  --brand-steel:      #52525b;   /* Secondary - Strong, industrial */
  --brand-ember:      #f97316;   /* Accent - Energy, courage, action */
  --brand-prosperity: #10b981;   /* Money/Success - 10X growth */

  /* Neutrals */
  --neutral-50:   #fafafa;
  --neutral-100:  #f5f5f5;
  --neutral-200:  #e5e5e5;
  --neutral-500:  #71717a;
  --neutral-600:  #52525b;
  --neutral-900:  #18181b;

  /* Light Mode (default) */
  --bg-primary:    #ffffff;
  --bg-secondary:  #fafafa;
  --text-primary:  #18181b;
  --text-secondary: #52525b;

  /* Deal Pipeline Stages */
  --deal-analyzing:    #71717a;  /* Neutral assessment */
  --deal-offer:        #f97316;  /* EMBER - bold move */
  --deal-counter:      #fb923c;  /* Lighter ember - negotiation */
  --deal-contract:     #eab308;  /* Yellow - locked in */
  --deal-earnest:      #84cc16;  /* Lime - committed */
  --deal-buyer-found:  #10b981;  /* PROSPERITY - money coming */
  --deal-assignment:   #8b5cf6;  /* Violet - sophisticated */
  --deal-closed:       #10b981;  /* PROSPERITY - success */
  --deal-dead:         #ef4444;  /* Red - failed, NEXT */

  /* Semantic Colors */
  --money:    #10b981;  /* All dollar amounts */
  --urgent:   #f97316;  /* Needs action NOW */
  --warning:  #fb923c;  /* Pay attention */
  --success:  #10b981;  /* Wins, closed deals */
  --danger:   #ef4444;  /* Errors, failures */
  --info:     #3b82f6;  /* Informational */

  /* Navigation */
  --nav-bg:           #0a0a0a;
  --nav-text:         #ffffff;
  --nav-text-muted:   #a1a1aa;
  --nav-hover:        rgba(255, 255, 255, 0.1);
  --nav-active:       #f97316;
  --nav-height:       64px;
}

/* ========================================
   DARK MODE - Complete Theme Override
   Medical necessity: Reduces eye strain for astigmatism
   ======================================== */
[data-bs-theme="dark"] {
  /* Backgrounds */
  --bg-primary:    #0a0a0a;      /* Cards, modals, surfaces */
  --bg-secondary:  #18181b;      /* Page background */
  --bg-tertiary:   #27272a;      /* Hover states, dividers */
  --bg-input:      #18181b;      /* Form inputs */
  --bg-hover:      #27272a;      /* Interactive hover */

  /* Text */
  --text-primary:   #fafafa;     /* Headings, primary content */
  --text-secondary: #a1a1aa;     /* Labels, muted text */
  --text-tertiary:  #71717a;     /* Disabled, placeholder */

  /* Borders & Dividers */
  --border-color:   #27272a;
  --divider-color:  #3f3f46;

  /* Form Controls */
  --input-bg:       #18181b;
  --input-border:   #3f3f46;
  --input-focus:    #52525b;
  --input-text:     #fafafa;
  --input-placeholder: #71717a;

  /* Cards & Surfaces */
  --card-bg:        #0a0a0a;
  --card-border:    #27272a;
  --card-shadow:    rgba(0, 0, 0, 0.5);

  /* Tables */
  --table-border:   #27272a;
  --table-stripe:   #18181b;
  --table-hover:    rgba(249, 115, 22, 0.1);

  /* Alerts (Dark Mode) */
  --alert-success-bg:   rgba(16, 185, 129, 0.15);
  --alert-success-border: #059669;
  --alert-success-text:   #34d399;

  --alert-danger-bg:    rgba(239, 68, 68, 0.15);
  --alert-danger-border: #dc2626;
  --alert-danger-text:   #f87171;

  --alert-warning-bg:   rgba(251, 146, 60, 0.15);
  --alert-warning-border: #ea580c;
  --alert-warning-text:   #fb923c;

  --alert-info-bg:      rgba(59, 130, 246, 0.15);
  --alert-info-border:  #2563eb;
  --alert-info-text:    #60a5fa;

  /* Navigation (already dark, but ensure consistency) */
  --nav-bg:         #0a0a0a;
  --nav-text:       #fafafa;
  --nav-text-muted: #a1a1aa;

  /* Modals & Dropdowns */
  --modal-bg:       #0a0a0a;
  --modal-backdrop: rgba(0, 0, 0, 0.75);
  --dropdown-bg:    #18181b;
  --dropdown-border: #3f3f46;
  --dropdown-hover: #27272a;
}

/* ========================================
   GLOBAL NAVIGATION
   ======================================== */
.global-nav {
  background: var(--nav-bg);
  height: var(--nav-height);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.global-nav .navbar-brand {
  color: var(--nav-text);
  font-weight: 700;
  font-size: 1.25rem;
}

.global-nav .nav-link {
  color: var(--nav-text-muted);
  transition: color 0.2s;
}

.global-nav .nav-link:hover {
  color: var(--nav-text);
  background: var(--nav-hover);
}

.global-nav .nav-link.active {
  color: var(--nav-active);
}

/* ========================================
   DASHBOARD LAYOUT
   ======================================== */
.dashboard-container {
  padding: 2rem;
  background: var(--bg-secondary);
  min-height: calc(100vh - var(--nav-height));
}

.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.widget {
  background: var(--bg-primary);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--neutral-200);
}

.widget-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ========================================
   DEAL PIPELINE STAGES
   ======================================== */
.stage-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
}

.stage-badge.analyzing { background: var(--deal-analyzing); }
.stage-badge.offer { background: var(--deal-offer); }
.stage-badge.counter { background: var(--deal-counter); }
.stage-badge.contract { background: var(--deal-contract); }
.stage-badge.earnest { background: var(--deal-earnest); }
.stage-badge.buyer-found { background: var(--deal-buyer-found); }
.stage-badge.assignment { background: var(--deal-assignment); }
.stage-badge.closed { background: var(--deal-closed); }
.stage-badge.dead { background: var(--deal-dead); }

/* Pipeline Stage Colors */
.stage-color {
  width: 4px;
  height: 100%;
  border-radius: 2px;
}

.stage-color.analyzing { background: #71717a; }
.stage-color.offer { background: #f97316; }
.stage-color.counter { background: #fb923c; }
.stage-color.contract { background: #eab308; }
.stage-color.earnest { background: #84cc16; }
.stage-color.buyer-found { background: #10b981; }
.stage-color.assignment { background: #8b5cf6; }
.stage-color.closed { background: #10b981; }
.stage-color.dead { background: #ef4444; }

/* ========================================
   BUTTONS & INTERACTIVE ELEMENTS
   ======================================== */
.btn-primary {
  background: var(--brand-ember);
  border-color: var(--brand-ember);
  color: white;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: #fb923c;
  border-color: #fb923c;
  transform: translateY(-1px);
}

.btn-success {
  background: var(--brand-prosperity);
  border-color: var(--brand-prosperity);
}

.btn-success:hover {
  background: #059669;
  border-color: #059669;
}

/* ========================================
   FORMS
   ======================================== */
.form-control:focus {
  border-color: var(--brand-ember);
  box-shadow: 0 0 0 0.2rem rgba(249, 115, 22, 0.25);
}

.form-label {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.form-text {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

.text-muted {
  color: var(--text-secondary) !important;
}

/* Money Display */
.price,
.money {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--brand-prosperity);
}

/* ========================================
   TABLES
   ======================================== */
.table {
  color: var(--text-primary);
}

.table thead th {
  border-bottom: 2px solid #e5e5e5;
  font-weight: 600;
  color: var(--text-primary);
}

.table-hover tbody tr:hover {
  background: rgba(249, 115, 22, 0.05);
}

.table-striped tbody tr:nth-of-type(odd) {
  background: var(--bg-secondary);
}

/* ========================================
   ALERTS & MESSAGES
   ======================================== */
.alert {
  border-radius: 0.5rem;
  border: 1px solid;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--brand-prosperity);
  color: #065f46;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
  color: #991b1b;
}

.alert-warning {
  background: rgba(251, 146, 60, 0.1);
  border-color: var(--warning);
  color: #92400e;
}

.alert-info {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--info);
  color: #1e40af;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.text-ember { color: var(--brand-ember); }
.text-steel { color: var(--brand-steel); }
.text-prosperity { color: var(--brand-prosperity); }
.text-money { color: var(--money); }
.text-urgent { color: var(--urgent); }

.bg-ember { background: var(--brand-ember); }
.bg-steel { background: var(--brand-steel); }
.bg-prosperity { background: var(--brand-prosperity); }

.border-ember { border-color: var(--brand-ember); }
.border-steel { border-color: var(--brand-steel); }
.border-prosperity { border-color: var(--brand-prosperity); }

/* ========================================
   RESPONSIVE UTILITIES
   ======================================== */
@media (max-width: 768px) {
  .dashboard-container {
    padding: 1rem;
  }

  .global-nav {
    padding: 0 1rem;
  }

  h1 {
    font-size: 1.5rem;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
  .global-nav,
  .quick-actions {
    display: none;
  }

  .widget {
    break-inside: avoid;
    border: 1px solid #ccc;
  }
}

/* ========================================
   USER INFO HEADER
   ======================================== */
/* User Info Header */
.user-info-bar {
    background: var(--nav-bg, #0a0a0a);
    color: var(--nav-text, #ffffff);
    padding: 8px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--nav-border, rgba(255, 255, 255, 0.08));
    font-size: 14px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.user-info-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info-bar a,
.user-logout-link {
    color: var(--nav-text, #ffffff);
    text-decoration: none;
    transition: color 0.2s ease;
}

.user-info-bar a:hover,
.user-logout-link:hover {
    color: var(--brand-ember, #f97316);
}

.user-email {
    font-weight: 600;
}

.user-team {
    color: #a1a1aa;
}

.user-tier-badge {
    padding: 2px 8px;
    background: #ff6b35;
    border-radius: 3px;
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
}

.user-logout-link {
    color: #fafafa;
    text-decoration: none;
    padding: 4px 12px;
    border: 1px solid #333;
    border-radius: 4px;
    transition: all 0.2s;
}

.user-logout-link:hover {
    background: #333;
    color: #ff6b35;
}
/* ===========================================
   DARK MODE - BOOTSTRAP TABLE OVERRIDES
   Bootstrap 5 uses CSS custom properties.
   We override them for dark mode compatibility.
   =========================================== */

[data-bs-theme="dark"] .table,
[data-bs-theme="dark"] .table-striped,
[data-bs-theme="dark"] .table-hover {
    --bs-table-bg: #18181b;
    --bs-table-color: #fafafa;
    --bs-table-border-color: #3f3f46;
    --bs-table-striped-bg: #27272a;
    --bs-table-striped-color: #fafafa;
    --bs-table-hover-bg: rgba(249, 115, 22, 0.1);
    --bs-table-hover-color: #fafafa;
}

[data-bs-theme="dark"] .table > thead {
    background-color: #27272a;
}

[data-bs-theme="dark"] .table > thead > tr > th {
    background-color: #27272a;
    color: #fafafa;
    border-color: #3f3f46;
}

[data-bs-theme="dark"] .table > tbody > tr > td {
    color: #fafafa;
    border-color: #3f3f46;
}

[data-bs-theme="dark"] .table > tbody > tr {
    background-color: #18181b;
}

[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > td {
    background-color: #27272a;
}

/* ===========================================
   DARK MODE - FORM CONTROLS (Bootstrap)
   =========================================== */

[data-bs-theme="dark"] .form-select {
    background-color: #27272a;
    border-color: #3f3f46;
    color: #fafafa;
}

[data-bs-theme="dark"] .form-select:focus {
    background-color: #27272a;
    border-color: var(--brand-ember);
    color: #fafafa;
}

/* ===========================================
   THEME TOGGLE - ICON VISIBILITY
   Icon must be visible in BOTH modes.
   =========================================== */

[data-bs-theme="dark"] .ph-sun,
[data-bs-theme="dark"] .ph-moon {
    color: #fafafa !important;
}

[data-bs-theme="light"] .ph-sun,
[data-bs-theme="light"] .ph-moon {
    color: #18181b !important;
}

/* ===========================================
   DARK MODE - BADGE OVERRIDES
   =========================================== */

[data-bs-theme="dark"] .badge.bg-secondary {
    background-color: #3f3f46 !important;
    color: #fafafa !important;
}

/* ===========================================
   DARK MODE - BUTTON OUTLINES
   =========================================== */

[data-bs-theme="dark"] .btn-outline-primary {
    color: var(--brand-ember);
    border-color: var(--brand-ember);
}

[data-bs-theme="dark"] .btn-outline-primary:hover {
    background-color: var(--brand-ember);
    color: #ffffff;
}

[data-bs-theme="dark"] .btn-outline-secondary {
    color: #a1a1aa;
    border-color: #3f3f46;
}

[data-bs-theme="dark"] .btn-outline-secondary:hover {
    background-color: #3f3f46;
    color: #fafafa;
}

/* ===========================================
   DARK MODE - PAGINATION
   =========================================== */

[data-bs-theme="dark"] .pagination .page-link {
    background-color: #18181b;
    border-color: #3f3f46;
    color: #fafafa;
}

[data-bs-theme="dark"] .pagination .page-item.active .page-link {
    background-color: var(--brand-ember);
    border-color: var(--brand-ember);
    color: #ffffff;
}

[data-bs-theme="dark"] .pagination .page-link:hover {
    background-color: #27272a;
    color: var(--brand-ember);
}

/* ===========================================
   DARK MODE - TYPOGRAPHY & UTILITIES
   =========================================== */

[data-bs-theme="dark"] h1,
[data-bs-theme="dark"] h2,
[data-bs-theme="dark"] h3,
[data-bs-theme="dark"] h4,
[data-bs-theme="dark"] h5,
[data-bs-theme="dark"] h6 {
    color: #fafafa;
}

[data-bs-theme="dark"] .text-muted {
    color: #a1a1aa !important;
}

/* ========================================
   THEME TOGGLE BUTTON
   ======================================== */
.theme-toggle-btn {
    background: transparent;
    border: none;
    color: var(--nav-text, #ffffff);
    padding: 8px;
    cursor: pointer;
    font-size: 1.125rem;
    transition: color 0.2s ease, transform 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
}

.theme-toggle-btn:hover {
    opacity: 1;
    color: var(--brand-ember, #f97316);
    transform: scale(1.1);
}

.theme-toggle-btn:active {
    transform: scale(0.95);
}

.theme-toggle-btn i {
    font-size: 1.25rem;
}

/* ========================================
   LIGHT MODE VARIABLE OVERRIDES
   ======================================== */
[data-bs-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --text-primary: #18181b;
    --text-secondary: #52525b;
    --nav-bg: #ffffff;
    --nav-text: #18181b;
    --nav-text-muted: #52525b;
    --nav-hover: rgba(0, 0, 0, 0.05);
    --nav-border: rgba(0, 0, 0, 0.1);
}

/* ============================================
   SKIP TRACE SECTION
   ============================================ */

.skip-trace-section {
    background: var(--bg-secondary, #1a1a1a);
    border: 1px solid var(--border-color, #333);
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.skip-trace-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color, #333);
}

.skip-trace-section .section-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
}

.skip-trace-section .section-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Owner Cards */
.owner-info-grid {
    display: grid;
    gap: 16px;
}

.owner-card {
    background: var(--bg-primary, #0f0f0f);
    border: 1px solid var(--border-color, #333);
    border-radius: 6px;
    padding: 16px;
}

.owner-card.owner-primary {
    border-left: 3px solid var(--brand-ember, #f97316);
}

.owner-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.owner-name {
    font-weight: 600;
    font-size: 1rem;
}

.owner-type {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: capitalize;
}

/* Owner Type Badges */
.badge-individual { background: #3b82f6; color: white; }
.badge-joint { background: #8b5cf6; color: white; }
.badge-trust { background: #f59e0b; color: white; }
.badge-llc { background: #10b981; color: white; }
.badge-corporation { background: #06b6d4; color: white; }
.badge-bank { background: #ef4444; color: white; }
.badge-estate { background: #6b7280; color: white; }
.badge-government { background: #1f2937; color: white; }
.badge-unknown { background: #374151; color: white; }

.owner-mailing {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--text-secondary, #a0a0a0);
}

.owner-phones,
.owner-emails {
    margin-bottom: 12px;
}

.phone-item,
.email-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.phone-item a,
.email-item a {
    color: var(--brand-ember, #f97316);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.phone-item a:hover,
.email-item a:hover {
    text-decoration: underline;
}

.source-badge {
    font-size: 0.65rem;
    padding: 1px 6px;
    background: var(--bg-secondary, #1a1a1a);
    border-radius: 3px;
    color: var(--text-muted, #666);
}

.owner-sources {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color, #333);
}

.no-contact {
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.no-skip-trace {
    padding: 20px;
    text-align: center;
}

.no-skip-trace p {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* MAO Highlight - works in both light and dark mode */
/* Follows Bootstrap table-warning pattern for proper dark mode support */
.mao-highlight {
    --bs-table-bg: #f97316;
    --bs-table-color: #18181b;
    background-color: #f97316 !important;
    color: #18181b !important;
}

.mao-highlight > td,
.mao-highlight > th {
    background-color: #f97316 !important;
    color: #18181b !important;
}

[data-bs-theme="dark"] .mao-highlight {
    --bs-table-bg: #f97316;
    --bs-table-color: #18181b;
}

[data-bs-theme="dark"] .mao-highlight > td,
[data-bs-theme="dark"] .mao-highlight > th {
    background-color: #f97316 !important;
    color: #18181b !important;
}
