/* ===========================
   SEGMENTATION FORM CSS
   =========================== 
   
   CSS for the segmentation form with smart dropdowns.
   Built on top of standalone.css design patterns and variables.
   Uses consistent styling with the main dashboard system.
*/

/* Import design variables - these should match standalone.css */
:root {
    /* Colors from General_Main.css */
    --primary: #5fc73e;
    --primary-dark: #4ab02f;
    --accent: #e87c20;
    --accent-dark: #d96a0a;
    --primary-gradient: linear-gradient(135deg, #5fc73e 0%, #4ab02f 100%);
    
    /* Background and glass effects */
    --glass-bg: rgba(255, 255, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow-light: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 15px 60px rgba(0, 0, 0, 0.2);
    
    /* Text colors */
    --text-primary: #464646;
    --text-secondary: #6b7280;
    --text-light: #64748b;
    
    /* Dashboard colors for clean sections */
    --dashboard-bg: #f8fafc;
    --dashboard-white: #ffffff;
    --dashboard-border: #e2e8f0;
    --dashboard-text: #334155;
    --dashboard-text-light: #64748b;
    --dashboard-hover: #f1f5f9;
    
    /* Transitions */
    --transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    --transition-fast: all 0.2s ease;
}

/* ===========================
   SEGMENTATION FORM LAYOUT
   =========================== */

.segmentation-form {
    width: 100%;
    padding: 0;
}

.segmentation-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: flex-start;
}

.segmentation-row-2 {
    justify-content: flex-start;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.segmentation-row-3 {
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
}

.segmentation-group {
    flex: 1;
    min-width: 0; /* Allow flex items to shrink below their content size */
    max-width: calc(33.333% - 0.67rem); /* Roughly 1/3 width minus gap */
}

/* Special width distribution for row 2 */
.segmentation-row-2 .segmentation-group:nth-child(1),
.segmentation-row-2 .segmentation-group:nth-child(2) {
    flex: 1.125; /* 37.5% each (75% total for first two) */
    max-width: calc(37.5% - 0.5rem);
}

.segmentation-row-2 .segmentation-group:nth-child(3) {
    flex: 0.75; /* 25% for the third one */
    max-width: calc(25% - 0.5rem);
}

.segmentation-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--dashboard-text);
    margin-bottom: 0.5rem;
    text-align: left;
}

/* ===========================
   CUSTOM SELECT STYLING
   =========================== */

.custom-select {
    position: relative;
    width: 100%;
    /* Apply same beautiful styling as search-input-wrapper */
    background: var(--dashboard-white);
    border-radius: 7px;
    box-shadow: 0 0px 15px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
    border: 1px solid #4ab02f;
    z-index: 10000; /* High z-index for dropdown parent - above search results */
}

.custom-select:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 25px rgba(95, 199, 62, 0.2);
    transform: translateY(-2px);
}

.select-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 1.25rem; /* Smaller padding to reduce height */
    background: transparent; /* Let custom-select handle background */
    border: none; /* Let custom-select handle border */
    border-radius: 16px; /* Match custom-select border radius */
    cursor: pointer;
    transition: var(--transition-fast);
    font-size: 0.875rem; /* Slightly smaller font size */
    min-height: 38px; /* Reduced height */
    font-weight: 400; /* Match search input weight */
    color: var(--dashboard-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Remove individual hover/active styles since custom-select handles them */

.select-text {
    color: var(--dashboard-text);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    text-align: left;
}

/* Use dropdown-arrow from simple search styling - no animation */
.dropdown-arrow {
    color: var(--dashboard-text-light);
    font-size: 0.8rem;
    pointer-events: none;
    /* Remove transition to prevent animation */
}

/* Hover effect on the parent custom-select instead */
.custom-select:hover .dropdown-arrow {
    color: var(--primary);
    /* No transform animation */
}

.select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 200%; /* Make dropdowns 50% wider */
    background: var(--dashboard-white);
    border: 1px solid var(--primary);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: var(--shadow-light);
    z-index: 10100; /* High z-index to appear above search results */
    max-height: 350px; /* Increased from 300px */
    overflow-y: visible; /* Remove outer scroller */
    display: none;
    margin-top: 1px;
}

/* Specific override for location dropdown - no outer scroll */
#location-select-leadsynergy-segmentation-container .select-dropdown {
    overflow-y: visible !important;
    max-height: none !important;
}

