/* ============================================================
   ACE — retrieve_directory.css
   Clean consolidated stylesheet
   ============================================================ */


/* ============================================================
   GLOBAL
   ============================================================ */

* {
    box-sizing: border-box;
}

html {
    background: #f4f6f8;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: #1f2933;
    background: #f4f6f8;
}

a {
    color: inherit;
}

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 24px auto 60px;
}


/* ============================================================
   PAGE HEADER
   ============================================================ */

.page-header {
    padding: 4px 0 18px;
}

.page-header h1 {
    margin: 0;
    font-size: 30px;
    line-height: 1.2;
}

.subtitle {
    margin: 7px 0 0;
    color: #5f6c78;
}


/* ============================================================
   SEARCH BOX
   ============================================================ */

.search-box {
    margin-bottom: 18px;
    padding: 16px;

    background: #ffffff;
    border: 1px solid #d7dde3;
    border-radius: 10px;
}

.search-box form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.search-box label {
    font-weight: 700;
}

.search-box input[type="text"] {
    width: 220px;
    max-width: 100%;

    padding: 8px 11px;

    border: 1px solid #b9c2ca;
    border-radius: 6px;

    background: #ffffff;

    direction: rtl;
    text-align: right;

    font-size: 22px;
    line-height: 1.3;
}

.search-box input[type="text"]:focus {
    outline: 2px solid #9fb9cf;
    outline-offset: 1px;
    border-color: #6688a3;
}

.search-box button,
.root-picker-form button {
    padding: 9px 15px;

    border: 1px solid #334e68;
    border-radius: 7px;

    background: #334e68;
    color: #ffffff;

    font-size: 15px;
    font-weight: 700;

    cursor: pointer;
}

.search-box button:hover,
.root-picker-form button:hover {
    background: #243b53;
}


/* ============================================================
   ARABIC ALPHABET NAVIGATION
   ============================================================ */

.alphabet-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;

    direction: rtl;

    padding: 14px;
    margin-bottom: 14px;

    background: #ffffff;
    border: 1px solid #d7dde3;
    border-radius: 10px;
}


/* Active alphabet links */

a.alphabet-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 40px;
    min-height: 40px;

    padding: 7px 10px;

    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 7px;

    color: #1d4ed8;

    font-size: 22px;
    font-weight: 700;
    line-height: 1;

    text-align: center;
    text-decoration: none;

    cursor: pointer;

    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        transform 0.15s ease;
}

a.alphabet-link:hover {
    background: #eff6ff;
    border-color: #2563eb;
    color: #1e40af;

    transform: translateY(-1px);
}

a.alphabet-link:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.25);
    outline-offset: 2px;
}

a.alphabet-link:active {
    transform: translateY(0);
}


/* Current selected Arabic letter */

a.alphabet-link.is-current {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #ffffff;
}

a.alphabet-link.is-current:hover {
    background: #1e40af;
    border-color: #1e40af;
    color: #ffffff;
}


/* Disabled alphabet letters */

span.alphabet-link.is-disabled {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 40px;
    min-height: 40px;

    padding: 7px 10px;

    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 7px;

    color: #94a3b8;

    font-size: 22px;
    font-weight: 700;
    line-height: 1;

    cursor: default;
    pointer-events: none;
}


/* ============================================================
   LETTER / ROOT NAVIGATION
   ============================================================ */

.letter-nav,
.root-nav {
    display: grid;
    grid-template-columns: minmax(170px, 1fr) auto minmax(170px, 1fr);
    align-items: center;
    gap: 12px;

    margin-bottom: 14px;
}

.letter-nav > :first-child,
.root-nav > :first-child {
    justify-self: start;
}

.letter-nav > :last-child,
.root-nav > :last-child {
    justify-self: end;
}

.current-letter,
.selected-root {
    text-align: center;
}

.current-letter strong,
.selected-root strong {
    font-size: 23px;
}

.selected-root strong {
    direction: rtl;
}


