/**
 * Business Registry Autocomplete Styles
 */

/* Input wrapper styles */
.hccp-company-field .hccp-input-wrapper {
    position: relative;
}

.hccp-company-search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--hccp-text-muted, #94a3b8);
    pointer-events: none;
    transition: color 0.2s ease;
}

.hccp-company-field input:focus + .hccp-company-search-icon,
.hccp-company-field .hccp-input-wrapper:focus-within .hccp-company-search-icon {
    color: var(--hccp-accent, #00796b);
}

/* Dropdown container */
.hccp-company-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: var(--hccp-card-bg, #fff);
    border: 1px solid var(--hccp-border, rgba(226, 232, 240, 0.8));
    border-radius: 12px;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.08),
        0 4px 12px rgba(0, 0, 0, 0.04);
    z-index: 1000;
    max-height: 360px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--hccp-border, #e2e8f0) transparent;
}

.hccp-company-dropdown::-webkit-scrollbar {
    width: 6px;
}

.hccp-company-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.hccp-company-dropdown::-webkit-scrollbar-thumb {
    background: var(--hccp-border, #e2e8f0);
    border-radius: 3px;
}

/* Company list */
.hccp-company-list {
    list-style: none;
    margin: 0;
    padding: 6px;
}

/* Company item */
.hccp-company-item {
    padding: 12px 14px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.hccp-company-item:hover,
.hccp-company-item.selected {
    background: var(--hccp-hover-bg, rgba(0, 121, 107, 0.04));
    border-color: var(--hccp-accent-light, rgba(0, 121, 107, 0.1));
}

.hccp-company-item.selected {
    background: var(--hccp-hover-bg, rgba(0, 121, 107, 0.08));
}

/* Company main line */
.hccp-company-main {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.hccp-company-name {
    font-weight: 600;
    color: var(--hccp-text-primary, #1e293b);
    font-size: 0.9375rem;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hccp-company-form {
    font-size: 0.75rem;
    color: var(--hccp-text-muted, #94a3b8);
    background: var(--hccp-bg-subtle, #f1f5f9);
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Company meta line */
.hccp-company-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8125rem;
}

.hccp-company-code {
    color: var(--hccp-text-muted, #64748b);
    font-family: ui-monospace, monospace;
    font-size: 0.75rem;
}

.hccp-company-status {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 12px;
}

.hccp-company-status.status-success {
    color: #047857;
    background: rgba(4, 120, 87, 0.1);
}

.hccp-company-status.status-warning {
    color: #d97706;
    background: rgba(217, 119, 6, 0.1);
}

.hccp-company-status.status-error {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}

.hccp-company-status.status-muted {
    color: var(--hccp-text-muted, #94a3b8);
    background: var(--hccp-bg-subtle, #f1f5f9);
}

/* Company address */
.hccp-company-address {
    font-size: 0.75rem;
    color: var(--hccp-text-muted, #64748b);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Historical names */
.hccp-company-history {
    font-size: 0.6875rem;
    color: var(--hccp-text-muted, #94a3b8);
    margin-top: 4px;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Loading state */
.hccp-company-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    color: var(--hccp-text-muted, #64748b);
    font-size: 0.875rem;
}

.hccp-company-loading svg {
    animation: hccp-spin 1s linear infinite;
}

@keyframes hccp-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* No results */
.hccp-company-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    color: var(--hccp-text-muted, #94a3b8);
}

.hccp-company-empty svg {
    margin-bottom: 8px;
    opacity: 0.5;
}

.hccp-company-empty span {
    font-size: 0.875rem;
}

/* Error state */
.hccp-company-error {
    padding: 16px 24px;
    text-align: center;
    color: #dc2626;
    font-size: 0.875rem;
}

/* =========================================
   Company Details Panel (after selection)
   ========================================= */

.hccp-company-details-panel {
    margin-top: 16px;
    margin-bottom: 20px;
    animation: hccp-fadeSlideIn 0.3s ease;
}

@keyframes hccp-fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hccp-company-details {
    background: var(--hccp-card-bg, #fff);
    border: 1px solid var(--hccp-border, rgba(226, 232, 240, 0.8));
    border-radius: 16px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* Header */
.hccp-company-details-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: var(--hccp-bg-subtle, linear-gradient(135deg, #f0fdfa 0%, #f8fafc 100%));
    border-bottom: 1px solid var(--hccp-border, rgba(226, 232, 240, 0.8));
}

.hccp-company-details-icon {
    width: 48px;
    height: 48px;
    background: var(--hccp-accent, #00796b);
    color: #fff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hccp-company-details-title {
    flex: 1;
    min-width: 0;
}

.hccp-company-details-title h4 {
    margin: 0 0 2px 0;
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--hccp-text-primary, #1e293b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hccp-company-details-form {
    font-size: 0.8125rem;
    color: var(--hccp-text-muted, #64748b);
}

.hccp-company-details-status {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    flex-shrink: 0;
}

.hccp-company-details-status.status-success,
.hccp-company-details-status.status-green {
    color: #047857;
    background: rgba(4, 120, 87, 0.1);
}

.hccp-company-details-status.status-warning,
.hccp-company-details-status.status-yellow {
    color: #d97706;
    background: rgba(217, 119, 6, 0.1);
}

.hccp-company-details-status.status-error,
.hccp-company-details-status.status-red {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}

.hccp-company-details-status.status-muted {
    color: var(--hccp-text-muted, #94a3b8);
    background: var(--hccp-bg-subtle, #f1f5f9);
}

/* Details grid */
.hccp-company-details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    background: var(--hccp-border, rgba(226, 232, 240, 0.6));
    margin: 0;
}

.hccp-company-details-item {
    padding: 14px 18px;
    background: var(--hccp-card-bg, #fff);
}

.hccp-company-details-item.full {
    grid-column: span 2;
}

.hccp-company-details-item .label {
    display: block;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--hccp-text-muted, #94a3b8);
    margin-bottom: 4px;
    font-weight: 500;
}

.hccp-company-details-item .value {
    display: block;
    font-size: 0.875rem;
    color: var(--hccp-text-primary, #1e293b);
    font-weight: 500;
}

/* Board members */
.hccp-company-details-board {
    padding: 16px 18px;
    border-top: 1px solid var(--hccp-border, rgba(226, 232, 240, 0.8));
}

.hccp-company-details-board h5 {
    margin: 0 0 10px 0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--hccp-text-muted, #94a3b8);
    font-weight: 500;
}

.hccp-company-details-board ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hccp-company-details-board li {
    font-size: 0.8125rem;
    color: var(--hccp-text-primary, #1e293b);
    background: var(--hccp-bg-subtle, #f8fafc);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--hccp-border, rgba(226, 232, 240, 0.8));
}

/* Footer */
.hccp-company-details-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: var(--hccp-bg-subtle, #f8fafc);
    border-top: 1px solid var(--hccp-border, rgba(226, 232, 240, 0.8));
}

.hccp-company-details-source {
    font-size: 0.6875rem;
    color: var(--hccp-text-muted, #94a3b8);
}

/* Ghost button small */
.hccp-btn-ghost.hccp-btn-sm {
    font-size: 0.8125rem;
    padding: 6px 14px;
    color: var(--hccp-accent, #00796b);
    background: transparent;
    border: 1px solid var(--hccp-accent-light, rgba(0, 121, 107, 0.2));
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hccp-btn-ghost.hccp-btn-sm:hover {
    background: var(--hccp-accent-light, rgba(0, 121, 107, 0.08));
    border-color: var(--hccp-accent, #00796b);
}

/* =========================================
   Responsive Styles
   ========================================= */

@media (max-width: 640px) {
    .hccp-company-dropdown {
        max-height: 280px;
    }
    
    .hccp-company-details-grid {
        grid-template-columns: 1fr;
    }
    
    .hccp-company-details-item.full {
        grid-column: span 1;
    }
    
    .hccp-company-details-header {
        flex-wrap: wrap;
    }
    
    .hccp-company-details-status {
        order: -1;
        width: 100%;
        text-align: center;
        margin-bottom: 8px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .hccp-company-dropdown {
        background: #1e293b;
        border-color: #334155;
    }
    
    .hccp-company-name {
        color: #f1f5f9;
    }
    
    .hccp-company-form {
        background: #334155;
        color: #94a3b8;
    }
    
    .hccp-company-code {
        color: #94a3b8;
    }
    
    .hccp-company-item:hover,
    .hccp-company-item.selected {
        background: rgba(0, 121, 107, 0.15);
    }
    
    .hccp-company-details {
        background: #1e293b;
        border-color: #334155;
    }
    
    .hccp-company-details-header {
        background: linear-gradient(135deg, rgba(0, 121, 107, 0.1) 0%, #1e293b 100%);
    }
    
    .hccp-company-details-title h4 {
        color: #f1f5f9;
    }
    
    .hccp-company-details-item {
        background: #1e293b;
    }
    
    .hccp-company-details-item .value {
        color: #f1f5f9;
    }
    
    .hccp-company-details-board li {
        background: #334155;
        color: #f1f5f9;
        border-color: #475569;
    }
    
    .hccp-company-details-footer {
        background: #0f172a;
    }
}

/* =========================================
   Glass Auth Form Support (Registration)
   ========================================= */

.glass-auth-page .hccp-company-dropdown,
.glass-auth-form .hccp-company-dropdown {
    z-index: 10000;
    background: var(--glass-bg, #ffffff);
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.18));
    border-radius: 16px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 4px 12px rgba(0, 0, 0, 0.06);
    /* Limit height on registration form to not cover other fields */
    max-height: 200px;
}

/* Hide dropdown when company is selected (has data-company-selected) */
.glass-auth-page .company-field:has(input[data-company-selected="true"]) .hccp-company-dropdown,
.glass-auth-form .company-field:has(input[data-company-selected="true"]) .hccp-company-dropdown {
    display: none !important;
}

[data-theme="dark"] .glass-auth-page .hccp-company-dropdown,
[data-theme="dark"] .glass-auth-form .hccp-company-dropdown {
    background: var(--glass-bg-dark, #1e1e2e);
    border-color: var(--glass-border-dark, rgba(255, 255, 255, 0.1));
}

.glass-auth-page .hccp-company-item:hover,
.glass-auth-page .hccp-company-item.selected {
    background: var(--glass-primary-lighter, rgba(99, 102, 241, 0.1));
    border-color: var(--glass-primary, #6366f1);
}

.glass-auth-page .hccp-company-name {
    color: var(--glass-text, #1f2937);
}

[data-theme="dark"] .glass-auth-page .hccp-company-name {
    color: var(--glass-text-dark, #f3f4f6);
}

/* Company confirmation message on registration */
.glass-company-confirm {
    animation: hccp-fadeSlideIn 0.3s ease;
}
