/*
 * Kailo UI Components — Main Stylesheet
 *
 * Usage in host app index.html / App.razor:
 *   <link rel="stylesheet" href="_content/Kailo.Core.UI/styles/kailo.ui-components.css" />
 */

@import url('kailo.fonts.css');
@import url('../fonts/font-awesome/css/all.min.css');
@import url('default-main.css');
@import url('default-main-dark.css');
@import url('kailo.tokens.css');
@import url('kailo.telerik.overrides.css');
@import url('kailo.code-editor.css');
@import url('kailo.popups.css');

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--kailo-font-family);
    font-weight: var(--kailo-font-weight-normal);
    background-color: var(--kailo-color-app-surface);
    color: var(--kailo-color-on-surface);
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

::-webkit-scrollbar {
    width: 14px;
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--kailo-color-neutral);
    border-radius: 10px;
    border: 4px solid transparent;
    background-clip: padding-box;
}

    ::-webkit-scrollbar-thumb:hover {
        background-color: var(--kailo-color-neutral-hover);
    }

/* ===== Shared popup chrome ===== */

@keyframes kailo-popup-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kailo-popup {
    background: var(--kailo-color-surface);
    border: 1px solid var(--kailo-color-border);
    border-radius: var(--kailo-radius-md);
    box-shadow: var(--kailo-shadow-md);
    z-index: 10100;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    animation: kailo-popup-in 0.15s ease;
}

/* ===== Global validation ===== */

.kailo-label-icon {
    font-size: 0.875em;
    color: var(--kailo-color-on-surface-muted);
    margin-right: var(--kailo-space-1);
    flex-shrink: 0;
}

