/* ============================================================
   Translation page (/Translation) — modern grid + search.
   Scoped under .tr so it can't affect other pages.
   Replaces the old isotope/masonry absolute layout with a
   responsive CSS grid that always aligns into rows.
   ============================================================ */

.tr {
    --tr-brand: #3f51b5;
    --tr-brand-d: #2c3a91;
    --tr-brand-l: #5c6bc0;
    --tr-accent: #ff7a59;
    --tr-ink: #16225a;
    --tr-body: #5a6072;
    --tr-muted: #8a90a2;
    --tr-line: #e4e7f2;
    --tr-bg-soft: #f6f7fb;
    --tr-radius: 16px;

    font-family: 'Roboto', 'Segoe UI', system-ui, sans-serif;
    color: var(--tr-body);
    padding-bottom: 80px;
}
.tr * { box-sizing: border-box; }
.tr__wrap { max-width: 1180px; margin: 0 auto; padding: 0 22px; }

/* ---------- Hero / header ---------- */
.tr-hero {
    text-align: center;
    padding: 54px 22px 40px;
    background: linear-gradient(180deg, #eef1fb 0%, #ffffff 100%);
    border-bottom: 1px solid var(--tr-line);
    margin-bottom: 36px;
}
.tr-hero__eyebrow {
    display: inline-block;
    font-family: 'Montserrat', sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .15em;
    text-transform: uppercase;
    color: var(--tr-brand);
    background: rgba(63, 81, 181, .1);
    padding: 6px 15px;
    border-radius: 999px;
    margin-bottom: 16px;
}
.tr-hero h1 {
    font-family: 'Montserrat', 'Roboto', sans-serif;
    font-size: clamp(24px, 3.2vw, 34px);
    font-weight: 800;
    color: var(--tr-ink);
    margin: 0 0 12px;
    line-height: 1.2;
}
.tr-hero p { margin: 0 auto 26px; max-width: 620px; font-size: 16px; color: var(--tr-body); }

/* ---------- Search ---------- */
.tr-search {
    position: relative;
    max-width: 540px;
    margin: 0 auto;
}
.tr-search > i {
    position: absolute;
    left: 22px; top: 50%;
    transform: translateY(-50%);
    color: var(--tr-brand);
    font-size: 16px;
}
.tr-search input {
    width: 100%;
    height: 58px;
    padding: 0 52px 0 50px;
    border: 1.5px solid var(--tr-line);
    border-radius: 999px;
    background: #fff;
    font-size: 15.5px;
    color: var(--tr-ink);
    box-shadow: 0 14px 30px -18px rgba(22, 27, 51, .35);
    transition: border-color .2s ease, box-shadow .2s ease;
}
.tr-search input:focus {
    outline: none;
    border-color: var(--tr-brand);
    box-shadow: 0 14px 32px -16px rgba(63, 81, 181, .5);
}
.tr-search__clear {
    position: absolute;
    right: 14px; top: 50%;
    transform: translateY(-50%);
    width: 30px; height: 30px;
    border: 0;
    border-radius: 50%;
    background: var(--tr-bg-soft);
    color: var(--tr-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: none;
    transition: background .2s ease, color .2s ease;
}
.tr-search__clear:hover { background: #ffe7e0; color: var(--tr-accent); }
.tr-search.has-text .tr-search__clear { display: block; }

/* ---------- Filter tabs ---------- */
.tr-tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 0 0 34px;
}
.tr-tab {
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--tr-body);
    background: #fff;
    border: 1.5px solid var(--tr-line);
    padding: 9px 18px;
    border-radius: 999px;
    cursor: pointer;
    transition: all .22s ease;
    white-space: nowrap;
}
.tr-tab:hover { border-color: var(--tr-brand-l); color: var(--tr-brand); }
.tr-tab.is-active {
    background: linear-gradient(135deg, var(--tr-brand-l), var(--tr-brand));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 10px 20px -10px rgba(63, 81, 181, .8);
}

/* ---------- Grid ---------- */
.tr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

/* ---------- Card ---------- */
.tr-card {
    position: relative;
    display: flex;
    flex-direction: column;
    border-radius: var(--tr-radius);
    overflow: hidden;
    cursor: pointer;
    background: #fff;
    border: 1px solid var(--tr-line);
    box-shadow: 0 10px 26px -18px rgba(22, 27, 51, .4);
    transition: transform .3s ease, box-shadow .3s ease, border-color .3s ease;
}
.tr-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 22px 40px -20px rgba(22, 27, 51, .5);
    border-color: transparent;
}

/* 3:2 image area using the shared thumbnail */
.tr-card__media {
    position: relative;
    width: 100%;
    padding-top: 66.66%;          /* 1536 x 1024 = 3:2 */
    background: #eef3ff url('../img/translate-thumb.png') center / cover no-repeat;
}

