/* All header classes are namespaced with `kw-header-*` to avoid clashing
   with page-level CSS (e.g. .header-btn, .search-input on receivables-list-modern.css).
   Legacy aliases (.main-header, .header-left, etc.) are kept so static
   header markup in older HTML files stays styled until renderHeader()
   swaps it for the namespaced version. */

.kw-main-header,
.main-header {
    position: sticky;
    top: 0;
    height: 56px;
    background-color: #1a1e23;
    display: flex;
    align-items: center;
    padding: 0 40px;
    justify-content: space-between;
    z-index: 1000;
}

.kw-header-left,
.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

.kw-header-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 520px;
    max-width: 50vw;
    margin-left: 8px;
}

.kw-header-search-dropdown {
    /* dropdown widens beyond the input so multi-line people cards have room
       for the phone column on the right */
    min-width: 560px;
}

.kw-header-search-icon {
    position: absolute;
    left: 10px;
    color: #94a3b8;
    font-size: 18px !important;
    pointer-events: none;
}

/* These rules deliberately use !important to defeat broad `input[type="text"]`
   selectors from page-level stylesheets (e.g. receivables-list-modern.css)
   that otherwise stomp the padding/background and shove the placeholder on
   top of the magnify icon. */
input.kw-header-search-input {
    width: 100% !important;
    height: 36px !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 8px !important;
    color: #ffffff !important;
    font-size: 13px !important;
    padding: 0 12px 0 36px !important;
    outline: none !important;
    box-shadow: none !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}

input.kw-header-search-input::placeholder {
    color: #94a3b8 !important;
}

input.kw-header-search-input:hover {
    background-color: rgba(255, 255, 255, 0.12) !important;
    border-color: rgba(255, 255, 255, 0.18) !important;
}

input.kw-header-search-input:focus {
    background-color: #ffffff !important;
    color: #1a1f36 !important;
    border-color: #635bff !important;
    box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.25) !important;
}

.kw-header-search-wrapper:focus-within .kw-header-search-icon {
    color: #4f566b;
}

.kw-header-search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 480px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #e3e8ee;
    border-radius: 10px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.18), 0 10px 10px -5px rgba(0, 0, 0, 0.06);
    padding: 6px 0;
    z-index: 1100;
}

.kw-header-search-hint,
.kw-header-search-empty {
    padding: 14px 16px;
    color: #6b7280;
    font-size: 13px;
}

.kw-header-search-section + .kw-header-search-section {
    border-top: 1px solid #f1f5f9;
    margin-top: 4px;
    padding-top: 4px;
}

.kw-header-search-section-title {
    padding: 8px 16px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8792a2;
}

.kw-header-search-loading {
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: #b3b9c4;
    font-style: italic;
    margin-left: 4px;
}

.kw-header-search-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    color: #1a1f36;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.12s;
}

.kw-header-search-result:hover,
.kw-header-search-result.is-active {
    background-color: #f5f6fa;
}

.kw-header-search-result-icon {
    font-size: 18px !important;
    color: #635bff;
    flex-shrink: 0;
}

.kw-header-search-result-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kw-header-search-result-text mark {
    background: rgba(99, 91, 255, 0.18);
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

.kw-header-search-result-sub {
    font-size: 11px;
    color: #8792a2;
    text-transform: capitalize;
    flex-shrink: 0;
}

/* Owner / Vendor / Tenant badge on people results */
.kw-header-search-result-badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    line-height: 1.4;
    border: 1px solid transparent;
}

.kw-header-search-result-badge.kw-badge-owner {
    background: #ede9fe;
    color: #5b21b6;
    border-color: #ddd6fe;
}

.kw-header-search-result-badge.kw-badge-vendor {
    background: #ffedd5;
    color: #9a3412;
    border-color: #fed7aa;
}

