/* ============================================ */
/* Dark theme — active when <html data-theme="dark"> */
/* Loaded after main.css; overrides design tokens  */
/* and common hardcoded light backgrounds.         */
/* ============================================ */

html[data-theme="dark"] {
    color-scheme: dark;

    /* Venture design system */
    --venture-primary: #4F8EF7;
    --venture-primary-light: #6FA3FA;
    --venture-primary-dark: #3B78E0;

    --venture-secondary: #9CA3AF;
    --venture-secondary-light: #6B7280;
    --venture-secondary-dark: #D1D5DB;

    --venture-bg-primary: #1E1F22;
    --venture-bg-secondary: #141517;
    --venture-bg-tertiary: #2A2B2F;

    --venture-border-light: #2F3136;
    --venture-border-medium: #3A3D43;
    --venture-border-strong: #555A62;

    --venture-text-primary: #ECEDEE;
    --venture-text-secondary: #A1A5AB;
    --venture-text-tertiary: #7C8087;

    --venture-blue: #60A5FA;
    --venture-blue-light: #1E2A3D;

    --venture-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --venture-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.4);
    --venture-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.55), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
    --venture-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.45);

    /* Fluent tokens */
    --colorBrandForeground1: #60A5FA;
    --colorBrandForeground2: #93C5FD;
    --colorBrandBackground: #3B82F6;
    --colorBrandBackgroundHover: #2563EB;
    --colorBrandBackgroundPressed: #1D4ED8;
    --colorBrandBackgroundSelected: #1E2A3D;

    --colorNeutralForeground1: #ECEDEE;
    --colorNeutralForeground2: #C9CBCF;
    --colorNeutralForeground3: #A1A5AB;
    --colorNeutralForeground4: #8A8E95;
    --colorNeutralForegroundDisabled: #5C6067;

    --colorNeutralBackground1: #1E1F22;
    --colorNeutralBackground2: #1A1B1E;
    --colorNeutralBackground3: #26272B;
    --colorNeutralBackground4: #2C2D31;
    --colorNeutralBackground5: #323338;
    --colorNeutralBackground6: #3A3B40;

    --colorNeutralStroke1: #3A3D43;
    --colorNeutralStroke2: #2F3136;
    --colorNeutralStroke3: #555A62;
    --colorNeutralStrokeDisabled: #2F3136;

    --colorStatusSuccessForeground1: #4ADE80;
    --colorStatusSuccessBackground1: #12301D;
    --colorStatusErrorForeground1: #F87171;
    --colorStatusErrorBackground1: #3A1518;
    --colorStatusWarningForeground1: #FBBF24;
    --colorStatusWarningBackground1: #3A2E12;

    --shadow-2: 0px 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-4: 0px 2px 4px rgba(0, 0, 0, 0.5);
    --shadow-8: 0px 4px 8px rgba(0, 0, 0, 0.5);
    --shadow-16: 0px 8px 16px rgba(0, 0, 0, 0.5);
}

/* One page background for every layer, so it doesn't change below the first screen */
html[data-theme="dark"],
html[data-theme="dark"] body,
html[data-theme="dark"] .main-content,
html[data-theme="dark"] .page,
html[data-theme="dark"] .content-grid,
html[data-theme="dark"] .properties-feed,
html[data-theme="dark"] .feed-container {
    background-color: var(--venture-bg-secondary);
    color: var(--venture-text-primary);
}

/* Logo is drawn dark on light */
html[data-theme="dark"] .sidebar-header .logo-svg,
html[data-theme="dark"] .sidebar-header .logo img {
    filter: invert(1);
}

/* Text inputs */
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="tel"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] textarea,
html[data-theme="dark"] select,
html[data-theme="dark"] .venture-input {
    background-color: var(--venture-bg-tertiary);
    color: var(--venture-text-primary);
    border-color: var(--venture-border-medium);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: var(--venture-text-tertiary);
}