.select-dropdown.show {
    display: block;
    z-index: 10100 !important; /* Ensure high z-index when shown - above all search results */
}

/* Force all dropdowns to appear above search results */
.segmentation-form .select-dropdown,
.simple-search .select-dropdown {
    z-index: 10100 !important;
}

.segmentation-form .custom-select,
.simple-search .custom-select {
    z-index: 10000 !important;
}

/* ===========================
   BRANCH DROPDOWN SPECIFIC
   =========================== */

/* Branch Mode Toggle (Bransjer/Formål) */
.branch-mode-toggle {
    display: flex;
    gap: 0;
    padding: 0.75rem;
    border-bottom: 1px solid var(--dashboard-border);
    background: var(--dashboard-white);
}

.mode-toggle-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    border: 1px solid var(--dashboard-border);
    background: var(--dashboard-white);
    color: var(--dashboard-text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.mode-toggle-btn:first-child {
    border-radius: 6px 0 0 6px;
}

.mode-toggle-btn:last-child {
    border-radius: 0 6px 6px 0;
    border-left: none;
}

.mode-toggle-btn:hover:not(.active) {
    background: var(--dashboard-hover);
    color: var(--primary);
}

.mode-toggle-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.branch-search {
    padding: 0.75rem;
    border-bottom: 1px solid var(--dashboard-border);
    background: var(--dashboard-hover);
}

.branch-search-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--dashboard-border);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--dashboard-white);
    color: var(--dashboard-text);
    outline: none;
    transition: var(--transition-fast);
}

.branch-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(95, 199, 62, 0.1);
}

.branch-results {
    max-height: 200px;
    overflow-y: auto;
    border-bottom: 1px solid var(--dashboard-border);
    position: relative;
    z-index: 10000; /* Force above everything */
}

/* Specific override for branch results container */
#branch-results-container-leadsynergy-segmentation {
    position: relative;
    z-index: 1000; /* Standard dropdown z-index */
}

.branch-placeholder,
.no-branch-results {
    padding: 1rem;
    text-align: center;
    color: var(--dashboard-text-light);
    font-size: 0.875rem;
    font-style: italic;
}

.branch-result-item {
    display: flex;
    align-items: flex-start;
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: all 0.2s ease;
}

.branch-result-item:last-child {
    border-bottom: none;
}

.branch-result-item:hover {
    background: var(--dashboard-hover);
}

.branch-result-item.selected {
    background: rgba(95, 199, 62, 0.1);
    border-left: 3px solid var(--primary);
}

.branch-result-content {
    flex: 1;
    text-align: left;
}

.branch-result-name {
    font-weight: 600;
    color: var(--dashboard-text);
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.branch-result-description {
    color: var(--dashboard-text-light);
    font-size: 0.8rem;
    line-height: 1.4;
    margin-bottom: 0.25rem;
}

.branch-result-codes {
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: monospace;
}

/* Search Highlight */
.search-highlight {
    background: rgba(95, 199, 62, 0.2);
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* Selected Branches */
.selected-branches {
    padding: 0.5rem 0;
    border-top: 1px solid var(--dashboard-border);
    background: #f8fafc;
    display: none;
}

.selected-branches:not(:empty) {
    display: block;
}

.selected-branch-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.75rem;
    margin: 0.25rem 0.5rem;
    background: var(--dashboard-white);
    border: 1px solid var(--dashboard-border);
    border-radius: 6px;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.selected-branch-item:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.selected-branch-name {
    font-weight: 600;
    color: var(--dashboard-text);
    margin-bottom: 0.125rem;
}

.selected-branch-codes {
    color: var(--primary);
    font-size: 0.7rem;
    font-family: monospace;
}

.selected-branch-remove {
    background: none;
    border: none;
    color: var(--dashboard-text-light);
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    line-height: 1;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.selected-branch-remove:hover {
    background: #ef4444;
    color: white;
    transform: scale(1.1);
}

/* ===========================
   LOCATION DROPDOWN SPECIFIC
   =========================== */

/* Ensure left alignment for location dropdown */
#location-select-leadsynergy-segmentation-container .select-text {
    text-align: left !important;
    justify-content: flex-start !important;
}

#location-select-leadsynergy-segmentation-container .select-display {
    text-align: left !important;
    justify-content: flex-start !important;
}

.location-search {
    padding: 0.75rem;
    border-bottom: 1px solid var(--dashboard-border);
    background: var(--dashboard-hover);
}

.location-search-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--dashboard-border);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--dashboard-white);
    color: var(--dashboard-text);
    outline: none;
    transition: var(--transition-fast);
}

