/* Seller Lead Engine - Styles */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --light: #f8fafc;
    --dark: #1e293b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--light);
    color: var(--dark);
    line-height: 1.5;
}

/* Navigation */
.navbar {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.nav-brand a {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--secondary);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
}

/* User section in navbar */
.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-name {
    color: var(--dark);
    font-weight: 500;
}

.nav-link-small {
    color: var(--secondary);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.nav-link-small:hover {
    color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
}

/* Navigation Divider */
.nav-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 0.5rem;
}

/* ============================================
   APP SWITCHER
   ============================================ */

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.app-switcher {
    position: relative;
}

.app-switcher-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: white;
}

.app-switcher-btn:hover {
    background: rgba(255,255,255,0.2);
}

.app-switcher-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    min-width: 260px;
    padding: 0.5rem;
    display: none;
    z-index: 1000;
}

.app-switcher-menu.show {
    display: block;
}

.app-switcher-header {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.app-switcher-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--dark);
    transition: all 0.2s;
}

.app-switcher-item:hover {
    background: var(--light);
}

.app-switcher-item.active {
    background: var(--light);
}

.app-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
}

.app-icon-leads {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.app-icon-marketing {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.app-icon-admin {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
}

.app-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.app-desc {
    font-size: 0.75rem;
    color: var(--secondary);
}

/* Brand Icons in Navbar */
.brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    color: white;
}

.brand-icon-leads {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.brand-icon-marketing {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.brand-icon-admin {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
}

/* ============================================
   SELLER LEAD ENGINE THEME (Blue)
   ============================================ */

.leads-theme {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
}

.navbar-leads {
    background: linear-gradient(135deg, #1e3a5f 0%, #0f2744 100%);
    border-bottom: none;
}

.navbar-leads .nav-brand a {
    color: white;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.navbar-leads .nav-links a {
    color: rgba(255,255,255,0.7);
}

.navbar-leads .nav-links a:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.navbar-leads .nav-links a.active {
    color: white;
    background: rgba(37, 99, 235, 0.4);
}

.navbar-leads .nav-user .user-name {
    color: white;
}

.navbar-leads .nav-link-small {
    color: rgba(255,255,255,0.7);
}

.navbar-leads .nav-link-small:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.leads-theme .footer {
    background: #0f2744;
    color: rgba(255,255,255,0.6);
}

/* ============================================
   MARKETING HUB THEME (Purple)
   ============================================ */

.marketing-theme {
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
}

.navbar-marketing {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-bottom: none;
}

.navbar-marketing .nav-brand a {
    color: white;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.navbar-marketing .nav-links a {
    color: rgba(255,255,255,0.7);
}

.navbar-marketing .nav-links a:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.navbar-marketing .nav-links a.active {
    color: white;
    background: rgba(139, 92, 246, 0.3);
}

.navbar-marketing .nav-user .user-name {
    color: white;
}

.navbar-marketing .nav-link-small {
    color: rgba(255,255,255,0.7);
}

.navbar-marketing .nav-link-small:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.marketing-theme .footer {
    background: #1a1a2e;
    color: rgba(255,255,255,0.6);
}

/* ============================================
   ADMIN THEME (Gray)
   ============================================ */

.admin-theme {
    --primary: #64748b;
    --primary-dark: #475569;
}

.navbar-admin {
    background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
    border-bottom: none;
}

.navbar-admin .nav-brand a {
    color: white;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.navbar-admin .nav-links a {
    color: rgba(255,255,255,0.7);
}

.navbar-admin .nav-links a:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.navbar-admin .nav-links a.active {
    color: white;
    background: rgba(100, 116, 139, 0.4);
}

.navbar-admin .nav-user .user-name {
    color: white;
}

.navbar-admin .nav-link-small {
    color: rgba(255,255,255,0.7);
}

.navbar-admin .nav-link-small:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.admin-theme .footer {
    background: #1f2937;
    color: rgba(255,255,255,0.6);
}

/* ============================================
   CRM THEME (Teal/Green)
   ============================================ */

.crm-theme {
    --primary: #0d9488;
    --primary-dark: #0f766e;
}

.navbar-crm {
    background: linear-gradient(135deg, #134e4a 0%, #0f3d3a 100%);
    border-bottom: none;
}

.navbar-crm .nav-brand a {
    color: white;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.navbar-crm .nav-links a {
    color: rgba(255,255,255,0.7);
}

.navbar-crm .nav-links a:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.navbar-crm .nav-links a.active {
    color: white;
    background: rgba(13, 148, 136, 0.4);
}

.navbar-crm .nav-user .user-name {
    color: white;
}

.navbar-crm .nav-link-small {
    color: rgba(255,255,255,0.7);
}

.navbar-crm .nav-link-small:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.crm-theme .footer {
    background: #0f3d3a;
    color: rgba(255,255,255,0.6);
}

/* CRM App Icons */
.app-icon-crm {
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
}

.brand-icon-crm {
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
}

.app-badge-crm {
    background: #ccfbf1;
    color: #0f766e;
}

/* CRM Pipeline Stage Badges */
.pipeline-stage-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.stage-new { background: #dbeafe; color: #1e40af; }
.stage-contacted { background: #fef3c7; color: #92400e; }
.stage-qualified { background: #d1fae5; color: #065f46; }
.stage-showing { background: #e9d5ff; color: #7c3aed; }
.stage-offer { background: #fce7f3; color: #be185d; }
.stage-contract { background: #cffafe; color: #0e7490; }
.stage-closed { background: #dcfce7; color: #166534; }
.stage-lost { background: #fee2e2; color: #991b1b; }

/* CRM Deal Stage Badges */
.deal-stage-prospecting { background: #dbeafe; color: #1e40af; }
.deal-stage-showing { background: #e9d5ff; color: #7c3aed; }
.deal-stage-offer { background: #fce7f3; color: #be185d; }
.deal-stage-negotiation { background: #fef3c7; color: #92400e; }
.deal-stage-pending { background: #cffafe; color: #0e7490; }
.deal-stage-closed_won { background: #dcfce7; color: #166534; }
.deal-stage-closed_lost { background: #fee2e2; color: #991b1b; }

/* CRM Activity Timeline */
.activity-timeline {
    position: relative;
    padding-left: 2rem;
}

.activity-timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.activity-item {
    position: relative;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
}

.activity-item::before {
    content: '';
    position: absolute;
    left: -1.75rem;
    top: 0.25rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--primary);
}

.activity-type-call::before { background: #3b82f6; box-shadow: 0 0 0 2px #3b82f6; }
.activity-type-email::before { background: #8b5cf6; box-shadow: 0 0 0 2px #8b5cf6; }
.activity-type-text::before { background: #10b981; box-shadow: 0 0 0 2px #10b981; }
.activity-type-note::before { background: #6b7280; box-shadow: 0 0 0 2px #6b7280; }
.activity-type-meeting::before { background: #f59e0b; box-shadow: 0 0 0 2px #f59e0b; }
.activity-type-showing::before { background: #ec4899; box-shadow: 0 0 0 2px #ec4899; }

.activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.activity-type {
    font-weight: 600;
    text-transform: capitalize;
}

.activity-time {
    font-size: 0.75rem;
    color: var(--secondary);
}

.activity-description {
    color: var(--dark);
    font-size: 0.875rem;
}

/* CRM Task Styles */
.task-priority-urgent { border-left: 4px solid #ef4444; }
.task-priority-high { border-left: 4px solid #f59e0b; }
.task-priority-normal { border-left: 4px solid #3b82f6; }
.task-priority-low { border-left: 4px solid #6b7280; }

.task-status-pending { color: #92400e; }
.task-status-completed { color: #166534; text-decoration: line-through; }
.task-status-cancelled { color: #991b1b; text-decoration: line-through; }

/* CRM Contact Type Badges */
.contact-type-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.contact-type-lead { background: #dbeafe; color: #1e40af; }
.contact-type-buyer { background: #d1fae5; color: #065f46; }
.contact-type-seller { background: #fef3c7; color: #92400e; }
.contact-type-past_client { background: #e9d5ff; color: #7c3aed; }
.contact-type-sphere { background: #f3f4f6; color: #374151; }

/* CRM Stats Cards */
.crm-stat-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    text-align: center;
}

.crm-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: white;
}

.crm-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark);
}

.crm-stat-label {
    font-size: 0.875rem;
    color: var(--secondary);
    margin-top: 0.25rem;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Filters */
.filters-bar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.875rem;
    color: var(--secondary);
}

/* Form Elements */
input, select, textarea {
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

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

.search-input {
    min-width: 250px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-secondary {
    background: var(--light);
    color: var(--dark);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead {
    background: var(--light);
}

th, td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    font-weight: 600;
    color: var(--secondary);
    cursor: pointer;
    user-select: none;
}

th:hover {
    color: var(--primary);
}

tbody tr:hover {
    background: rgba(37, 99, 235, 0.02);
}

/* Tags */
.tag {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-right: 0.25rem;
}

.tag-absentee {
    background: #dbeafe;
    color: #1d4ed8;
}

.tag-bay-area {
    background: #dcfce7;
    color: #166534;
}

.tag-investor {
    background: #fef3c7;
    color: #92400e;
}

.tag-equity {
    background: #f3e8ff;
    color: #7c3aed;
}

/* Score Badge */
.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 2rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.875rem;
}

.score-high {
    background: #dcfce7;
    color: #166534;
}

.score-medium {
    background: #fef3c7;
    color: #92400e;
}

.score-low {
    background: #fee2e2;
    color: #991b1b;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.pagination button {
    padding: 0.5rem 1rem;
}

.pagination span {
    color: var(--secondary);
    font-size: 0.875rem;
}

/* Upload Area */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.upload-icon {
    font-size: 3rem;
    color: var(--secondary);
    margin-bottom: 1rem;
}

.upload-text {
    color: var(--secondary);
    margin-bottom: 0.5rem;
}

.upload-subtext {
    font-size: 0.875rem;
    color: var(--secondary);
}

/* Progress Bar */
.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}

/* Sliders */
.slider-group {
    margin-bottom: 1.5rem;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.slider-label {
    font-weight: 500;
}

.slider-value {
    color: var(--primary);
    font-weight: 600;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

/* Checkbox */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
}

/* Alert Messages */
.alert {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-info {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

/* Charts */
.chart-container {
    position: relative;
    height: 200px;
    margin-top: 1rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--secondary);
    font-size: 0.875rem;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
    }

    .search-input {
        min-width: 100%;
    }
}

/* Lead Detail */
.lead-detail {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.lead-detail-item {
    padding: 0.5rem 0;
}

.lead-detail-label {
    font-size: 0.75rem;
    color: var(--secondary);
    text-transform: uppercase;
}

.lead-detail-value {
    font-weight: 500;
    margin-top: 0.25rem;
}

/* Score Breakdown */
.score-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: var(--light);
    border-radius: 4px;
}

.breakdown-label {
    color: var(--secondary);
}

.breakdown-points {
    font-weight: 600;
    color: var(--success);
}

/* Two column layout */
.two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .two-columns {
        grid-template-columns: 1fr;
    }
}

/* Radio group */
.radio-group {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.radio-option:hover {
    border-color: var(--primary);
}

.radio-option.selected {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.radio-option input {
    display: none;
}

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