/* Record name placed inside the white "speech-bubble" area (right side) */
.tr-card__name {
    position: absolute;
    left: 42%;
    right: 6%;
    top: 9%;
    bottom: 38%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 8px;
}
.tr-card__name h3 {
    margin: 0;
    font-family: 'Montserrat', 'Roboto', sans-serif;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.28;
    color: var(--tr-ink);
    /* clamp very long names so they stay inside the bubble */
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.tr-card__price {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: var(--tr-brand);
    background: rgba(63, 81, 181, .1);
    padding: 3px 11px;
    border-radius: 999px;
}

/* card footer: name + price under the image */
.tr-card__foot {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 18px 18px;
    background: #fff;
}
.tr-card__title {
    margin: 0;
    font-family: 'Montserrat', 'Roboto', sans-serif;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--tr-ink);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.7em;       /* reserve 2 lines so footers align across a row */
}
.tr-card__footrow {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--tr-line);
}
.tr-card__footprice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 15px;
    color: var(--tr-brand);
}
.tr-card__footprice--muted { color: var(--tr-muted); font-weight: 600; }
.tr-card__select {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'Montserrat', sans-serif;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--tr-accent-d);
    transition: gap .2s ease;
}
.tr-card:hover .tr-card__select { gap: 9px; }

/* ---------- Empty state ---------- */
.tr-empty {
    text-align: center;
    padding: 70px 20px;
    color: var(--tr-muted);
}
.tr-empty i { font-size: 40px; color: var(--tr-line); margin-bottom: 16px; display: block; }
.tr-empty p { margin: 0; font-size: 16px; }

/* ============================================================
   ORDER DIALOG  (#modl / .register-modal)
   Overrides the old template modal (left:25% absolute, 820px).
   ============================================================ */
/* The modal lives OUTSIDE the .tr wrapper, so re-declare the
   CSS variables here or every var(--tr-*) would be undefined
   (invisible borders/backgrounds). */
.register-modal {
    --tr-brand: #3f51b5;
    --tr-brand-d: #2c3a91;
    --tr-brand-l: #5c6bc0;
    --tr-accent: #ff7a59;
    --tr-accent-d: #f4623a;
    --tr-ink: #16225a;
    --tr-body: #5a6072;
    --tr-muted: #8a90a2;
    --tr-line: #e4e7f2;
    --tr-bg-soft: #f6f7fb;
    --tr-radius: 16px;
    font-family: 'Roboto', 'Segoe UI', system-ui, sans-serif;
}
.register-modal.modal { padding: 0 !important; }
.register-modal .modal-content.tr-modal {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
    max-width: 720px;
    margin: 40px auto !important;
    padding: 0 !important;
    text-align: left;
    border: 0;
    border-radius: 18px;
    box-shadow: 0 40px 90px -30px rgba(16, 20, 48, .65);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 70px);
}

