/* All styles are local to the Al-Ghadir Arabic on-screen keyboard. */
.ag-arabic-osk-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
}

.ag-arabic-osk-wrap > input[type="search"] {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    padding-left: 3.25rem !important;
    direction: rtl;
    text-align: right;
}

/* Compact icon button inside the left side of the search input. The theme has
   broad .ag-search button rules, so these dimensions intentionally use !important. */
.ag-arabic-osk-toggle {
    position: absolute !important;
    z-index: 5 !important;
    left: 6px !important;
    right: auto !important;
    top: 50% !important;
    bottom: auto !important;
    transform: translateY(-50%) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    width: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid #C8A15A !important;
    border-radius: 8px !important;
    background: #0E4835 !important;
    color: #fff !important;
    font: inherit !important;
    font-size: 12px !important;
    line-height: 1 !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    float: none !important;
    flex: none !important;
    box-shadow: none !important;
}

.ag-arabic-osk-toggle:hover {
    background: #C8A15A !important;
    color: #fff !important;
}

.ag-arabic-osk-toggle svg {
    display: block;
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
}

.ag-arabic-osk-toggle:focus-visible,
.ag-arabic-osk-panel button:focus-visible {
    outline: 2px solid #C8A15A;
    outline-offset: 2px;
}

.ag-arabic-osk-panel {
    /* Fixed positioning plus mounting under <body> avoids overflow:hidden ancestors. */
    position: fixed;
    z-index: 2147483000;
    top: 12px;
    left: 12px;
    width: min(560px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    box-sizing: border-box;
    max-height: min(70vh, 520px);
    overflow-y: auto;
    padding: 10px;
    border: 1px solid #C8A15A;
    border-radius: 10px;
    background: #fff;
    color: #17231e;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
    font-family: inherit;
    text-align: center;
}

.ag-arabic-osk-panel[hidden] {
    display: none !important;
}

.ag-arabic-osk-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 0 8px;
    margin-bottom: 7px;
    border-bottom: 1px solid #e7e0d4;
    color: #0E4835;
    text-align: right;
}

.ag-arabic-osk-header strong {
    font-size: 14px;
    font-weight: 700;
}

.ag-arabic-osk-row {
    display: grid;
    grid-template-columns: repeat(13, minmax(0, 1fr));
    gap: 4px;
    margin: 0 0 5px;
}

.ag-arabic-osk-row:nth-of-type(3) {
    grid-template-columns: repeat(11, minmax(0, 1fr));
}

.ag-arabic-osk-row:nth-of-type(4) {
    grid-template-columns: repeat(10, minmax(0, 1fr));
}

.ag-arabic-osk-key {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 38px;
    padding: 5px 2px;
    border: 1px solid #d8d8d8;
    border-radius: 5px;
    background: #f7f7f5;
    color: #17231e;
    font-family: inherit;
    font-size: 17px;
    line-height: 1.1;
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease;
}

.ag-arabic-osk-key:hover {
    background: #f2e8d5;
    border-color: #C8A15A;
}

.ag-arabic-osk-action {
    font-size: 13px;
    white-space: nowrap;
}

.ag-arabic-osk-close {
    min-height: 28px;
    padding: 4px 8px;
    border-color: #d8d8d8;
}

.ag-arabic-osk-controls {
    display: flex;
    gap: 5px;
    margin-top: 7px;
}

.ag-arabic-osk-controls .ag-arabic-osk-key {
    flex: 1 1 auto;
}

.ag-arabic-osk-controls .ag-arabic-osk-space {
    flex: 2 1 auto;
}

.ag-arabic-osk-controls .ag-arabic-osk-submit {
    background: #0E4835;
    border-color: #0E4835;
    color: #fff;
}

.ag-arabic-osk-controls .ag-arabic-osk-submit:hover {
    background: #155b44;
}

.ag-arabic-osk-controls .ag-arabic-osk-clear,
.ag-arabic-osk-controls .ag-arabic-osk-backspace {
    border-color: #C8A15A;
}

@media (max-width: 480px) {
    .ag-arabic-osk-panel {
        width: min(560px, calc(100vw - 24px));
        padding: 7px;
    }

    .ag-arabic-osk-row {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 4px;
    }

    .ag-arabic-osk-row:nth-of-type(3),
    .ag-arabic-osk-row:nth-of-type(4) {
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }

    .ag-arabic-osk-key {
        min-height: 36px;
        font-size: 16px;
    }

    .ag-arabic-osk-action {
        font-size: 12px;
    }

    .ag-arabic-osk-controls {
        flex-wrap: wrap;
    }

    .ag-arabic-osk-controls .ag-arabic-osk-key {
        min-width: 68px;
    }

    .ag-arabic-osk-controls .ag-arabic-osk-space {
        order: 0;
        flex: 1 1 90px;
    }
}
