/* =============================================================================
   On-Screen Keyboard  —  ParTrack 360
   Global styles for the #osk-panel element, which is injected directly into
   <body> by on-screen-keyboard.js and therefore cannot use Blazor scoped CSS.
   Previously these lived in OnScreenKeyboard.razor.css with :global() wrappers,
   but Blazor CSS isolation appends [b-xxxx] even to :global() selectors, making
   every rule a dead no-match. This plain CSS file is linked from _Layout_App.cshtml.
   ============================================================================= */

/* —— Design tokens (inherit from ParTrack 360 theme — custom.css) —————————— */
#osk-panel {
    --osk-accent:         #0d6efd;
    --osk-accent-hover:   #0b5ed7;
    --osk-accent-glow:    rgba(13, 110, 253, 0.35);
    --osk-bg:             #0a0f1f;
    --osk-border:         rgba(255, 255, 255, 0.28);
    --osk-key-bg:         #f8f9fa;
    --osk-key-border:     #ced4da;
    --osk-key-hover:      #e9ecef;
    --osk-key-press:      #dee2e6;
    --osk-key-active:     #0d6efd;
    --osk-enter-bg:       #198754;
    --osk-enter-border:   #146c43;
    --osk-close-bg:       #dc3545;
    --osk-close-hover:    #bb2d3b;
    --osk-text:           #111827;
    --osk-text-muted:     #0f172a;
    --osk-key-radius:     0.55rem;
    --osk-focus-ring:     0 0 0 3px rgba(13, 110, 253, 0.35);
    /* Panel always slides to bottom:0, covering the footer */

    position: fixed;
    bottom: -150vh;          /* off-screen below; JS/CSS slides it up via .osk-visible */
    left: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    background: var(--osk-bg);
    border-top: 2px solid var(--osk-border);
    padding: 0.9rem 1rem 1.1rem;
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.55);
    z-index: 2000;
    transition: bottom 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#osk-panel.osk-visible {
    bottom: 0;
}

/* —— Rows —— */
#osk-panel .osk-row {
    display: flex;
    justify-content: center;
    gap: 0.45rem;
    margin-bottom: 0.45rem;
    width: 100%;
}

/* —— Keys —— */
#osk-panel .osk-key {
    flex: 1;
    min-width: 3.5rem;
    max-width: none;
    height: 4.2rem;
    padding: 0 0.35rem;
    background: var(--osk-key-bg);
    border: 2px solid var(--osk-key-border);
    border-radius: var(--osk-key-radius);
    color: var(--osk-text);
    font-size: 1.22rem;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s, border-color 0.1s, transform 0.07s, box-shadow 0.1s;
    touch-action: manipulation;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.26);
    position: relative;
}

#osk-panel .osk-key:hover {
    background: var(--osk-key-hover);
    border-color: #adb5bd;
}

#osk-panel .osk-key:active {
    background: var(--osk-key-press);
    transform: translateY(1px);
    box-shadow: none;
}

/* Accessibility: visible focus ring for physical keyboard / switch access */
#osk-panel .osk-key:focus-visible {
    outline: none;
    box-shadow: var(--osk-focus-ring), 0 2px 0 rgba(0, 0, 0, 0.38);
    z-index: 1;
}

/* Wide modifier / action keys */
#osk-panel .osk-key--wide {
    flex: 1.8;
    min-width: 6.5rem;
    color: var(--osk-text-muted);
    font-size: 1rem;
    letter-spacing: 0.01em;
}

/* Backspace */
#osk-panel .osk-key--backspace {
    flex: 2;
    min-width: 7rem;
}

/* Space bar */
#osk-panel .osk-key--space {
    flex: 6;
    min-width: 14rem;
    max-width: none;
    color: var(--osk-text-muted);
    font-size: 1rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Enter */
#osk-panel .osk-key--enter {
    min-width: 7rem;
    background: var(--osk-enter-bg);
    border-color: var(--osk-enter-border);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

#osk-panel .osk-key--enter:hover {
    background: var(--osk-accent-hover);
}

/* Close button */
#osk-panel .osk-key--close {
    background: var(--osk-close-bg);
    border-color: #9f1d2b;
    color: #fff;
    font-weight: 700;
}

#osk-panel .osk-key--close:hover {
    background: var(--osk-close-hover);
}

/* Active modifier state: Caps Lock on or Shift latched */
#osk-panel .osk-key--active {
    background: var(--osk-key-active) !important;
    border-color: #084298 !important;
    color: #fff !important;
    box-shadow: 0 0 10px var(--osk-accent-glow) !important;
}

/* Key label */
#osk-panel .osk-key-label {
    pointer-events: none;
    line-height: 1.1;
}

#osk-panel .osk-key-label-dual {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.08rem;
    line-height: 1;
}

#osk-panel .osk-key-char-shifted,
#osk-panel .osk-key-char-base {
    display: block;
    font-weight: 700;
}

