/* ===========================
   STANDALONE FORMS CSS
   =========================== 
   
   This file contains all form-related styles for the standalone company search page.
   Extracted from standalone.css to follow CSS organization best practices.
   Built on top of General_Main.css design patterns and variables.
*/

/* 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;
}

/* ===========================
   SEARCH TOGGLE
   =========================== */

.search-toggle {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 2rem;
    background: rgba(148, 163, 184, 0.1);
    padding: 0.5rem;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.toggle-btn {
    background: transparent;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    color: var(--dashboard-text-light);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.toggle-btn:hover {
    background: rgba(148, 163, 184, 0.15);
    color: var(--dashboard-text);
}

.toggle-btn.active {
    background: var(--dashboard-white);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

/* ===========================
   AUTOCOMPLETE COMPONENT
   =========================== */

/* Autocomplete styling - based on general_forms.css for consistency */
.autocomplete-container {
    position: relative;
    flex: 1.857; /* 65% proportion to match search-input */
    z-index: 10000; /* Ensure autocomplete container is above all other elements */
    display: flex;
    align-items: center;
}

/* Search mode icons */
.search-mode-icons {
    position: absolute;
    left: 2px; /* Reduced from 4px to compensate for larger icons */
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column; /* Stack vertically - company over person */
    gap: 1px; /* Reduced gap between icons from 2px to 1px */
    z-index: 2;
}

.search-mode-icon {
    width: 26px; /* Increased from 20px to 26px */
    height: 26px; /* Increased from 20px to 26px */
    padding: 0;
    border: none;
    background: none;
    color: #94a3b8; /* Light gray for inactive */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 16px; /* Increased from 12px to 16px */
    position: relative; /* Added for individual positioning */
}

/* Adjust company icon position - move 2px down */
.search-mode-icon[data-mode="company"] {
    top: 2px;
}

/* Adjust person icon position - move 3px up */
.search-mode-icon[data-mode="person"] {
    top: -3px;
}

.search-mode-icon:hover {
    color: #64748b; /* Slightly darker on hover */
}

.search-mode-icon.active {
    color: #334155; /* Dark gray for active */
}

.search-mode-icon i {
    font-size: 16px; /* Increased from 12px to 16px */
    pointer-events: none; /* Prevent icon from capturing clicks */
}

.autocomplete-input {
    width: 100%;
    padding-right: 2.5rem; /* Space for loading indicator */
    padding-left: 37px; /* Adjusted: Icons area (2px + 26px) + spacing (6px) + 3px extra = 37px */
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--dashboard-white, #ffffff);
    border: 2px solid var(--primary, #5fc73e);
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    z-index: 10001; /* Much higher to ensure it's above everything */
    max-height: 300px;
    overflow-y: auto;
    display: none;
    margin-top: 1px; /* Small gap to avoid border overlap */
}

.autocomplete-dropdown.show {
    display: block;
}

/* Specific styling for company search dropdown to ensure it's always on top */
#company-search-dropdown {
    z-index: 10001 !important; /* Force higher z-index for company search dropdown */
    position: absolute !important;
}

.autocomplete-item {
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--dashboard-border, #e2e8f0);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    text-align: left;
    align-items: flex-start;
}

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

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--dashboard-hover, #f1f5f9);
    color: var(--primary, #5fc73e);
}

.autocomplete-item.highlighted {
    background: var(--primary, #5fc73e);
    color: white;
}

/* Special styling for brregUnderEnheter items - slightly different background */
.autocomplete-item-underenhet {
    background: #f8f9fb; /* Very light blue-gray background */
}

.autocomplete-item-underenhet:hover,
.autocomplete-item-underenhet.selected {
    background: #e8edf3; /* Slightly darker blue-gray on hover */
    color: var(--primary, #5fc73e);
}

.autocomplete-item-underenhet.highlighted {
    background: var(--primary, #5fc73e);
    color: white;
}

.autocomplete-item-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 100%;
}

.autocomplete-item-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: inherit;
    flex: 1;
    text-align: left;
}

.autocomplete-item-employees {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--dashboard-text-light, #64748b);
}

.autocomplete-item.highlighted .autocomplete-item-employees {
    color: rgba(255, 255, 255, 0.8);
}

.autocomplete-item-address {
    font-size: 0.875rem;
    color: var(--dashboard-text, #334155);
    line-height: 1.3;
    text-align: left;
    width: 100%;
}

.autocomplete-item.highlighted .autocomplete-item-address {
    color: rgba(255, 255, 255, 0.9);
}

.autocomplete-item-location {
    font-size: 0.875rem;
    color: var(--dashboard-text, #334155);
    font-weight: 500;
    text-align: left;
    width: 100%;
}

.autocomplete-item.highlighted .autocomplete-item-location {
    color: rgba(255, 255, 255, 0.9);
}

.autocomplete-item-org {
    font-size: 0.8rem;
    color: var(--dashboard-text-light, #64748b);
    font-family: 'Courier New', monospace;
    margin-top: 0.25rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--dashboard-border, #e2e8f0);
    text-align: left;
    width: 100%;
}

.autocomplete-item.highlighted .autocomplete-item-org {
    color: rgba(255, 255, 255, 0.7);
    border-top-color: rgba(255, 255, 255, 0.3);
}

.autocomplete-loading {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.875rem;
    color: var(--dashboard-text-light, #64748b);
    display: none;
    pointer-events: none;
}

.autocomplete-loading.show {
    display: block;
}

.autocomplete-search-info {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--dashboard-text-light, #64748b);
    display: none;
    pointer-events: none;
    background: var(--dashboard-white, #ffffff);
    padding: 0.15rem 0.3rem;
    border-radius: 4px;
    white-space: nowrap;
}

.autocomplete-search-info.show {
    display: block;
}

.autocomplete-no-results {
    padding: 1rem 1.25rem;
    color: var(--dashboard-text-light, #64748b);
    text-align: left;
    font-style: italic;
}

/* Custom scrollbar for autocomplete dropdown */
.autocomplete-dropdown::-webkit-scrollbar {
    width: 6px;
}

.autocomplete-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: var(--dashboard-text-light, #64748b);
    border-radius: 3px;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--primary, #5fc73e);
}

/* ===========================
   SEARCH FORM
   =========================== */

.search-form {
    margin-top: 1rem;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: stretch;
    background: var(--dashboard-white);
    border-radius: 16px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    overflow: visible; /* Changed from hidden to visible for autocomplete dropdown */
    transition: var(--transition);
    border: 1px solid #4ab02f;
}

.search-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 8px 25px rgba(95, 199, 62, 0.2);
    transform: translateY(-2px);
}

.search-input {
    flex: 1.857; /* 65% proportion (65/35 = 1.857) */
    padding: 0.875rem 1.5rem 0.875rem 37px; /* Adjusted left padding to move placeholder text */
    border: none;
    background: transparent;
    font-size: 1rem;
    font-weight: 400;
    color: var(--dashboard-text);
    outline: none;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border-radius: 16px 0 0 16px; /* Round corners on the left side only */
}

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

/* ===========================
   DROPDOWN STYLING
   =========================== */

.search-dropdown-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 200px;
    border-left: 1px solid var(--dashboard-border);
    border-radius: 0; /* No border radius for middle element */
    background: var(--dashboard-hover);
}

.branch-select {
    appearance: none;
    background: transparent;
    border: none;
    padding: 0.875rem 3rem 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--dashboard-text);
    cursor: pointer;
    outline: none;
    width: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    pointer-events: none;
}

.branch-select:focus {
    color: var(--primary);
}

.dropdown-arrow {
    position: absolute;
    right: 1rem;
    color: var(--dashboard-text-light);
    font-size: 0.8rem;
    pointer-events: none;
    transition: var(--transition-fast);
}

.search-dropdown-wrapper:hover .dropdown-arrow {
    color: var(--primary);
    transform: scale(1.1);
}

/* ===========================
   SEARCH BUTTON
   =========================== */

.search-btn {
    background: var(--primary-gradient);
    border: none;
    padding: 0.875rem 1.75rem;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 70px;
    border-radius: 0 16px 16px 0; /* Round corners on the right side only */
}

.search-btn:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #3a8b22 100%);
    transform: scale(1.05);
}

.search-btn:active {
    transform: scale(0.98);
}

.search-btn:disabled,
.search-btn.disabled {
    background: var(--dashboard-text-light, #64748b) !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
    transform: none !important;
}

.search-btn:disabled:hover,
.search-btn.disabled:hover {
    background: var(--dashboard-text-light, #64748b) !important;
    transform: none !important;
}

.search-btn i {
    font-size: 1rem;
}

/* ===========================
   BRANCH SMART DROPDOWN
   =========================== 
   
   Smart dropdown functionality for branch selection
   Based on industry-select from Prospektering system
*/

.branch-smart-dropdown {
    position: absolute;
    width: 340px;
    background: var(--dashboard-white);
    border: 1px solid var(--dashboard-border);
    border-radius: 8px;
    box-shadow: var(--shadow-light);
    z-index: 10002; /* Higher than autocomplete dropdown to avoid conflicts */
    max-height: 400px;
    overflow: hidden;
    top: 0;
    right: 0;
}

/* Branch Search Input */
.branch-search {
    padding: 10px 15px;
    border-bottom: 1px solid var(--dashboard-border);
    background: var(--dashboard-hover);
}

.branch-search-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--dashboard-border);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--dashboard-white);
    color: var(--dashboard-text);
    outline: none;
    transition: var(--transition-fast);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

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

/* Branch Results */
.branch-results {
    max-height: 200px;
    overflow-y: auto;
    border-bottom: 1px solid var(--dashboard-border);
}

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

.branch-result-item {
    display: flex;
    align-items: flex-start;
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: all 0.3s 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.9rem;
}

.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.75rem 0;
    border-top: 1px solid var(--dashboard-border);
    background: #f8fafc;
    display: none;
}

.selected-branches:empty {
    display: none;
}

.selected-branch-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    margin: 0.25rem 0.75rem;
    background: var(--dashboard-white);
    border: 1px solid var(--dashboard-border);
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.3s 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.25rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-size: 1rem;
    line-height: 1;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

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

/* ===========================
   RESPONSIVE FORM STYLES
   =========================== */

@media (max-width: 992px) {
    .search-input-wrapper {
        flex-direction: column;
        border-radius: 12px;
    }
    
    .search-input {
        padding: 0.75rem 1.25rem 0.75rem 37px; /* Maintain left padding for placeholder */
        font-size: 0.95rem;
        border-bottom: 1px solid var(--dashboard-border);
    }
    
    .search-dropdown-wrapper {
        border-left: none;
        border-bottom: 1px solid var(--dashboard-border);
        min-width: auto;
    }
    
    .branch-select {
        padding: 0.75rem 3rem 0.75rem 1.25rem;
        font-size: 0.95rem;
    }
    
    .search-btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
        border-radius: 0;
    }
}

@media (max-width: 768px) {
    .search-toggle {
        flex-direction: row;
        gap: 0.5rem;
        justify-content: center;
        margin-bottom: 1rem; /* Reduce spacing on mobile */
    }
    
    .toggle-btn {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
        justify-content: center;
        flex: 1;
        max-width: 200px;
    }
    
    /* Fix search wrapper border on mobile - remove border from wrapper and add gap */
    .search-input-wrapper {
        border: none;
        box-shadow: none;
        background: transparent;
        gap: 8px;
    }
    
    .search-input-wrapper:focus-within {
        border: none;
        box-shadow: none;
        transform: none;
    }
    
    .search-input {
        padding: 0.75rem 1rem 0.75rem 37px; /* Maintain left padding for placeholder */
        font-size: 1.1rem;
        min-height: 45px;
        border: 1px solid #4ab02f;
        border-radius: 16px;
        background: var(--dashboard-white);
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    }
    
    .search-input:focus {
        border-color: var(--primary);
        box-shadow: 0 8px 25px rgba(95, 199, 62, 0.2);
        transform: translateY(-2px);
    }
    
    /* Hide branch selection in simple search on mobile */
    #simple-search #branch-select-simple-search-container {
        display: none;
    }
    
    .branch-select {
        padding: 0.625rem 2.5rem 0.625rem 1rem;
        font-size: 0.9rem;
    }
    
    .search-btn {
        padding: 0.625rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Make simple search icon button match search-input width on mobile */
    #simple-search .search-btn {
        width: 100%;
        max-width: 100%;
        border-radius: 16px;
        min-height: 45px;
    }
    
    .branch-smart-dropdown {
        width: 100% !important;
        max-width: 700px !important;
        max-height: 50vh;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
    }
    
    .branch-result-item {
        padding: 0.5rem;
    }
    
    .selected-branch-item {
        margin: 0.25rem 0.5rem;
        padding: 0.4rem 0.75rem;
    }
}

@media (max-width: 480px) {
    /* Fix search wrapper border on small mobile - remove border from wrapper and add gap */
    .search-input-wrapper {
        border: none;
        box-shadow: none;
        background: transparent;
        gap: 8px;
    }
    
    .search-input-wrapper:focus-within {
        border: none;
        box-shadow: none;
        transform: none;
    }
    
    .search-input {
        padding: 0.625rem 0.875rem 0.625rem 37px; /* Maintain left padding for placeholder */
        font-size: 1.2rem;
        min-height: 42px;
        border: 1px solid #4ab02f;
        border-radius: 16px;
        background: var(--dashboard-white);
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    }
    
    .search-input:focus {
        border-color: var(--primary);
        box-shadow: 0 8px 25px rgba(95, 199, 62, 0.2);
        transform: translateY(-2px);
    }
    
    .search-input::placeholder {
        font-size: 1rem;
    }
    
    .search-toggle {
        margin-bottom: 0.75rem; /* Even less spacing on very small screens */
    }
    
    .toggle-btn {
        font-size: 0.9rem;
        padding: 0.875rem 0.5rem;
    }
    
    .branch-select {
        padding: 0.5rem 2rem 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .search-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.85rem;
    }
    
    /* Make simple search icon button match search-input width on small mobile */
    #simple-search .search-btn {
        width: 100%;
        max-width: 100%;
        border-radius: 16px;
        min-height: 42px;
    }
    
    .toggle-btn {
        font-size: 0.8rem;
        padding: 0.625rem 0.75rem;
    }
}

/* ===========================
   READ-ONLY FORM INPUTS
   =========================== */

.form-input-readonly {
    background-color: var(--dashboard-hover, #f1f5f9) !important;
    color: var(--dashboard-text-light, #64748b) !important;
    border-color: var(--dashboard-border, #e2e8f0) !important;
    cursor: not-allowed !important;
    opacity: 0.8;
    transition: border-color 0.3s ease, color 0.3s ease;
}

.form-input-readonly:hover {
    background-color: var(--dashboard-hover, #f1f5f9) !important;
    border-color: var(--dashboard-border, #e2e8f0) !important;
    transform: none !important;
}

.form-input-readonly:focus {
    background-color: var(--dashboard-hover, #f1f5f9) !important;
    border-color: var(--dashboard-border, #e2e8f0) !important;
    box-shadow: none !important;
    transform: none !important;
    outline: none !important;
}

/* ===========================
   ACCESSIBILITY FOR FORMS
   =========================== */

@media (prefers-reduced-motion: reduce) {
    .search-input-wrapper,
    .toggle-btn,
    .search-btn,
    .branch-result-item,
    .selected-branch-item,
    .selected-branch-remove,
    .branch-search-input,
    .dropdown-arrow {
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: high) {
    .toggle-btn {
        border: 1px solid rgba(255, 255, 255, 0.5);
    }
    
    .toggle-btn.active {
        border: 2px solid var(--primary);
    }
    
    .search-input-wrapper {
        border: 2px solid var(--primary);
    }
    
    .branch-smart-dropdown {
        border: 2px solid var(--primary);
    }
}