/* Tables */
html[data-theme="dark"] table,
html[data-theme="dark"] th,
html[data-theme="dark"] td {
    background-color: var(--venture-bg-primary);
    color: var(--venture-text-primary);
    border-color: var(--venture-border-light);
}

/* Containers with hardcoded light backgrounds in main.css */
html[data-theme="dark"] .autosearch-tile,
html[data-theme="dark"] .agent-filter-agency,
html[data-theme="dark"] .agent-filter-agents,
html[data-theme="dark"] .agent-filter-agent,
html[data-theme="dark"] .agent-filter-mls-option,
html[data-theme="dark"] .agent-card,
html[data-theme="dark"] .agent-phone,
html[data-theme="dark"] .agent-avatar-large,
html[data-theme="dark"] .agent-profile-contact-item,
html[data-theme="dark"] .photo-preview-card,
html[data-theme="dark"] .photo-preview-info,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .collection-modal,
html[data-theme="dark"] .collection-divider span,
html[data-theme="dark"] .custom-dialog,
html[data-theme="dark"] .performance-console,
html[data-theme="dark"] .performance-stats,
html[data-theme="dark"] .timeline-item,
html[data-theme="dark"] .profile-edit-field textarea,
html[data-theme="dark"] .profile-edit-footer,
html[data-theme="dark"] .journal-add-entry,
html[data-theme="dark"] .journal-entry,
html[data-theme="dark"] .journal-entry-card,
html[data-theme="dark"] .analytics-chart-container,
html[data-theme="dark"] .ai-trends-table-container,
html[data-theme="dark"] .trends-controls select,
html[data-theme="dark"] .prop-popup-no-photo,
html[data-theme="dark"] .confirm-dialog,
html[data-theme="dark"] .confirm-dialog-actions,
html[data-theme="dark"] .search-dropdown,
html[data-theme="dark"] .dropdown-menu {
    background: var(--venture-bg-primary);
    color: var(--venture-text-primary);
    border-color: var(--venture-border-light);
}

html[data-theme="dark"] .confirm-dialog-actions .btn-secondary,
html[data-theme="dark"] .filter-modal-close:hover,
html[data-theme="dark"] .fdrop-grid .checkbox-item:hover,
html[data-theme="dark"] .profile-edit-header .btn-icon:hover,
html[data-theme="dark"] .ai-badge.neutral,
html[data-theme="dark"] .aw-theme-minimal {
    background: var(--venture-bg-tertiary);
    color: var(--venture-text-primary);
}

html[data-theme="dark"] .modal-actions {
    border-top-color: var(--venture-border-light);
}

/* Property editor: left info panel */
html[data-theme="dark"] .pe-info-block {
    background: var(--venture-bg-primary);
    box-shadow: var(--venture-shadow-sm);
}
html[data-theme="dark"] .pe-info-block-header,
html[data-theme="dark"] .pe-dt {
    color: var(--venture-text-secondary);
}
html[data-theme="dark"] .pe-dd select,
html[data-theme="dark"] .pe-dd input,
html[data-theme="dark"] .pe-dd input[type="number"] {
    background-color: transparent;
    color: var(--venture-text-primary);
    border-top: none;
    border-left: none;
    border-right: none;
}
html[data-theme="dark"] .pe-dd select {
    border-bottom-color: transparent;
}
html[data-theme="dark"] .pe-dd input {
    border-bottom: 1.5px solid var(--venture-border-medium);
}
html[data-theme="dark"] .pe-dd select:hover,
html[data-theme="dark"] .pe-dd input:hover {
    border-bottom-color: var(--venture-border-strong);
}
html[data-theme="dark"] .pe-dd select:focus,
html[data-theme="dark"] .pe-dd input:focus {
    border-bottom-color: var(--venture-blue);
}
html[data-theme="dark"] .pe-dd select option {
    background-color: var(--venture-bg-primary);
    color: var(--venture-text-primary);
}