/* ============================================================
   ACTIVE PREVIOUS / NEXT NAVIGATION BUTTONS
   ============================================================ */

a.nav-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: fit-content;
    min-height: 42px;

    padding: 9px 16px;

    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;

    color: #1d4ed8;

    font-weight: 600;
    text-decoration: none;

    cursor: pointer;

    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        transform 0.15s ease;
}

a.nav-button:hover {
    background: #eff6ff;
    border-color: #2563eb;
    color: #1e40af;

    text-decoration: none;

    transform: translateY(-1px);
}

a.nav-button:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.25);
    outline-offset: 2px;
}

a.nav-button:active {
    transform: translateY(0);
}


/* Disabled previous / next navigation */

span.nav-button.is-disabled {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: fit-content;
    min-height: 42px;

    padding: 9px 16px;

    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;

    color: #94a3b8;

    font-weight: 600;

    cursor: default;
    pointer-events: none;
}


/* ============================================================
   ROOT SELECTOR
   ============================================================ */

.root-picker {
    margin-bottom: 14px;
    padding: 14px;

    background: #ffffff;

    border: 1px solid #d7dde3;
    border-radius: 10px;
}

.root-picker-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.root-picker-form label {
    font-weight: 700;
}

.root-picker-form select {
    min-width: 190px;

    padding: 8px 38px 8px 10px;

    border: 1px solid #b9c2ca;
    border-radius: 6px;

    background: #ffffff;

    direction: rtl;
    text-align: right;

    font-size: 22px;
}


/* ============================================================
   SUMMARY
   ============================================================ */

.summary {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 30px;

    margin: 18px 0;
    padding: 14px 17px;

    background: #eaf2f8;

    border: 1px solid #b9cad8;
    border-radius: 9px;
}

.summary > div {
    display: flex;
    align-items: center;
    gap: 8px;
}

.summary-label {
    color: #52606d;
    font-weight: 600;
}

.arabic-display {
    direction: rtl;
    font-size: 24px;
}


/* ============================================================
   RECORD CARD
   ============================================================ */

.record-card {
    overflow: hidden;

    margin-bottom: 22px;

    background: #ffffff;

    border: 1px solid #d1d8de;
    border-radius: 11px;

    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.04);
}

.record-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;

    padding: 15px 18px;

    background: #edf2f6;
    border-bottom: 1px solid #d1d8de;
}

.record-number {
    font-size: 18px;
    font-weight: 700;
}

.form-badge {
    display: inline-block;

    margin-left: 9px;
    padding: 4px 9px;

    background: #ffffff;

    border: 1px solid #bcc7d0;
    border-radius: 999px;

    font-size: 13px;
    font-weight: 700;
}


/* ============================================================
   MAIN ARABIC RECORD LINK

   Example:
   ace_pattern_no.php?token=<Arabic token>
   ============================================================ */

.record-arabic-link {
    display: inline-block;

    direction: rtl;
    text-align: right;

    padding: 3px 7px;

    border-radius: 6px;

    color: #1f4f78;

    font-size: 30px;
    font-weight: 700;
    line-height: 1.4;

    text-decoration: none;

    transition:
        background-color 0.15s ease,
        color 0.15s ease;
}

.record-arabic-link:hover {
    background: #dfeaf3;
    color: #163d5c;

    text-decoration: none;
}

.record-arabic-link:focus-visible {
    outline: 2px solid #7fa5c2;
    outline-offset: 2px;
}


/* ============================================================
   RECORD TABLE
   ============================================================ */

.record-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.record-table {
    width: 100%;
    border-collapse: collapse;
}

.record-table th,
.record-table td {
    padding: 10px 13px;

    border-bottom: 1px solid #e1e6ea;

    vertical-align: top;
}

.record-table th {
    width: 225px;

    background: #f8fafb;

    color: #43515d;

    text-align: left;

    font-size: 14px;
    font-weight: 700;
}

.record-table tr:last-child th,
.record-table tr:last-child td {
    border-bottom: 0;
}