/* header */
.tr-modal__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 26px;
    background: linear-gradient(135deg, var(--tr-brand-d), var(--tr-brand));
    color: #fff;
    flex: none;
}
.tr-modal__eyebrow {
    display: block;
    font-family: 'Montserrat', sans-serif;
    font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
    color: rgba(255, 255, 255, .8);
    margin-bottom: 5px;
}
.tr-modal__head h3 { margin: 0; color: #fff; font-family: 'Montserrat', sans-serif; font-size: 19px; font-weight: 700; line-height: 1.3; }
.tr-modal__close {
    flex: none;
    width: 36px; height: 36px;
    border: 0; border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    color: #fff; font-size: 22px; line-height: 1;
    cursor: pointer; opacity: 1; text-shadow: none;
    transition: background .2s ease;
}
.tr-modal__close:hover { background: rgba(255, 255, 255, .32); color: #fff; opacity: 1; }

/* body (scrolls) */
.tr-modal__body { padding: 24px 26px; overflow-y: auto; flex: 1; }

/* footer */
.tr-modal__foot {
    display: flex; justify-content: flex-end; gap: 12px;
    padding: 16px 26px;
    border-top: 1px solid var(--tr-line);
    background: var(--tr-bg-soft);
    flex: none;
}
.tr-modal__btn {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: 'Montserrat', sans-serif; font-weight: 600; font-size: 14px;
    padding: 12px 22px; border-radius: 999px; border: 1.5px solid transparent;
    cursor: pointer; transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.tr-modal__btn--primary { background: linear-gradient(135deg, var(--tr-brand-l), var(--tr-brand)); color: #fff; box-shadow: 0 12px 24px -12px rgba(63, 81, 181, .8); }
.tr-modal__btn--primary:hover { transform: translateY(-2px); }
.tr-modal__btn--cancel { background: #fff; border-color: var(--tr-line); color: var(--tr-body); }
.tr-modal__btn--cancel:hover { border-color: var(--tr-muted); }
.tr-modal__btn--ghost { background: var(--tr-brand); color: #fff; }
.tr-modal__btn--ghost:hover { transform: translateY(-2px); }

/* register lookup */
.tr-modal__reg { background: var(--tr-bg-soft); border: 1px solid var(--tr-line); border-radius: 14px; padding: 16px; margin-bottom: 22px; }
.tr-modal__reg-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--tr-ink); margin-bottom: 10px; }
.tr-modal__reg-label i { color: var(--tr-brand); }
.tr-modal__reg-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tr-modal__reg-inputs { display: flex; gap: 8px; flex: 1; min-width: 220px; }
.tr-modal__reg-inputs select { width: 70px !important; flex: none; padding: 0 8px !important; }
.tr-modal__reg-inputs input { flex: 1; }

/* ---------- Custom fields loaded into #Result (TranslateForm) ---------- */
.trf-section { margin-bottom: 26px; }
.trf-section:last-child { margin-bottom: 0; }
.trf-section__title {
    font-family: 'Montserrat', sans-serif;
    font-size: 15px; font-weight: 700; color: var(--tr-ink);
    margin: 0 0 18px; padding: 0 0 10px;
    border-bottom: 2px solid var(--tr-line);
}
.trf-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 20px; }
.trf-field { display: flex; flex-direction: column; min-width: 0; }
.trf-label {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 600; color: var(--tr-ink);
    margin: 0 0 8px; line-height: 1.35; min-height: 20px;
}
.trf-num {
    display: inline-grid; place-items: center; flex: none;
    width: 21px; height: 21px; border-radius: 50%;
    background: linear-gradient(135deg, var(--tr-brand-l), var(--tr-brand));
    color: #fff; font-size: 11px; font-weight: 700;
}
.trf-empty { padding: 34px; text-align: center; color: var(--tr-muted); font-weight: 600; }

/* Inputs — shared by the register-autofill row and the document fields */
.register-modal input[type="text"],
.register-modal input[type="number"],
.register-modal input[type="date"],
.register-modal .trf-input,
.register-modal #Result select,
.register-modal select.form-control {
    width: 100%; height: 46px;
    border: 1.5px solid var(--tr-line) !important;
    border-radius: 10px !important;
    padding: 0 14px !important;
    font-size: 14px !important;
    color: var(--tr-ink); background: #fff !important; box-shadow: none !important;
    font-family: inherit;
}
.register-modal input:focus, .register-modal select:focus {
    border-color: var(--tr-brand) !important;
    box-shadow: 0 0 0 3px rgba(63, 81, 181, .14) !important;
    outline: none !important;
}
/* Date field: readonly text input that opens the custom Mongolian picker */
.trf-date {
    cursor: pointer;
    padding-right: 40px !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%233f51b5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='2.5' y='3.5' width='11' height='10.5' rx='2'/><path d='M2.5 6.5h11M5.5 1.5v3M10.5 1.5v3'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 13px center !important;
}

/* ---------- Custom Mongolian date picker popup ---------- */
/* NOTE: literal colors (the popup is appended to <body>, outside the .tr scope
   where the --tr-* variables live, so var() would not resolve here). */
.mndp {
    position: absolute;
    z-index: 100060;
    width: 286px;
    padding: 12px;
    background: #fff;
    border: 1px solid #e4e7f2;
    border-radius: 14px;
    box-shadow: 0 22px 55px -14px rgba(22, 27, 51, .4);
    font-family: 'Roboto', 'Segoe UI', system-ui, sans-serif;
    -webkit-user-select: none;
    user-select: none;
}
.mndp * { box-sizing: border-box; }
.mndp__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.mndp__title { font-weight: 700; font-size: 14px; color: #16225a; }
.mndp__nav {
    border: 0; background: #f1f3fb; color: #3f51b5;
    width: 30px; height: 30px; border-radius: 8px;
    font-size: 18px; line-height: 1; cursor: pointer;
    transition: background .15s ease;
}
.mndp__nav:hover { background: #e4e9fb; }
.mndp__wd { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.mndp__wd span { text-align: center; font-size: 11px; font-weight: 700; color: #8a90a2; padding: 4px 0; }
.mndp__days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.mndp__empty { height: 34px; }
.mndp__day {
    border: 0; background: none; height: 34px; border-radius: 8px;
    font-size: 13px; color: #16225a; cursor: pointer;
    transition: background .12s ease;
}
.mndp__day:hover { background: #eef1fb; }
.mndp__day.is-today { color: #3f51b5; font-weight: 700; box-shadow: inset 0 0 0 1.5px rgba(63, 81, 181, .4); }
.mndp__day.is-sel { background: linear-gradient(135deg, #5c6bc0, #3f51b5); color: #fff; font-weight: 700; }
.mndp__foot { display: flex; gap: 8px; margin-top: 10px; }
.mndp__btn {
    flex: 1; padding: 8px; cursor: pointer;
    border: 1px solid #e4e7f2; background: #fff; border-radius: 9px;
    font-size: 12.5px; font-weight: 600; color: #3f51b5;
    transition: background .15s ease;
}
.mndp__btn:hover { background: #f1f3fb; }
@media (max-width: 767px) { .trf-grid { grid-template-columns: 1fr; } }
@media (min-width: 601px) and (max-width: 900px) { .trf-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
    .tr-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
    .tr-hero { padding: 40px 18px 30px; }
    .tr-card__name h3 { font-size: 13px; -webkit-line-clamp: 4; }
}