/* Property editor: tabs bar */
html[data-theme="dark"] .property-tabs {
    background: var(--venture-bg-primary);
    box-shadow: var(--venture-shadow-sm);
}
html[data-theme="dark"] .property-tab-btn {
    color: var(--venture-text-secondary);
}
html[data-theme="dark"] .property-tab-btn:hover {
    color: var(--venture-blue);
    background: var(--venture-bg-tertiary);
}
html[data-theme="dark"] .property-tab-btn.active {
    color: var(--venture-blue);
    border-bottom-color: var(--venture-blue);
    background: none;
}

/* Client card (CRM): left panel, tabs, search block */
html[data-theme="dark"] .crm-section,
html[data-theme="dark"] .crm-card-actions,
html[data-theme="dark"] .crm-tab-strip,
html[data-theme="dark"] .crm-search-block {
    background: var(--venture-bg-primary);
    color: var(--venture-text-primary);
    box-shadow: var(--venture-shadow-sm);
}
html[data-theme="dark"] .crm-section-header,
html[data-theme="dark"] .crm-field-label,
html[data-theme="dark"] .crm-search-title,
html[data-theme="dark"] .crm-search-label {
    color: var(--venture-text-secondary);
}
html[data-theme="dark"] .crm-section-menu:hover {
    color: var(--venture-text-primary);
}
html[data-theme="dark"] .crm-field-value-text,
html[data-theme="dark"] .crm-card-left .crm-field-input,
html[data-theme="dark"] .crm-card-left .crm-field-select {
    color: var(--venture-text-primary);
}
html[data-theme="dark"] .crm-card-left .crm-field-input {
    border-bottom-color: var(--venture-border-medium) !important;
}
html[data-theme="dark"] .crm-card-left .crm-field-input:hover,
html[data-theme="dark"] .crm-card-left .crm-field-select:hover {
    border-bottom-color: var(--venture-border-strong) !important;
}
html[data-theme="dark"] .crm-card-left .crm-field-input:focus,
html[data-theme="dark"] .crm-card-left .crm-field-select:focus {
    border-bottom-color: var(--venture-blue) !important;
}
html[data-theme="dark"] .crm-card-left .crm-field-input::placeholder {
    color: var(--venture-text-tertiary);
}
html[data-theme="dark"] .crm-card-left .crm-field-select option {
    background-color: var(--venture-bg-primary);
    color: var(--venture-text-primary);
}
html[data-theme="dark"] .crm-tab-btn {
    color: var(--venture-text-secondary);
}
html[data-theme="dark"] .crm-tab-btn:hover {
    color: var(--venture-blue);
    background: var(--venture-bg-tertiary);
}
html[data-theme="dark"] .crm-tab-btn.active {
    color: var(--venture-blue);
    border-bottom-color: var(--venture-blue);
}
html[data-theme="dark"] .crm-search-hint {
    background: var(--venture-blue-light);
    color: var(--venture-blue);
    border-color: #1E3A5F;
}
html[data-theme="dark"] .crm-search-field-quarter .crm-range-pair .venture-input {
    background-color: var(--venture-bg-tertiary) !important;
}

/* Inline styles in markup that hardcode white/light backgrounds */
html[data-theme="dark"] [style*="background: white"],
html[data-theme="dark"] [style*="background:white"],
html[data-theme="dark"] [style*="background: #fff"],
html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background-color: white"],
html[data-theme="dark"] [style*="background-color: #fff"],
html[data-theme="dark"] [style*="background: #f9fafb"],
html[data-theme="dark"] [style*="background: #f8f9fa"],
html[data-theme="dark"] [style*="background: #f3f4f6"] {
    background: var(--venture-bg-primary) !important;
    color: var(--venture-text-primary);
}

/* Scrollbars */
html[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--venture-bg-secondary);
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--venture-border-strong);
}

/* Map tiles stay as-is; darken map controls only */
html[data-theme="dark"] .leaflet-bar a,
html[data-theme="dark"] .leaflet-control-attribution {
    background-color: var(--venture-bg-primary);
    color: var(--venture-text-primary);
}