.location-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(95, 199, 62, 0.1);
}

.location-tree {
    max-height: 250px;
    overflow-y: auto !important;
    padding: 0.5rem 0;
    position: relative;
    z-index: 10000; /* Force above everything */
}

/* Ensure location tree has proper scrolling */
#location-tree-container-leadsynergy-segmentation {
    max-height: 270px !important;
    overflow-y: auto !important;
    padding: 0.5rem 0;
    position: relative;
    z-index: 10000; /* Force above everything */
}

.loading-message {
    text-align: center;
    padding: 1rem;
    color: var(--dashboard-text-light);
    font-style: italic;
    font-size: 0.875rem;
}

/* Location tree styling - adapted from Prospektering */
.location-region {
    margin-bottom: 0.5rem;
    text-align: left !important;
}

/* Force left alignment for ALL location tree items */
#location-tree-container-leadsynergy-segmentation {
    text-align: left !important;
}

#location-tree-container-leadsynergy-segmentation .location-region {
    text-align: left !important;
}

#location-tree-container-leadsynergy-segmentation .region-header {
    text-align: left !important;
    justify-content: flex-start !important;
}

#location-tree-container-leadsynergy-segmentation .county-header {
    text-align: left !important;
    justify-content: flex-start !important;
}

#location-tree-container-leadsynergy-segmentation .municipality-item {
    text-align: left !important;
    justify-content: flex-start !important;
}

.region-header {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    background: var(--dashboard-hover);
    border-radius: 4px;
    margin: 0 0.5rem;
    transition: var(--transition-fast);
}

.region-header:hover {
    background: rgba(95, 199, 62, 0.1);
}

.region-header input[type="checkbox"] {
    margin-right: 0.5rem;
}

.region-header label {
    flex: 1;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--dashboard-text);
    cursor: pointer;
}

.expand-arrow {
    font-size: 0.75rem;
    color: var(--dashboard-text-light);
    transition: var(--transition-fast);
}

.region-header.expanded .expand-arrow,
.county-header.expanded .expand-arrow {
    transform: rotate(90deg);
}

/* Default arrows point right, expanded arrows point down */
.region-header .expand-arrow,
.county-header .expand-arrow {
    transform: rotate(0deg); /* Point right when collapsed */
}

.region-content {
    display: none;
    padding-left: 1rem;
}

.region-content.expanded {
    display: block;
}

.county-group {
    margin-bottom: 0.25rem;
}

.county-header {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    transition: var(--transition-fast);
    border-radius: 3px;
}

.county-header:hover {
    background: var(--dashboard-hover);
}

.county-header input[type="checkbox"] {
    margin-right: 0.5rem;
}

.county-header label {
    flex: 1;
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--dashboard-text);
    cursor: pointer;
}

.county-content {
    display: none;
    padding-left: 1rem;
}

.county-content.expanded {
    display: block;
}

.municipality-item {
    display: flex;
    align-items: center;
    padding: 0.3rem 0.5rem;
    transition: var(--transition-fast);
    border-radius: 3px;
}

.municipality-item:hover {
    background: var(--dashboard-hover);
}

.municipality-item input[type="checkbox"] {
    margin-right: 0.5rem;
}

.municipality-item label {
    flex: 1;
    font-size: 0.8rem;
    color: var(--dashboard-text);
    cursor: pointer;
}

/* ===========================
   COMPANY TYPE DROPDOWN SPECIFIC
   =========================== */

/* Ensure left alignment for company type dropdown */
#company-type-select-leadsynergy-segmentation-container .select-text {
    text-align: left !important;
    justify-content: flex-start !important;
}

#company-type-select-leadsynergy-segmentation-container .select-display {
    text-align: left !important;
    justify-content: flex-start !important;
}

.checkbox-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    transition: var(--transition-fast);
    cursor: pointer;
    text-align: left !important;
    justify-content: flex-start !important;
}

/* Force left alignment for ALL company type checkboxes */
#company-type-select-leadsynergy-segmentation-container .checkbox-item {
    text-align: left !important;
    justify-content: flex-start !important;
}

#company-type-select-leadsynergy-segmentation-container .checkbox-item label {
    text-align: left !important;
}