/* Grid cells inside FillHeight grids must not drive their own height */
.kailo-grid--fill-height .kailo-grid__inner > * {
    min-height: 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Protocol badges
   ─────────────────────────────────────────────────────────────────────────────
   Fixed identity colours for the integration protocols, so HL7 is the same
   colour on every screen that shows it.

   There is no protocol badge control. A caller uses an ordinary KailoBadge and
   adds one of these classes, which override only the two colour variables its
   fill modes read -- size, radius, spacing and solid-vs-outline all stay
   KailoBadge's. KailoColorVariant is deliberately left alone: it is shared by
   21 components, and protocol members there would offer Variant="Hl7" on every
   button and alert with no styling behind it.

   THE SUFFIX IS THE ENUM MEMBER NAME, LOWER-CASED. Kailo.Modules.Common
   .ValueTypes.IntegrationProtocol has HL7, Dicom, Fhir and Api, so call sites
   build the class as

       $"kailo-protocol-badge--{protocol.ToString().ToLowerInvariant()}"

   rather than keeping a mapping table that could fall out of step. Adding a
   protocol therefore means adding a member there and a rule here, and nothing
   else.

   Global rather than component-scoped on purpose: the element belongs to
   KailoBadge, so a rule scoped to some other component would never match it.

   The protocol class is named twice in each selector, which is deliberate and is
   not a typo. The variant rules it has to beat (.kailo-badge--neutral and
   friends) live in KailoBadge.razor.css, and Blazor rewrites every scoped
   selector to carry a scope attribute -- .kailo-badge--neutral[b-abc123], whose
   hash changes from build to build. That attribute counts, so those rules are
   specificity 2, not 1, and the plain
   .kailo-badge.kailo-protocol-badge--hl7 only ties with them. A tie is
   settled by load order, and the scoped bundle is linked ahead of this file in
   one app and behind it in another, so the badges came out grey wherever the
   bundle happened to land second.

   Doubling the class makes these rules specificity 3, which wins outright
   whichever order the stylesheets load in. */

.kailo-badge.kailo-protocol-badge--hl7.kailo-protocol-badge--hl7 {
    --kailo-badge-bg: var(--kailo-color-protocol-hl7-badge);
    --kailo-badge-color: var(--kailo-color-protocol-hl7-badge-text);
}

.kailo-badge.kailo-protocol-badge--dicom.kailo-protocol-badge--dicom {
    --kailo-badge-bg: var(--kailo-color-protocol-dicom-badge);
    --kailo-badge-color: var(--kailo-color-protocol-dicom-badge-text);
}

.kailo-badge.kailo-protocol-badge--fhir.kailo-protocol-badge--fhir {
    --kailo-badge-bg: var(--kailo-color-protocol-fhir-badge);
    --kailo-badge-color: var(--kailo-color-protocol-fhir-badge-text);
}

.kailo-badge.kailo-protocol-badge--api.kailo-protocol-badge--api {
    --kailo-badge-bg: var(--kailo-color-protocol-api-badge);
    --kailo-badge-color: var(--kailo-color-protocol-api-badge-text);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Payload badges
   ─────────────────────────────────────────────────────────────────────────────
   Fixed identity colours for what an interface carries, so a payload is the same
   colour on the Interfaces grid, the Queues grid and the workflow diagram. Built
   exactly like the protocol badges above -- an ordinary KailoBadge plus one of
   these classes, overriding only the two colour variables -- including the
   doubled class name, for the specificity reason spelled out there.

   THE SUFFIX IS THE ENUM MEMBER NAME, LOWER-CASED, as it is for protocols:
   Kailo.Modules.Interface.ValueTypes.InterfacePayloadType has HL7, DICOM, XML,
   PVS, KAL, JSON, FHIR and CUSTOM, so InterfacePayloadBadge builds the class as

       $"kailo-payload-badge--{payload.ToString().ToLowerInvariant()}"

   HL7, DICOM and FHIR resolve to the same primitives the protocol badges use, so
   the same standard is the same colour whichever badge names it. The tokens are
   still the payload family's own; see kailo.tokens.css for why the two are not
   collapsed into one set.

   There is deliberately NO rule for PVS, KAL or CUSTOM. They fall back to
   KailoBadge's neutral grey rather than to a colour invented for them -- the
   ramps left over all already mean something else, and CUSTOM is the member for
   "none of these" in the first place. The class is still emitted for them, so
   giving one a colour later is a rule here and nothing else. */

.kailo-badge.kailo-payload-badge--hl7.kailo-payload-badge--hl7 {
    --kailo-badge-bg: var(--kailo-color-payload-hl7-badge);
    --kailo-badge-color: var(--kailo-color-payload-hl7-badge-text);
}

.kailo-badge.kailo-payload-badge--dicom.kailo-payload-badge--dicom {
    --kailo-badge-bg: var(--kailo-color-payload-dicom-badge);
    --kailo-badge-color: var(--kailo-color-payload-dicom-badge-text);
}

.kailo-badge.kailo-payload-badge--fhir.kailo-payload-badge--fhir {
    --kailo-badge-bg: var(--kailo-color-payload-fhir-badge);
    --kailo-badge-color: var(--kailo-color-payload-fhir-badge-text);
}

.kailo-badge.kailo-payload-badge--xml.kailo-payload-badge--xml {
    --kailo-badge-bg: var(--kailo-color-payload-xml-badge);
    --kailo-badge-color: var(--kailo-color-payload-xml-badge-text);
}

.kailo-badge.kailo-payload-badge--json.kailo-payload-badge--json {
    --kailo-badge-bg: var(--kailo-color-payload-json-badge);
    --kailo-badge-color: var(--kailo-color-payload-json-badge-text);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Direction badges
   ─────────────────────────────────────────────────────────────────────────────
   Fixed identity colours for which way traffic flows across a network address,
   so ingress is the same colour on every screen that shows it. Built exactly
   like the protocol badges above -- an ordinary KailoBadge plus one of these
   classes, overriding only the two colour variables -- including the doubled
   class name, for the specificity reason spelled out there.

   THE SUFFIX IS THE ENUM MEMBER NAME, LOWER-CASED, as it is for protocols:
   Kailo.Modules.VendorSystem.ValueTypes.NetworkAddressDirection has Ingress and
   Egress, so call sites build the class as

       $"kailo-direction-badge--{direction.ToString().ToLowerInvariant()}"

   There is deliberately NO rule for the enum's third member, Both. Both is not a
   third colour -- it is the other two at once, and it renders as both badges.
   NetworkAddressDirections.Split is what turns a stored value into the badges to
   show, so nothing should reach here holding Both; anything that does falls back
   to KailoBadge's neutral grey rather than inventing a colour.

   The pair is deliberately not tied to Kailo.Modules.Interface's
   InterfaceDirection, which is a five-member taxonomy (inbound, outbound,
   pass-through, MWL, Q/R) rather than an ingress/egress axis. */

.kailo-badge.kailo-direction-badge--ingress.kailo-direction-badge--ingress {
    --kailo-badge-bg: var(--kailo-color-direction-ingress-badge);
    --kailo-badge-color: var(--kailo-color-direction-ingress-badge-text);
}

.kailo-badge.kailo-direction-badge--egress.kailo-direction-badge--egress {
    --kailo-badge-bg: var(--kailo-color-direction-egress-badge);
    --kailo-badge-color: var(--kailo-color-direction-egress-badge-text);
}