#osk-panel .osk-key-char-shifted {
    font-size: 0.72rem;
    opacity: 0.55;
}

#osk-panel .osk-key-char-base {
    font-size: 1rem;
    opacity: 0.7;
}

#osk-panel .osk-key-char-base.active,
#osk-panel .osk-key-char-shifted.active {
    opacity: 1;
    color: var(--osk-text);
    font-size: 1.44rem;
}

#osk-panel .osk-key-char-shifted.active {
    color: #0b5ed7;
}

#osk-panel .osk-key--active .osk-key-char-shifted.active {
    color: #ffffff;
}

#osk-panel .osk-key--caps .osk-key-label,
#osk-panel .osk-key--shift .osk-key-label,
#osk-panel .osk-key--emailpanel .osk-key-label {
    font-size: 0.95rem;
    font-weight: 700;
}

#osk-panel .osk-key--caps .osk-key-label i {
    margin-left: 0.3rem;
}

#osk-panel .osk-email-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
    padding-top: 0;
    border-top: 0 solid rgba(255, 255, 255, 0.22);
    transition: max-height 0.24s ease, opacity 0.2s ease, margin-top 0.2s ease, padding-top 0.2s ease;
}

#osk-panel.osk-email-expanded .osk-email-panel {
    max-height: 16rem;
    opacity: 1;
    margin-top: 0.35rem;
    padding-top: 0.5rem;
    border-top-width: 1px;
}

#osk-panel .osk-email-suffix-btn {
    min-height: 2.8rem;
    width: 100%;
    border: 2px solid #adb5bd;
    border-radius: 0.45rem;
    background: #ffffff;
    color: #0f172a;
    font-size: 0.98rem;
    font-weight: 700;
    text-align: left;
    padding: 0.45rem 0.6rem;
}

#osk-panel .osk-email-suffix-btn:hover,
#osk-panel .osk-email-suffix-btn:focus-visible {
    background: #e9ecef;
    border-color: #6c757d;
    outline: none;
}

/* —— Screen-reader live region (visually hidden) —— */
.osk-live-region {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    pointer-events: none;
}

/* —— Responsive: narrow screens —— */
@media (max-width: 700px) {
    #osk-panel {
        padding: 0.55rem 0.35rem 0.75rem;
    }

    #osk-panel .osk-row {
        gap: 0.24rem;
        margin-bottom: 0.24rem;
    }

    #osk-panel .osk-key {
        height: 3.45rem;
        font-size: 1rem;
        min-width: 2.2rem;
    }

    #osk-panel .osk-key-char-base {
        font-size: 0.92rem;
    }

    #osk-panel .osk-key-char-shifted {
        font-size: 0.66rem;
    }

    #osk-panel .osk-key--wide  { min-width: 4.2rem; flex: 1.5; }
    #osk-panel .osk-key--space { min-width: 7.5rem; flex: 4.8; }

    #osk-panel .osk-email-panel {
        grid-template-columns: 1fr;
        max-height: 0;
    }

    #osk-panel.osk-email-expanded .osk-email-panel {
        max-height: 22rem;
    }
}

/* Next / Submit action button */
#osk-panel .osk-key--next {
    min-width: 7rem;
    flex: 2;
    background: var(--osk-accent, #0d6efd);
    border-color: #084298;
    color: #fff;
    font-weight: 700;
}

#osk-panel .osk-key--next:hover,
#osk-panel .osk-key--next:focus {
    background: var(--osk-accent-hover, #0b5ed7);
}

#osk-panel .osk-key--next.osk-key--next-submit {
    background: var(--osk-submit, #198754);
}

#osk-panel .osk-key--next.osk-key--next-submit:hover,
#osk-panel .osk-key--next.osk-key--next-submit:focus {
    background: var(--osk-submit-hover, #157347);
}

/* ── Scroll-bar strip ──────────────────────────────────────────────────────── */

#osk-panel .osk-scroll-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.45rem 0.6rem 0.35rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.22);
    margin-bottom: 0.45rem;
    touch-action: auto; /* allow native scroll gestures on the bar itself */
}

#osk-panel .osk-scroll-btn,
#osk-panel .osk-scroll-close-btn {
    flex: 1;
    min-height: 48px;
    border: 2px solid #adb5bd;
    border-radius: 0.45rem;
    background: #f8f9fa;
    color: #0f172a;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    transition: background 0.15s;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

#osk-panel .osk-scroll-btn:hover,
#osk-panel .osk-scroll-btn:active {
    background: #e9ecef;
}

#osk-panel .osk-scroll-close-btn {
    flex: 1.4;
    background: #dc3545;
    border-color: #9f1d2b;
    color: #fff;
}

#osk-panel .osk-scroll-close-btn:hover,
#osk-panel .osk-scroll-close-btn:active {
    background: #bb2d3b;
}