/* Ensure company type dropdown is tall enough to show all options including Kommuner and Annet */
#company-type-select-leadsynergy-segmentation-container .select-dropdown {
    max-height: 390px;
    overflow-y: auto;
}

.checkbox-item:hover {
    background: var(--dashboard-hover);
}

.checkbox-item input[type="checkbox"] {
    margin-right: 0.75rem;
    cursor: pointer;
}

.checkbox-item label {
    flex: 1;
    font-size: 0.875rem;
    color: var(--dashboard-text);
    cursor: pointer;
    line-height: 1.4;
}

/* ===========================
   SEGMENTATION PLACEHOLDER
   =========================== */

.segmentation-placeholder {
    text-align: center;
    padding: 2rem;
    color: var(--dashboard-text-light);
    font-style: italic;
}

.segmentation-placeholder p {
    margin: 0;
    font-size: 0.95rem;
}

/* ===========================
   RANGE FILTER INPUTS
   =========================== */

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--dashboard-text);
    margin-bottom: 0.5rem;
    text-align: left;
}

.range-inputs {
    display: flex;
    gap: 0.5rem;
    max-width: 280px; /* Wider for first two columns */
}

/* Smaller inputs for third column (Antall ansatte) */
.segmentation-row-2 .segmentation-group:nth-child(3) .range-inputs {
    max-width: 180px; /* Narrower for third column */
}

.range-input {
    flex: 1;
    padding: 0.5rem 0.75rem; /* Smaller padding */
    border: 1px solid var(--dashboard-border);
    border-radius: 7px;
    font-size: 0.875rem;
    background: var(--dashboard-white);
    color: var(--dashboard-text);
    outline: none;
    transition: var(--transition-fast);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-width: 0; /* Allow inputs to shrink */
    width: 100px; /* Wider inputs for first two columns */
}

/* Smaller inputs for third column */
.segmentation-row-2 .segmentation-group:nth-child(3) .range-input {
    width: 70px; /* Narrower inputs for third column */
}

.range-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(95, 199, 62, 0.1);
}

.range-input::placeholder {
    color: var(--dashboard-text-light);
    font-weight: 400;
}

/* ===========================
   CONTACT FILTERS
   =========================== */

.contact-filters {
    text-align: left;
    width: 100%;
    padding: 0;
    margin: 0;
    background: none;
    border: none;
    box-shadow: none;
}

.contact-filters-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--dashboard-text);
    margin-bottom: 1rem;
    text-align: left;
}

.contact-checkboxes {
    display: flex;
    justify-content: flex-start;
    gap: 2.5rem;
    flex-wrap: wrap;
}

.contact-checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}


.contact-checkbox {
    margin: 0;
    cursor: pointer;
    width: 18px;
    height: 18px;
    transform: scale(1.2);
    accent-color: var(--dashboard-text-light);
    border-radius: 3px;
}

.contact-checkbox-item label {
    font-size: 0.9rem;
    color: var(--dashboard-text-light);
    cursor: pointer;
    font-weight: 400;
    margin: 0;
    transition: var(--transition-fast);
    user-select: none;
}

/* CEO Email (Med daglig leder) disabled state and help icon */
.contact-checkbox-item.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.contact-checkbox-item.disabled .contact-checkbox {
    cursor: not-allowed;
    pointer-events: none;
}

.contact-checkbox-item.disabled label {
    cursor: not-allowed;
    color: #94a3b8;
}

.ceo-email-help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.25rem;
    cursor: pointer;
    color: #2196f3;
    font-size: 1rem;
    transition: all 0.2s ease;
    position: relative;
}

.ceo-email-help-icon:hover {
    color: #1976d2;
    transform: scale(1.1);
}

.ceo-email-help-icon i {
    filter: drop-shadow(0 1px 2px rgba(33, 150, 243, 0.2));
}

/* CEO Email Premium Popup */
.ceo-email-premium-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10040;
    animation: fadeIn 0.3s ease;
    padding: 1rem;
}

.ceo-email-premium-popup {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: slideUpBounce 0.4s ease;
    overflow: hidden;
}

.ceo-email-premium-body {
    text-align: center;
    padding: 2rem;
}

