/* ==========================================================================
   Universal login / registration component
   Paired with resources/views/components/auth-component.blade.php

   Everything is namespaced under .md-auth. The component is dropped onto
   pages that each ship their own stylesheet, several of which redeclare the
   same base selectors, so nothing here may rely on a page-level rule and
   nothing here may reach outside .md-auth.
   ========================================================================== */

/* The component is dropped onto pages whose own stylesheets vary, so it
   settles its own box model rather than inheriting whatever the host page
   happens to set. Without this the dialog's padding is added to its 100%
   width and the whole sheet overflows a phone viewport. */
.md-auth,
.md-auth *,
.md-auth *::before,
.md-auth *::after {
    box-sizing: border-box;
}

.md-auth {
    --auth-navy: #0d1b4c;
    --auth-blue: #2d6cdf;
    --auth-ink: #1b2436;
    --auth-muted: #5b6b86;
    --auth-line: #dde4ef;
    --auth-danger: #d6432f;
    --auth-radius: 14px;

    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* The gutter the dialog is allowed to sit in. Kept tight on purpose: every
   pixel here is a pixel the tallest step does not have. */

.md-auth.is-open {
    display: flex;
}

.md-auth__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 17, 41, 0.72);
    backdrop-filter: blur(2px);
}

.md-auth__dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    /* A flex item defaults to min-width:auto, which refuses to shrink below
       the widest thing inside it - and a bare <input> reports a min-content
       width of roughly twenty characters. On a phone that pushes the whole
       sheet past the viewport. Every track that holds a control opts out of
       that floor; the controls themselves are width-constrained instead. */
    min-width: 0;
    max-width: 560px;
    margin: auto;
    background: #fff;
    border-radius: var(--auth-radius);
    box-shadow: 0 24px 60px rgba(4, 12, 32, 0.35);
    padding: 26px 28px 22px;
    font-family: Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--auth-ink);
    animation: md-auth-rise 0.22s ease-out;
}

@keyframes md-auth-rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

.md-auth__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: #f1f4f9;
    color: var(--auth-muted);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.md-auth__close:hover {
    background: #e4e9f2;
    color: var(--auth-ink);
}

/* ---------- head ---------- */

.md-auth__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--auth-blue);
    background: #eef4ff;
    border-radius: 999px;
    padding: 4px 10px;
    margin-bottom: 8px;
}

.md-auth__title {
    font-size: 21px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--auth-navy);
    margin: 0 0 6px;
}

.md-auth__subtitle {
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--auth-muted);
    margin: 0 0 14px;
}

/* ---------- tabs ---------- */

.md-auth__tabs {
    display: flex;
    gap: 4px;
    background: #f1f4f9;
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 14px;
}

.md-auth__tab {
    flex: 1;
    border: 0;
    background: transparent;
    border-radius: 7px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--auth-muted);
    cursor: pointer;
}

.md-auth__tab.is-active {
    background: #fff;
    color: var(--auth-navy);
    box-shadow: 0 1px 3px rgba(13, 27, 76, 0.12);
}

/* ---------- alert ---------- */

.md-auth__alert {
    border-radius: 9px;
    padding: 11px 14px;
    font-size: 13.5px;
    line-height: 1.5;
    margin-bottom: 12px;
    background: #fdecea;
    border: 1px solid #f5c6c0;
    color: #8c2a1c;
}

.md-auth__alert.is-success {
    background: #eaf7ee;
    border-color: #bfe3c9;
    color: #1d6b33;
}

.md-auth__alert.is-info {
    background: #eef4ff;
    border-color: #b8d0f8;
    color: var(--auth-navy);
}

/* ---------- steps ---------- */

/* Registration is two short steps. Only one is in the layout at a time; the
   other keeps its values, and its controls stay enabled so that submitting
   from step two still posts everything answered on step one. */
.md-auth__step {
    display: none;
}

.md-auth__step.is-active {
    display: block;
    animation: md-auth-step-in 0.18s ease-out;
}

@keyframes md-auth-step-in {
    from { opacity: 0; transform: translateX(8px); }
    to   { opacity: 1; transform: none; }
}

.md-auth__steps {
    display: flex;
    gap: 8px;
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
}