.kw-header-search-result-badge.kw-badge-tenant {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.kw-header-search-result-badge.kw-badge-unit {
    background: #dbeafe;
    color: #1e40af;
    border-color: #bfdbfe;
}

.kw-header-search-result-badge.kw-badge-bank {
    background: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

.kw-header-search-result-badge.kw-badge-property {
    background: #cffafe;
    color: #155e75;
    border-color: #a5f3fc;
}

.kw-header-search-result-badge.kw-badge-medical {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

.kw-property-type {
    font-size: 12px;
    font-weight: 600;
    color: #0f172a;
    text-transform: capitalize;
    margin-top: 4px;
}

.kw-property-units {
    font-size: 12px;
    color: #475569;
    margin-top: 2px;
}

.kw-unit-vacant {
    color: #b91c1c;
    font-weight: 600;
}

.kw-unit-tenant-link {
    /* Inline link inside the meta line — strip the chip styling so it reads
       as text, not a button. */
    background: transparent;
    border: none;
    padding: 0;
    color: #2563eb;
    font-weight: 500;
    text-decoration: underline;
}

.kw-unit-tenant-link:hover {
    background: transparent;
    border: none;
    color: #1d4ed8;
}

/* Shared "people card" — multi-line block with action chips at the bottom.
   Used by tenant and vendor cards. Rendered as <div> (not <a>) because
   action chips inside are anchors; row click is delegated in JS. */
.kw-header-search-result.kw-people-card {
    display: block;
    padding: 12px 16px;
    cursor: pointer;
}

.kw-people-card-main {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.kw-people-card .kw-header-search-result-icon {
    margin-top: 2px;
}

.kw-people-body {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.kw-people-info-left {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.kw-people-info-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
    max-width: 45%;
}

.kw-people-name {
    font-weight: 600;
    font-size: 14px;
    color: #1a1f36;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kw-people-meta-line {
    font-size: 12px;
    color: #4f566b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kw-people-meta-muted {
    color: #8792a2;
}

.kw-people-phone {
    font-size: 12px;
    color: #4f566b;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.kw-people-phone strong {
    color: #1a1f36;
    font-weight: 600;
}

.kw-people-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    /* indent under the title so chips align with the text, not the icon */
    padding-left: 30px;
}

.kw-people-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 6px;
    background: #f1f5f9;
    color: #1a1f36;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background 0.12s, border-color 0.12s;
    line-height: 1.2;
}

.kw-people-action:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.kw-people-action .material-icons {
    font-size: 14px !important;
    color: #635bff;
}

.kw-tenant-balance {
    font-weight: 700;
    margin-left: 4px;
    padding-left: 6px;
    border-left: 1px solid #cbd5e1;
    color: #4f566b;
}

.kw-tenant-balance--owed {
    color: #b91c1c;
}

.kw-tenant-balance--credit {
    color: #047857;
}

.kw-tenant-balance--zero {
    color: #8792a2;
}

.kw-header-logo-icon,
.header-logo-icon {
    height: 32px;
    width: auto;
}

.kw-header-logo-text,
.header-logo-text {
    height: 18px;
    width: auto;
}

.kw-header-right,
.header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.portfolio-name-container {
    max-width: 250px;
    overflow: visible;
    color: white;
    font-size: 14px;
    font-weight: 500;
    position: relative;
}

.kw-header-actions,
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kw-header-btn,
.header-btn {
    position: relative;
    color: #94a3b8;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
}

.kw-header-btn:hover,
.header-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.kw-header-btn .material-icons,
.header-btn .material-icons {
    font-size: 20px;
}

/* Tooltip style */
.kw-header-btn::after,
.header-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background-color: #1e293b;
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 1001;
}

.kw-header-btn::before,
.header-btn::before {
    content: '';
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent #1e293b transparent;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
}

.kw-header-btn:hover::after,
.kw-header-btn:hover::before,
.header-btn:hover::after,
.header-btn:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Page breadcrumb header (used on detail/edit pages) */
.nav_header_path {
    background: transparent;
    border: none;
    padding: 8px 0;
    margin-bottom: 24px;
}

.nav_header_path .link_holder {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.nav_header_path .link_holder a {
    text-decoration: none;
}

.nav_header_path .prev_link_a {
    color: #6b7280;
}

.nav_header_path .prev_link_a:hover {
    color: #111827;
    text-decoration: underline;
}

.nav_header_path .cur_link_a {
    color: #111827;
    font-weight: 600;
    cursor: default;
}

.nav_header_path .link_holder .material-icons {
    font-size: 18px;
    color: #9ca3af;
}