.ceo-email-premium-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.ceo-email-premium-title {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.ceo-email-premium-text {
    color: #666;
    margin-bottom: 1.5rem;
    line-height: 1.6;
    font-size: 1rem;
}

.ceo-email-premium-contact {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #666;
    line-height: 1.6;
}

.ceo-email-premium-contact a {
    color: var(--primary, #5fc73e);
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.ceo-email-premium-contact a:hover {
    color: #4ab02f;
    text-decoration: underline;
}

.ceo-email-premium-actions {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

.ceo-email-premium-btn {
    padding: 0.875rem 2rem;
    background: linear-gradient(135deg, #5fc73e 0%, #4ab02f 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(95, 199, 62, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.ceo-email-premium-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(95, 199, 62, 0.4);
}

.ceo-email-premium-btn:active {
    transform: translateY(0);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUpBounce {
    0% {
        transform: translateY(30px);
        opacity: 0;
    }
    60% {
        transform: translateY(-5px);
        opacity: 1;
    }
    100% {
        transform: translateY(0);
    }
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .ceo-email-premium-popup {
        margin: 1rem;
        border-radius: 12px;
    }
    
    .ceo-email-premium-body {
        padding: 1.5rem;
    }
    
    .ceo-email-premium-icon {
        font-size: 2.5rem;
    }
    
    .ceo-email-premium-title {
        font-size: 1.25rem;
    }
    
    .ceo-email-premium-text {
        font-size: 0.95rem;
    }
}

/* AI Suggestion Container and Button */
.ai-suggestion-container {
    position: relative;
    margin-left: auto; /* Push to the right */
}

.ai-suggestion-btn {
    background: linear-gradient(135deg, rgba(95, 199, 62, 0.1) 0%, rgba(95, 199, 62, 0.05) 100%);
    border: 1px solid rgba(95, 199, 62, 0.3);
    color: var(--primary);
    padding: 0.5rem 0.875rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0.9;
    min-width: auto;
    height: auto;
    white-space: nowrap;
}

.ai-suggestion-btn:hover {
    background: linear-gradient(135deg, rgba(95, 199, 62, 0.15) 0%, rgba(95, 199, 62, 0.1) 100%);
    border-color: var(--primary);
    color: var(--primary-dark);
    opacity: 1;
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(95, 199, 62, 0.25);
}

.ai-suggestion-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(95, 199, 62, 0.2);
}

/* AI button text and icon styling */
.ai-suggestion-btn .ai-btn-text {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1;
}

.ai-suggestion-btn i {
    font-size: 0.9rem;
    opacity: 0.9;
}

.ai-suggestion-btn:hover i {
    opacity: 1;
    animation: sparkle 0.6s ease-in-out;
}

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(-5deg); }
    75% { transform: scale(1.1) rotate(5deg); }
}

/* Enhanced AI Input Box */
.ai-input-box {
    position: absolute;
    bottom: 37px; /* 5px above the button (32px height + 5px) */
    right: 0;
    background: var(--dashboard-white);
    border: 1px solid var(--dashboard-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 1rem;
    z-index: 10000;
    display: none;
    min-width: 350px;
    max-width: 400px;
}

.ai-input-box.show {
    display: block;
}

/* URL wrapper for input and button */
.ai-input-box .ai-url-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
    margin-bottom: 0.75rem;
}

/* URL input styling */
.ai-input-box .ai-url-input {
    flex: 1;
    border: 1px solid var(--dashboard-border);
    border-radius: 6px;
    padding: 0.625rem 0.75rem;
    font-size: 0.8rem;
    color: var(--dashboard-text);
    background: var(--dashboard-white);
    transition: var(--transition-fast);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ai-input-box .ai-url-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(95, 199, 62, 0.1);
}

.ai-input-box .ai-url-input::placeholder {
    color: var(--dashboard-text-light);
}

/* Next button in AI input box */
.ai-input-box .ai-next-btn {
    background: var(--primary-gradient);
    border: none;
    color: white;
    padding: 0.625rem 0.875rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.375rem;
    white-space: nowrap;
    font-family: inherit;
    min-width: 75px;
    justify-content: center;
}

/* Active/enabled state - make it clearly green and prominent */
.ai-input-box .ai-next-btn:not(:disabled):not(.disabled) {
    background: var(--primary-gradient);
    color: white;
    opacity: 1;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(95, 199, 62, 0.25);
}

.ai-input-box .ai-next-btn:hover:not(:disabled):not(.disabled) {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #3a8b22 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(95, 199, 62, 0.4);
}

.ai-input-box .ai-next-btn:active:not(:disabled):not(.disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(95, 199, 62, 0.3);
}

/* Disabled state - clearly inactive */
.ai-input-box .ai-next-btn:disabled,
.ai-input-box .ai-next-btn.disabled {
    background: var(--dashboard-text-light) !important;
    color: rgba(255, 255, 255, 0.7) !important;
    cursor: not-allowed !important;
    opacity: 0.5 !important;
    transform: none !important;
    box-shadow: none !important;
}

.ai-input-box .ai-next-btn .btn-icon {
    font-size: 0.7rem;
    transition: var(--transition-fast);
}

.ai-input-box .ai-next-btn:hover:not(:disabled) .btn-icon {
    transform: translateX(1px);
}

/* Status container */
.ai-input-box .ai-status-container {
    position: relative;
    min-height: 1.75rem;
}

.ai-input-box .ai-status,
.ai-input-box .ai-loading {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.625rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    transition: var(--transition-fast);
    line-height: 1.3;
}

/* Status states for embedded box */
.ai-input-box .ai-status.status-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--dashboard-text-light);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.ai-input-box .ai-status.status-success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.ai-input-box .ai-status.status-error {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.ai-input-box .ai-status.status-typing {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Loading state for embedded box */
.ai-input-box .ai-loading {
    background: var(--dashboard-hover);
    color: var(--dashboard-text-light);
    border: 1px solid var(--dashboard-border);
}

.ai-input-box .ai-loading i {
    animation: spin 1s linear infinite;
}

/* Responsive adjustments for AI button and embedded AI box */
@media (max-width: 768px) {
    .ai-suggestion-btn {
        padding: 0.375rem 0.625rem;
        font-size: 0.75rem;
        gap: 0.375rem;
    }
    
    .ai-suggestion-btn .ai-btn-text {
        font-size: 0.75rem;
    }
    
    .ai-suggestion-btn i {
        font-size: 0.8rem;
    }
    
    .ai-input-box {
        min-width: 300px;
        max-width: 320px;
        right: -20px; /* Adjust position on mobile */
    }
    
    .ai-input-box .ai-url-wrapper {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .ai-input-box .ai-next-btn {
        width: 100%;
    }
    
    .ai-input-box .ai-url-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (max-width: 480px) {
    .ai-suggestion-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
        gap: 0.25rem;
    }
    
    .ai-suggestion-btn .ai-btn-text {
        font-size: 0.7rem;
    }
    
    .ai-suggestion-btn i {
        font-size: 0.75rem;
    }
    
    .ai-input-box {
        min-width: 280px;
        max-width: 300px;
        right: -30px;
        left: auto;
    }
}


/* ===========================
   SIMPLE SEARCH BRANCH DROPDOWN STYLING
   =========================== */

/* Override custom-select styling for simple search */
#branch-select-simple-search-container.custom-select {
    background: var(--dashboard-hover); /* Gray background like original */
    border: none;
    border-left: 1px solid var(--dashboard-border);
    border-radius: 0; /* No border radius for middle element */
    box-shadow: none;
    z-index: 10000; /* High z-index like other dropdowns */
    flex: 1; /* 35% proportion (remaining space) */
    min-width: 0; /* Allow shrinking */
}

#branch-select-simple-search-container.custom-select:hover {
    background: var(--dashboard-hover);
    border-left: 1px solid var(--dashboard-border);
    box-shadow: none;
    transform: none;
}

#branch-select-simple-search-container .select-display {
    padding: 0.875rem 3rem 0.875rem 1.5rem; /* Match original branch-select padding */
    background: transparent;
    border: none;
    border-radius: 0;
    font-size: 1rem;
    font-weight: 500;
    min-height: auto;
}

#branch-select-simple-search-container .dropdown-arrow {
    position: absolute;
    right: 1rem;
    color: var(--dashboard-text-light);
    font-size: 0.8rem;
}

#branch-select-simple-search-container:hover .dropdown-arrow {
    color: var(--primary);
    transform: scale(1.1);
}