.record-table tr:hover th,
.record-table tr:hover td {
    background-color: #fafcfd;
}


/* ============================================================
   FIELD VALUES
   ============================================================ */

.field-value {
    font-size: 16px;
    line-height: 1.5;
}

.arabic-value {
    direction: rtl;
    text-align: right;

    font-size: 23px;
    line-height: 1.65;
}


/* ============================================================
   CLICKABLE ARABIC TOKENS

   Used for:
   ace_pattern_no.php?token=<Arabic token>
   ============================================================ */

.arabic-token-link {
    display: inline-block;

    direction: rtl;

    padding: 1px 4px;

    border-bottom: 1px dotted #527a99;
    border-radius: 3px;

    color: #1f557d;

    text-decoration: none;

    font-weight: 600;

    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
}

.arabic-token-link:hover {
    background: #e7f0f7;

    border-bottom-color: #1f557d;
    border-bottom-style: solid;

    color: #123e5e;
}

.arabic-token-link:focus-visible {
    outline: 2px solid #8aacbf;
    outline-offset: 2px;
}


/* ============================================================
   SOURCE ROW
   ============================================================ */

.source-row th,
.source-row td {
    background: #fafbfc;

    color: #697783;

    font-size: 13px;
}


/* ============================================================
   EMPTY / NOTICE MESSAGES
   ============================================================ */

.none,
.notice {
    padding: 15px;

    border-radius: 8px;
}

.none,
.notice-error {
    background: #fff1f1;
    border: 1px solid #e2bcbc;

    color: #713b3b;
}


/* ============================================================
   DEBUG
   ============================================================ */

.debug-box,
.debug {
    margin-top: 28px;
    padding: 12px 15px;

    background: #ffffff;

    border: 1px solid #d2d9df;
    border-radius: 8px;
}

.debug-box summary {
    cursor: pointer;
    font-weight: 700;
}

.debug-content {
    display: grid;
    gap: 6px;

    margin-top: 12px;

    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 13px;
}

.debug {
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 13px;
}


/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 760px) {

    .page-shell {
        width: min(calc(100% - 20px), 1180px);
        margin-top: 12px;
    }

    .page-header h1 {
        font-size: 24px;
    }

    .search-box form,
    .root-picker-form {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box input[type="text"],
    .root-picker-form select {
        width: 100%;
    }


    /* Navigation becomes two columns */

    .letter-nav,
    .root-nav {
        grid-template-columns: 1fr 1fr;
    }

    .current-letter,
    .selected-root {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .letter-nav > :first-child,
    .root-nav > :first-child {
        justify-self: start;
    }

    .letter-nav > :last-child,
    .root-nav > :last-child {
        justify-self: end;
    }


    /* Alphabet */

    .alphabet-nav {
        gap: 5px;
        padding: 10px;
    }

    a.alphabet-link,
    span.alphabet-link.is-disabled {
        min-width: 36px;
        min-height: 36px;

        padding: 7px;

        font-size: 20px;
    }


    /* Record */

    .record-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .record-arabic-link {
        font-size: 27px;
    }

    .record-table th {
        width: 160px;
    }

    .arabic-value {
        font-size: 21px;
    }
}


/* ============================================================
   VERY SMALL SCREENS
   ============================================================ */

@media (max-width: 480px) {

    .page-shell {
        width: calc(100% - 12px);
    }

    .record-table th,
    .record-table td {
        padding: 8px;
    }

    .record-table th {
        width: 125px;
        font-size: 12px;
    }

    .field-value {
        font-size: 14px;
    }

    .arabic-value {
        font-size: 20px;
    }

    a.nav-button,
    span.nav-button.is-disabled {
        min-height: 38px;

        padding: 8px 9px;

        font-size: 13px;
    }

    a.alphabet-link,
    span.alphabet-link.is-disabled {
        min-width: 34px;
        min-height: 34px;

        padding: 6px;

        font-size: 19px;
    }
}