.md-auth__steps li {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 1;
    padding: 7px 10px;
    border-radius: 8px;
    background: #f6f8fc;
    font-size: 12.5px;
    font-weight: 600;
    color: #93a1b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.md-auth__steps li span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    background: #dfe6f1;
    color: #7a8aa3;
    font-size: 11px;
    font-weight: 700;
}

.md-auth__steps li em {
    font-style: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

.md-auth__steps li.is-current {
    background: #eef4ff;
    color: var(--auth-navy);
}

.md-auth__steps li.is-current span {
    background: var(--auth-blue);
    color: #fff;
}

.md-auth__steps li.is-done span {
    background: #cfe0ff;
    color: var(--auth-blue);
}

.md-auth__back {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    border: 0;
    background: transparent;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--auth-muted);
    cursor: pointer;
}

.md-auth__back:hover {
    color: var(--auth-blue);
}

.md-auth__hint {
    display: block;
    margin-top: 5px;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--auth-muted);
}

/* ---------- panes ---------- */

.md-auth__pane {
    display: none;
}

.md-auth__pane.is-active {
    display: block;
}

.md-auth__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
}

/* Left holding one field because the other does not apply to this persona. */
.md-auth__row.is-single {
    grid-template-columns: minmax(0, 1fr);
}

.md-auth__field {
    margin-bottom: 14px;
    min-width: 0;
}

.md-auth__label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--auth-navy);
    margin-bottom: 6px;
}

.md-auth__label .req {
    color: var(--auth-danger);
}

.md-auth__label .opt {
    font-weight: 400;
    color: var(--auth-muted);
}

.md-auth .md-auth__input {
    display: block;
    width: 100%;
    min-width: 0;
    height: 44px;
    padding: 10px 13px;
    font-family: inherit;
    font-size: 14px;
    color: var(--auth-ink);
    background: #fff;
    border: 1.5px solid var(--auth-line);
    border-radius: 9px;
    box-shadow: none;
    appearance: auto;
}

.md-auth .md-auth__input:focus {
    outline: 0;
    border-color: var(--auth-blue);
    box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.14);
}

.md-auth .md-auth__input.error {
    border-color: var(--auth-danger);
}

.md-auth__input-group {
    position: relative;
}

.md-auth__input-group .md-auth__input {
    padding-right: 64px;
}

.md-auth__reveal {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--auth-blue);
    cursor: pointer;
    padding: 4px 6px;
}

.md-auth__phone {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 8px;
}

.md-auth__input--dial {
    text-align: center;
}

.md-auth__forgot {
    display: inline-block;
    margin-top: 7px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--auth-blue);
    text-decoration: underline;
}

/* ---------- pills, chips, terms ---------- */

.md-auth__pills {
    display: flex;
    gap: 8px;
    min-width: 0;
}

.md-auth__pills label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1.5px solid var(--auth-line);
    border-radius: 9px;
    padding: 8px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--auth-ink);
    cursor: pointer;
    margin: 0;
}

.md-auth__pills input {
    accent-color: var(--auth-blue);
}

.md-auth__picker {
    position: relative;
    min-width: 0;
}

.md-auth__picker-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    height: 44px;
    padding: 10px 13px;
    border: 1.5px solid var(--auth-line);
    border-radius: 9px;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
    color: var(--auth-muted);
    text-align: left;
    cursor: pointer;
}

.md-auth__picker.has-value .md-auth__picker-control {
    color: var(--auth-ink);
}

.md-auth__picker.is-open .md-auth__picker-control {
    border-color: var(--auth-blue);
    box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.14);
}

.md-auth__picker-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The panel overlays the form rather than lengthening it - the whole point of
   the picker is that the options cost no height until they are asked for. */
.md-auth__picker-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 5;
    padding: 8px;
    background: #fff;
    border: 1.5px solid var(--auth-line);
    border-radius: 9px;
    box-shadow: 0 14px 32px rgba(10, 22, 52, 0.18);
}

.md-auth__picker-search {
    width: 100%;
    height: 34px;
    margin-bottom: 6px;
    padding: 6px 10px;
    border: 1.5px solid var(--auth-line);
    border-radius: 7px;
    font-family: inherit;
    font-size: 13px;
    color: var(--auth-ink);
}

.md-auth__picker-search:focus {
    outline: 0;
    border-color: var(--auth-blue);
}

