/*
 * Registration (resources/views/auth/register.blade.php + livewire/user/new-register.blade.php).
 * Builds on the shared authentication styles (auth-login.css) and adds: a wider card, the two-column form grid,
 * the terms step, and a skin for the TomSelect widgets (searchable selects) so they look like the other fields.
 */

.al-card--wide {
    max-width: 680px;
}

/* ------------------------------------------------------------------ */
/* Steps                                                               */
/* ------------------------------------------------------------------ */

@media (prefers-reduced-motion: no-preference) {
    .al-register .al-step {
        animation: al-fade-up .5s var(--al-ease) both;
    }
}

.al-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    margin: 0 0 1rem;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--al-ink);
}

.al-section .al-icon {
    width: 23px;
    height: 23px;
    color: var(--al-blue-700);
}

.al-terms {
    max-height: 320px;
    margin-bottom: 1.1rem;
    padding: 1rem 1.15rem;
    overflow: auto;
    border: 1.5px solid var(--al-line);
    border-radius: var(--al-radius);
    background: #f8fafd;
    color: #243556;
    font-size: .97rem;
    line-height: 1.85;
    transition: border-color .22s ease, box-shadow .22s ease;
}

.al-terms:focus-visible {
    outline: 0;
    border-color: var(--al-blue);
    box-shadow: 0 0 0 4px rgba(22, 119, 230, .15);
}

.al-terms h1,
.al-terms h2,
.al-terms h3,
.al-terms h4,
.al-terms h5,
.al-terms h6 {
    margin: 0 0 .6rem;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--al-ink);
}

.al-terms p {
    margin: 0 0 .8rem;
}

.al-terms ul,
.al-terms ol {
    padding-inline-start: 1.4rem;
}

.al-hint {
    margin: .5rem 0 0;
    font-size: .9rem;
    font-weight: 600;
    text-align: center;
    color: var(--al-muted);
}

.al-register .al-step > .al-remember {
    display: flex;
    justify-content: center;
    margin: 0 0 .4rem;
}

.al-register .al-step > .al-btn {
    margin-top: 1.2rem;
}

.al-btn[disabled] {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    background-position: 0 0;
}

.al-back {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    margin: 0 0 1.3rem;
    padding: .45rem .95rem;
    border: 1px solid #dfe5ee;
    border-radius: 999px;
    background: #fff;
    color: var(--al-ink);
    font: inherit;
    font-size: .95rem;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    transition: border-color .2s ease, background-color .2s ease, color .2s ease, box-shadow .2s ease;
}

.al-back:hover {
    border-color: var(--al-blue);
    background: #f0f5fc;
    color: var(--al-blue-700);
}

.al-back:focus-visible {
    outline: 0;
    border-color: var(--al-blue);
    box-shadow: 0 0 0 4px rgba(22, 119, 230, .16);
}

.al-back__icon {
    width: 18px;
    height: 18px;
}

/* the shared arrow icon points right: flip it where the reading direction needs it */
html[dir="rtl"] .al-flip-rtl,
html[dir="ltr"] .al-flip-ltr {
    scale: -1 1;
}

.al-register .al-links {
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: 1.4rem;
}

.al-links__text {
    font-weight: 600;
    color: var(--al-muted);
}

.al-link--inline {
    flex: none;
    padding: .3rem .55rem;
}

/* ------------------------------------------------------------------ */
/* Form grid                                                           */
/* ------------------------------------------------------------------ */

.al-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    column-gap: 16px;
    row-gap: 1.35rem;
}

.al-grid > .al-field {
    margin-bottom: 0;
}

.al-grid > .mb-2 {
    margin-bottom: 0 !important; /* the nested <livewire:select2> wrapper carries Bootstrap's mb-2 */
}

.al-grid__full {
    grid-column: 1 / -1;
}

.al-grid__full > .al-field {
    margin-bottom: 0;
}

.al-grid__full > .al-btn {
    margin-top: .3rem;
}

/* nested <livewire:select2> markup (label + select + error) dressed like the other fields */
.al-register .al-field > .form-group {
    margin: 0;
}

.al-register .al-field > .form-group > label {
    display: flex;
    align-items: center;
    gap: .55rem;
    margin: 0 0 .7rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--al-ink);
}

.al-register .form-control-feedback {
    display: block;
    margin-top: .5rem;
    font-size: .9rem;
    font-weight: 600;
    line-height: 1.45;
    color: var(--al-danger);
}

.al-register .al-field > .form-group > select.form-control:not(.tomselected) {
    display: block;
    width: 100%;
    height: 54px;
    padding: 0 16px;
    border: 1.5px solid var(--al-line);
    border-radius: var(--al-radius);
    background: #fff;
    color: var(--al-ink);
    font-size: 1rem;
    font-weight: 600;
    box-shadow: none;
}

/* ------------------------------------------------------------------ */
/* TomSelect skin                                                      */
/* ------------------------------------------------------------------ */

.al-card .ts-wrapper {
    width: 100%;
}