/* Simple search dropdown positioning */
#branch-select-simple-search-container .select-dropdown {
    width: 340px; /* Wider dropdown like smart dropdown */
    right: 0;
    left: auto;
    z-index: 10100; /* Ensure high z-index above search results */
}

/* ===========================
   ACTION BUTTONS
   =========================== */

.segmentation-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Align to top instead of center */
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--dashboard-border);
}

.live-count-display {
    flex: 1;
    text-align: left; /* Left align the count display */
}

.live-count-display span {
    font-size: 0.875rem;
    color: var(--dashboard-text-light);
    font-weight: 500;
    display: block;
    text-align: left;
}

.action-buttons {
    display: flex;
    gap: 1rem;
}

.clear-btn {
    background: transparent;
    border: 1px solid var(--dashboard-border);
    color: var(--dashboard-text);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.clear-btn:hover {
    background: var(--dashboard-hover);
    border-color: var(--dashboard-text-light);
}

.search-btn {
    background: var(--primary-gradient);
    border: none;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0 15px 15px 0;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.search-btn:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #3a8b22 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(95, 199, 62, 0.3);
}

.search-btn:active {
    transform: translateY(0);
}

.search-btn:disabled {
    background: var(--dashboard-text-light);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ===========================
   RESPONSIVE DESIGN
   =========================== */

@media (max-width: 992px) {
 
    
    .segmentation-group {
        max-width: 100%;
    }
    
    .contact-checkboxes {
        gap: 1.5rem;
    }
    
    .range-inputs {
        max-width: 240px;
    }
    
    .segmentation-row-2 .segmentation-group:nth-child(3) .range-inputs {
        max-width: 160px;
    }
    
    .segmentation-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .action-buttons {
        justify-content: center;
    }

    /* Make segmentation search button match simple search button on mobile */
    #segmentation-search-btn {
        width: 100%;
        border-radius: 16px;
        min-height: 45px;
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    .segmentation-form {
        padding: 1rem 0;
    }
    
    .segmentation-row {
        margin-bottom: 1rem;
        width: 100%;
    }
    
    /* Put the three dropdowns on one row for mobile */
    .segmentation-row:first-child {
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
        margin-bottom: 1.5rem;
    }
    
    /* Stack segmentation groups vertically on mobile for row-2 */
    .segmentation-row-2 {
        flex-direction: column;
        gap: 1rem;
    }
    
    .segmentation-row:first-child .segmentation-group {
        flex: 1;
        min-width: 0; /* Allow shrinking */
        width: 100%;
    }
    
    /* Make all segmentation groups use full width on mobile */
    .segmentation-group {
        width: 100%;
        max-width: none; /* Remove max-width restrictions */
        flex: 1;
    }
    
    /* Override specific row 2 width restrictions on mobile */
    .segmentation-row-2 .segmentation-group:nth-child(1),
    .segmentation-row-2 .segmentation-group:nth-child(2),
    .segmentation-row-2 .segmentation-group:nth-child(3) {
        max-width: none;
        flex: 1;
    }
    
    /* Shorter button text for mobile */
    #branch-select-leadsynergy-segmentation-container .select-text:not(:empty) {
        font-size: 0;
    }
    
    #branch-select-leadsynergy-segmentation-container .select-text:not(:empty)::after {
        content: "Bransjer";
        font-size: 0.8rem;
    }
    
    #location-select-leadsynergy-segmentation-container .select-text:not(:empty) {
        font-size: 0;
    }
    
    #location-select-leadsynergy-segmentation-container .select-text:not(:empty)::after {
        content: "Områder";
        font-size: 0.8rem;
    }
    
    #company-type-select-leadsynergy-segmentation-container .select-text:not(:empty) {
        font-size: 0;
    }
    
    #company-type-select-leadsynergy-segmentation-container .select-text:not(:empty)::after {
        content: "Type";
        font-size: 0.8rem;
    }
    
    .select-display {
        padding: 0.625rem 0.875rem;
        font-size: 0.8rem;
    }
    
    .filter-label {
        font-size: 0.8rem;
        margin-bottom: 0.4rem;
    }
    
    .range-input {
        padding: 0.375rem 0.5rem;
        font-size: 0.9rem;
        width: calc(50% - 0.25rem);
        min-height: 38px;
        flex: 1;
    }
    
    .segmentation-row-2 .segmentation-group:nth-child(3) .range-input {
        width: calc(50% - 0.25rem);
        flex: 1;
    }
    
    .range-inputs {
        display: flex;
        width: 100%;
        max-width: 100%;
        gap: 0.5rem;
    }
    
    .segmentation-row-2 .segmentation-group:nth-child(3) .range-inputs {
        max-width: 100%;
    }
    
    .contact-checkboxes {
        flex-direction: row;
        gap: 1rem;
        align-items: center;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    
    .contact-checkbox-item {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        min-width: fit-content;
    }
    
    .contact-checkbox {
        width: 20px;
        height: 20px;
        transform: scale(1.3);
    }
    
    .contact-checkbox-item label {
        font-size: 0.9rem;
        font-weight: 600;
        white-space: nowrap;
    }
    
    
    .contact-filters-label {
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
    }
    
    .branch-search-input,
    .location-search-input {
        padding: 0.4rem;
        font-size: 0.8rem;
    }
    
    .branch-result-item,
    .checkbox-item {
        padding: 0.5rem;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .clear-btn,
    .search-btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.8rem;
    }
    
    /* Make segmentation search button match simple search button on mobile */
    #segmentation-search-btn {
        width: 100%;
        border-radius: 16px;
        min-height: 45px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .segmentation-form {
        padding: 0.75rem 0;
    }
    
    .select-display {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        min-height: 40px;
    }
    
    /* Stack segmentation groups vertically on mobile for row-2 */
    .segmentation-row-2 {
        flex-direction: column;
        gap: 1rem;
    }
    
    /* Make range inputs compact on very small screens */
    .range-input {
        padding: 0.25rem 0.375rem;
        font-size: 0.85rem;
        width: calc(50% - 0.25rem);
        min-height: 36px;
        flex: 1;
    }
    
    .segmentation-row-2 .segmentation-group:nth-child(3) .range-input {
        width: calc(50% - 0.25rem);
        flex: 1;
    }
    
    .range-inputs {
        display: flex;
        width: 100%;
        max-width: 100%;
        gap: 0.5rem;
    }
    
    .segmentation-row-2 .segmentation-group:nth-child(3) .range-inputs {
        max-width: 100%;
    }
    
    /* Ensure three dropdowns still fit on small screens */
    .segmentation-row:first-child {
        gap: 0.25rem;
    }
    
    /* Make sure all segmentation groups use full width on very small screens */
    .segmentation-group {
        width: 100%;
        max-width: none; /* Remove all max-width restrictions */
        flex: 1;
    }
    
    /* Override specific row 2 width restrictions on very small screens */
    .segmentation-row-2 .segmentation-group:nth-child(1),
    .segmentation-row-2 .segmentation-group:nth-child(2),
    .segmentation-row-2 .segmentation-group:nth-child(3) {
        max-width: none;
        flex: 1;
    }
    
    /* Adjust contact checkboxes for very small screens */
    .contact-checkboxes {
        gap: 0.75rem;
    }
    
    .contact-checkbox-item label {
        font-size: 0.8rem;
    }
    
    .segmentation-label {
        font-size: 0.75rem;
    }
    
    .select-dropdown {
        max-height: 250px;
    }
    
    .location-tree {
        max-height: 200px;
    }
    
    .branch-results {
        max-height: 150px;
    }
    
    /* Make segmentation search button match simple search button on small mobile */
    #segmentation-search-btn {
        width: 100%;
        border-radius: 16px;
        min-height: 42px;
        font-size: 1rem;
    }
}

