/* ==========================================================================
   AddressAutocomplete PCF — styles.css
   ========================================================================== */

/* --------------------------------------------------------------------------
   Wrapper / layout
   -------------------------------------------------------------------------- */

.aa-wrapper {
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.aa-wrapper--crm {
    background: transparent;
}

.aa-input-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

/* --------------------------------------------------------------------------
   Search icon / spinner adornment (REQ-UI-08)
   -------------------------------------------------------------------------- */

.aa-adornment {
    position: absolute;
    right: 0.5rem;
    display: flex;
    align-items: center;
    color: #666;
    pointer-events: none;
    z-index: 1;
}

.aa-adornment svg {
    transform: scaleX(-1);
}

/* Pure CSS ring spinner — shown while debouncing or fetching */
@keyframes aa-spin {
    to { transform: rotate(360deg); }
}

.aa-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #ccc;
    border-top-color: #555;
    border-radius: 50%;
    animation: aa-spin 0.7s linear infinite;
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Input field — shared base
   -------------------------------------------------------------------------- */

.aa-input {
    width: 100%;
    box-sizing: border-box;
    padding-left: 0.5rem;
    /* Right padding accounts for the adornment icon */
    padding-right: 2rem;
}

/* --------------------------------------------------------------------------
   CRM model-driven app styles (REQ-UI-05)
   Ported from legacy css/style.css; driven by Environment.CRM enum.
   -------------------------------------------------------------------------- */

.InputAddress {
    background: transparent;
    border-style: none;
    color: #000000;
    font-size: 1.0rem;
    font-weight: 600;
    height: 2.5rem;
    width: 100%;
    outline: 0 !important;
    padding-left: 0.5rem;
    padding-right: 2rem;
    box-sizing: border-box;
}

.InputAddressFocused {
    background: transparent;
    border-width: 1px;
    border-style: solid;
    border-color: #000000;
    color: #000000;
    font-size: 1.0rem;
    height: 2.5rem;
    width: 100%;
    padding-left: 0.5rem;
    padding-right: 2rem;
    outline: 0 !important;
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Portal / Power Pages styles (REQ-UI-05)
   Bootstrap-compatible; driven by Environment.Portal enum.
   The "text form-control" class pair is already defined by the portal's
   Bootstrap stylesheet — these rules add the adornment offset only.
   -------------------------------------------------------------------------- */

.aa-input.form-control {
    padding-left: 0.5rem;
    padding-right: 2rem;
}

/* --------------------------------------------------------------------------
   Autocomplete dropdown (REQ-UI-06, REQ-UI-07)
   -------------------------------------------------------------------------- */

.aa-dropdown {
    /* Position is set inline by the React portal (position:fixed + top/left/width from BoundingClientRect) */
    background-color: #ffffff;
    border: 1px solid #d4d4d4;
    border-top: none;
    z-index: 9999;
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 280px;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.aa-dropdown--portal {
    /* Rendered into document.body — ensure it floats above all D365 chrome */
    z-index: 2147483647;
}

/* --------------------------------------------------------------------------
   Dropdown items
   -------------------------------------------------------------------------- */

.aa-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #222;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aa-item:last-child {
    border-bottom: none;
}

/* Mouse hover (REQ-UI-04) */
.aa-item:hover {
    background-color: #e9e9e9;
}

/* Keyboard-highlighted item — tracked in React state (REQ-UI-06) */
.aa-item--highlighted {
    background-color: #dce9f8;
    color: #0063b1;
}

/* Empty state — shown when a search returns no results */
.aa-item--empty {
    color: #888;
    font-style: italic;
    cursor: default;
    pointer-events: none;
}