.al-card .ts-wrapper.single .ts-control,
.al-card .ts-wrapper.multi .ts-control,
.al-card .ts-control {
    display: flex;
    align-items: center;
    min-height: 54px;
    padding: 0 38px 0 16px;
    border: 1.5px solid var(--al-line);
    border-radius: var(--al-radius);
    background: #fff;
    box-shadow: none;
    color: var(--al-ink);
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .22s ease, box-shadow .22s ease;
}

.al-card .ts-wrapper.rtl.single .ts-control {
    padding: 0 16px 0 38px;
}

.al-card .ts-control > .item {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.al-card .ts-control input {
    color: var(--al-ink);
    font: inherit;
}

.al-card .ts-wrapper:hover .ts-control {
    border-color: var(--al-line-hover);
}

.al-card .ts-wrapper.focus .ts-control {
    border-color: var(--al-blue);
    box-shadow: 0 0 0 4px rgba(22, 119, 230, .15);
}

/* caret (inline SVG, same chevron as the other selects); right side, left side for right-to-left wrappers */
.al-card .ts-wrapper.single .ts-control {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%230b1f4b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-size: 16px 12px;
    background-position: right 14px center;
}

.al-card .ts-wrapper.rtl.single .ts-control {
    background-position: left 14px center;
}

.al-card .ts-wrapper.is-invalid .ts-control {
    border-color: var(--al-danger);
}

.al-card .ts-wrapper.is-invalid.focus .ts-control {
    box-shadow: 0 0 0 4px rgba(198, 40, 57, .14);
}

.al-card .ts-dropdown {
    margin-top: 6px;
    overflow: hidden;
    border: 1px solid #e3e8f1;
    border-radius: 14px;
    box-shadow: 0 14px 34px -14px rgba(11, 31, 75, .32);
    color: var(--al-ink);
    font-weight: 600;
}

.al-card .ts-dropdown .option,
.al-card .ts-dropdown .no-results {
    padding: .6rem .9rem;
}

.al-card .ts-dropdown .active {
    background: #eaf2fd;
    color: var(--al-blue-900);
}

.al-card .ts-dropdown .dropdown-input {
    border-color: #e3e8f1;
    font: inherit;
}

/* the country-code selects keep their left-to-right reading ("+218") and draw their own caret */
.al-select .ts-wrapper {
    direction: ltr;
}

.al-select .ts-wrapper ~ .al-select__chev {
    display: none;
}

.al-select .ts-wrapper.single .ts-control {
    padding: 0 30px 0 14px;
    font-weight: 700;
    background-position: right 10px center;
}

.al-select .ts-dropdown {
    min-width: 150px;
}

/* the wrapper must not inherit the look of the select it replaces (belt and braces next to the class removal in register.blade.php) */
.al-card .ts-wrapper.al-select__control,
.al-card .ts-wrapper.form-control {
    height: auto;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
}

.al-register .al-select {
    flex: 0 0 124px;
    min-width: 0;
}

.al-register .al-phone .al-input {
    min-width: 0;
}

.al-card .ts-control > input {
    min-width: 0 !important; /* TomSelect gives its search box a 7rem minimum, which made the code select wider than its column */
    width: 100% !important;
}

/* ------------------------------------------------------------------ */
/* Dark mode (tokens and the shared fields come from auth-login.css)   */
/* ------------------------------------------------------------------ */

@media screen {
    html[data-theme="dark"] .al-terms {
        background: #121a28;
        color: #c9d3e3;
    }

    html[data-theme="dark"] .al-back {
        border-color: #2c374d;
        background: #161e2d;
    }

    html[data-theme="dark"] .al-back:hover {
        border-color: #4a8af0;
        background: #1f2a3e;
    }

    html[data-theme="dark"] .al-register .al-field > .form-group > select.form-control:not(.tomselected),
    html[data-theme="dark"] .al-card .ts-wrapper.single .ts-control,
    html[data-theme="dark"] .al-card .ts-wrapper.multi .ts-control,
    html[data-theme="dark"] .al-card .ts-control {
        background-color: #161e2d;
    }

    /* same chevron, drawn in the light ink colour */
    html[data-theme="dark"] .al-card .ts-wrapper.single .ts-control {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23e6ecf6' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    }

    html[data-theme="dark"] .al-card .ts-wrapper.focus .ts-control {
        border-color: #4a8af0;
        box-shadow: 0 0 0 4px rgba(74, 138, 240, .22);
    }

    html[data-theme="dark"] .al-card .ts-dropdown {
        border-color: #2c374d;
        background: #161e2d;
        box-shadow: 0 14px 34px -14px rgba(0, 0, 0, .7);
    }

    html[data-theme="dark"] .al-card .ts-dropdown .option {
        color: var(--al-ink);
    }

    html[data-theme="dark"] .al-card .ts-dropdown .active {
        background: #1e2b4d;
        color: var(--al-blue-900);
    }

    html[data-theme="dark"] .al-card .ts-dropdown .dropdown-input,
    html[data-theme="dark"] .al-card .ts-dropdown .dropdown-input-wrap {
        border-color: #2c374d;
        background: #121a28;
        color: var(--al-ink);
    }

    html[data-theme="dark"] .al-card .ts-dropdown .no-results,
    html[data-theme="dark"] .al-card .ts-dropdown .optgroup-header {
        background: #161e2d;
        color: var(--al-muted);
    }
}