/* ===========================
   ACCESSIBILITY
   =========================== */

@media (prefers-reduced-motion: reduce) {
    .select-display,
    .select-arrow,
    .branch-result-item,
    .checkbox-item,
    .region-header,
    .county-header,
    .municipality-item,
    .selected-branch-remove,
    .clear-btn,
    .search-btn {
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: high) {
    .select-display {
        border: 2px solid var(--dashboard-border);
    }
    
    .select-display.active {
        border: 2px solid var(--primary);
    }
    
    .select-dropdown {
        border: 2px solid var(--primary);
    }
}

/* Custom scrollbar for dropdown containers */
.select-dropdown::-webkit-scrollbar,
.branch-results::-webkit-scrollbar,
.location-tree::-webkit-scrollbar {
    width: 6px;
}

.select-dropdown::-webkit-scrollbar-track,
.branch-results::-webkit-scrollbar-track,
.location-tree::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.select-dropdown::-webkit-scrollbar-thumb,
.branch-results::-webkit-scrollbar-thumb,
.location-tree::-webkit-scrollbar-thumb {
    background: var(--dashboard-text-light);
    border-radius: 3px;
}

.select-dropdown::-webkit-scrollbar-thumb:hover,
.branch-results::-webkit-scrollbar-thumb:hover,
.location-tree::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}