.md-auth__picker-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-height: 206px;
    overflow-y: auto;
}

.md-auth__picker-list label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 400;
    line-height: 1.35;
    color: var(--auth-ink);
    cursor: pointer;
}

.md-auth__picker-list label:hover {
    background: #f1f4f9;
}

.md-auth__picker-list label.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.md-auth__picker-list input {
    margin-top: 2px;
    accent-color: var(--auth-blue);
    flex: none;
}

.md-auth__terms {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--auth-muted);
    margin: 2px 0 0;
    cursor: pointer;
}

.md-auth__terms input {
    margin-top: 2px;
    accent-color: var(--auth-blue);
    flex: none;
}

.md-auth__terms a {
    color: var(--auth-blue);
    font-weight: 600;
    text-decoration: underline;
}

/* ---------- buttons ---------- */

.md-auth__submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    min-height: 48px;
    margin-top: 18px;
    border: 0;
    border-radius: 9px;
    background: var(--auth-blue);
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.md-auth__submit:hover:not(:disabled) {
    background: #2259bd;
}

.md-auth__submit:disabled {
    opacity: 0.65;
    cursor: progress;
}

.md-auth__spinner {
    display: none;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: md-auth-spin 0.7s linear infinite;
}

.md-auth__submit.is-busy .md-auth__spinner {
    display: block;
}

@keyframes md-auth-spin {
    to { transform: rotate(360deg); }
}

.md-auth__secondary {
    display: block;
    width: 100%;
    min-height: 44px;
    margin-top: 10px;
    border: 1.5px solid var(--auth-line);
    border-radius: 9px;
    background: #fff;
    color: var(--auth-navy);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.md-auth__secondary:hover {
    border-color: var(--auth-blue);
    color: var(--auth-blue);
}

.md-auth__swap {
    margin: 10px 0 0;
    font-size: 13.5px;
    text-align: center;
    color: var(--auth-muted);
}

.md-auth__swap button {
    border: 0;
    background: transparent;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    font-weight: 700;
    color: var(--auth-blue);
    cursor: pointer;
    text-decoration: underline;
}

/* The way out of a component that cannot be dismissed. Deliberately quiet -
   it is the option, not the offer - but a real link, not a styled button, so
   it behaves like one. */
.md-auth__exit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 12px -28px -22px;
    padding: 12px;
    border-top: 1px solid var(--auth-line);
    border-radius: 0 0 var(--auth-radius) var(--auth-radius);
    background: #f8fafd;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--auth-muted);
    text-decoration: none;
}

.md-auth__exit:hover {
    background: #f1f4f9;
    color: var(--auth-navy);
    text-decoration: none;
}

/* ---------- identity row, notes, errors ---------- */

.md-auth__identity {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: #f1f4f9;
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 13.5px;
    color: var(--auth-muted);
    margin: 0 0 16px;
}

.md-auth__identity button {
    border: 0;
    background: transparent;
    padding: 0;
    color: var(--auth-blue);
    cursor: pointer;
    line-height: 1;
}

.md-auth__note {
    background: #eef4ff;
    border: 1px solid #b8d0f8;
    border-radius: 9px;
    padding: 11px 14px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--auth-navy);
    margin-bottom: 16px;
}

.md-auth__resend {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    font-size: 12.5px;
    color: var(--auth-muted);
}

.md-auth__resend button {
    border: 0;
    background: transparent;
    padding: 0;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--auth-blue);
    cursor: pointer;
}

.md-auth .md-auth__error {
    display: none;
    margin-top: 5px;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--auth-danger);
}

.md-auth .md-auth__error.is-shown {
    display: block;
}

/* The page-wide validator in js/custom-form-validation.js injects its own
   markup after a field; give it the same voice as our own messages. */
.md-auth .error-box .error,
.md-auth .error-box .lable-error {
    display: block;
    margin-top: 5px;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--auth-danger);
}

/* ---------- narrow screens ---------- */

@media (max-width: 575.98px) {
    .md-auth {
        padding: 0;
    }

    .md-auth__dialog {
        max-width: none;
        min-height: 100%;
        border-radius: 0;
        padding: 22px 16px 28px;
    }

    .md-auth__row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .md-auth__exit {
        margin: 16px -16px -28px;
    }

    .md-auth__title {
        font-size: 19px;
    }
}
