/*------------------------------------------------------------------
  Auth (signin / signup) — full-bleed split screen
  Built entirely on the existing token contract in
  sass/component/_variable.scss + partials/theme-tokens.blade.php
-------------------------------------------------------------------*/

.auth-split {
    /* Measured height of topbar + navbar. Only a min-height, so a header of a
       different height just means a slightly shorter/taller visual panel. */
    --auth-header-offset: 130px;
    --auth-gutter: 4rem;

    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    min-height: calc(100vh - var(--auth-header-offset));
    /* Use --white / --white-3, not the --surface-* aliases: the surface aliases
       resolve against :root and so stay light under .dark-mode. */
    background-color: var(--white);
}

/* ============================================================
   Left — visual panel
   ============================================================ */

.auth-visual {
    position: relative;
    overflow: hidden;
    background-color: var(--white-3);
}

.auth-visual__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Scrim keeps the overlay copy readable over any uploaded image. */
.auth-visual::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(var(--primary-color), 0.15) 0%,
        rgba(0, 0, 0, 0.15) 45%,
        rgba(0, 0, 0, 0.72) 100%
    );
}

.auth-visual__content {
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: var(--auth-gutter);
    color: #fff;
}

.auth-visual__title {
    font-family: var(--secondary-font);
    font-size: clamp(1.75rem, 2.2vw, 2.5rem);
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.75rem;
    color: #fff;
}

.auth-visual__text {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 0;
    max-width: 46ch;
    color: rgba(255, 255, 255, 0.82);
}

/* ============================================================
   Right — form panel
   ============================================================ */

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--auth-gutter) 3rem;
    background-color: var(--white);
}

.auth-panel__inner {
    width: 100%;
    max-width: 440px;
}

.auth-split--wide .auth-panel__inner {
    max-width: 620px;
}

.auth-head {
    margin-bottom: 2rem;
}

.auth-head__title {
    font-family: var(--secondary-font);
    font-size: clamp(1.75rem, 2vw, 2.25rem);
    font-weight: 600;
    line-height: 1.15;
    color: var(--primary-text-color);
    margin-bottom: 0.5rem;
}

.auth-head__text {
    font-size: 1rem;
    color: var(--secondary-text-color);
    margin-bottom: 0;
}

/* ============================================================
   Fields
   ============================================================ */

/* The control wrapper — not .auth-field — is the positioning context, so the
   icons centre against the input itself rather than the label + input stack. */
.auth-field__control {
    position: relative;
}

.auth-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary-text-color);
    margin-bottom: 0.5rem;
}

.auth-field .form-control,
.auth-field .form-select {
    width: 100%;
    padding: 0.9rem 1rem 0.9rem 2.875rem;
    font-size: 1rem;
    line-height: 1.4;
    color: var(--color-input-text);
    background-color: var(--color-input-bg);
    border: 1px solid var(--color-input-border);
    border-radius: var(--rounded-square);
    box-shadow: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-field textarea.form-control {
    padding-top: 0.9rem;
    resize: vertical;
    min-height: 7rem;
}

/* Password fields leave room for the reveal toggle. */
.auth-field .form-control.c-password {
    padding-right: 3rem;
}

.auth-field .form-control::placeholder {
    color: var(--color-input-placeholder);
    opacity: 1;
}

.auth-field .form-control:focus,
.auth-field .form-select:focus {
    outline: none;
    border-color: rgba(var(--primary-color), 0.85);
    box-shadow: 0 0 0 4px rgba(var(--primary-color), 0.12);
}

.auth-field .form-select {
    /* Native arrow sits inside the padding box; keep it clear of the icon. */
    background-position: right 1rem center;
    cursor: pointer;
}

/* Icons */
.auth-field .first-icon,
.auth-field .second-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    font-size: 0.95rem;
    color: var(--secondary-text-color);
    pointer-events: none;
    transition: color 0.2s ease;
    z-index: 2;
}

.auth-field .first-icon {
    left: 1.0625rem;
}

.auth-field .second-icon {
    right: 1.0625rem;
    cursor: pointer;
    pointer-events: auto;
}

.auth-field .second-icon:hover {
    color: rgba(var(--primary-color), 1);
}

/* Textarea icon aligns to the first line, not the middle of the box. */
.auth-field--textarea .first-icon {
    top: 1.0625rem;
    transform: none;
}

.auth-field__control:focus-within .first-icon {
    color: rgba(var(--primary-color), 1);
}

/* Error state */
.auth-error {
    display: block;
    font-size: 0.8125rem;
    color: rgb(var(--danger-color));
    margin-top: 0.5rem;
}

.auth-field .form-control.is-invalid,
.auth-field .form-select.is-invalid {
    border-color: rgb(var(--danger-color));
}

/* Drop Bootstrap's injected validation glyph — it collides with the password
   reveal toggle, and the red border plus .auth-error message already say it.
   Scoped to .form-control so .form-select keeps its dropdown arrow. */
.auth-field .form-control.is-invalid {
    background-image: none;
}

.auth-field .form-control.is-invalid:focus,
.auth-field .form-select.is-invalid:focus {
    box-shadow: 0 0 0 4px rgba(var(--danger-color), 0.12);
}

/* ============================================================
   Meta row / links / submit
   ============================================================ */

.auth-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.auth-meta .form-check {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.auth-meta .form-check-input {
    margin: 0;
    float: none;
}

.auth-meta .form-check-label,
.auth-policy .form-check-label {
    font-size: 0.9375rem;
    color: var(--secondary-text-color);
    cursor: pointer;
}

.auth-link {
    font-size: 0.9375rem;
    font-weight: 500;
    color: rgba(var(--primary-color), 1);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.auth-link:hover {
    opacity: 0.75;
    text-decoration: underline;
}

.auth-policy {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.auth-policy .form-check-input {
    margin: 0.2rem 0 0 0;
    float: none;
    flex-shrink: 0;
}

.auth-submit {
    width: 100%;
    padding: 1.05rem 2rem;
}

/* ============================================================
   Divider
   ============================================================ */

.auth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--secondary-text-color);
    font-size: 0.875rem;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background-color: var(--border-color-2);
}

/* ============================================================
   Social + demo buttons
   ============================================================ */

.auth-social {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 0.75rem;
}

.auth-social__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--primary-text-color);
    background-color: transparent;
    border: 1px solid var(--border-color-2);
    border-radius: var(--rounded-square);
    text-decoration: none;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.auth-social__btn i {
    font-size: 1.125rem;
}

.auth-social__btn:hover {
    color: rgba(var(--primary-color), 1);
    border-color: rgba(var(--primary-color), 0.5);
    background-color: rgba(var(--primary-color), 0.04);
}

.auth-demo__label {
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--secondary-text-color);
    margin-bottom: 0.75rem;
}

.auth-demo__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.625rem;
}

.auth-demo__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--secondary-text-color);
    background-color: transparent;
    border: 1px dashed var(--border-color-2);
    border-radius: var(--rounded-square);
    text-decoration: none;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.auth-demo__btn:hover {
    color: rgba(var(--primary-color), 1);
    border-color: rgba(var(--primary-color), 0.6);
    border-style: solid;
    background-color: rgba(var(--primary-color), 0.04);
}

.auth-foot {
    font-size: 0.9375rem;
    color: var(--secondary-text-color);
    text-align: center;
    margin-bottom: 0;
}

/* ============================================================
   RTL
   ============================================================ */

[dir="rtl"] .auth-field .form-control,
[dir="rtl"] .auth-field .form-select {
    padding: 0.9rem 2.875rem 0.9rem 1rem;
}

[dir="rtl"] .auth-field .form-control.c-password {
    padding-left: 3rem;
}

[dir="rtl"] .auth-field .first-icon {
    left: auto;
    right: 1.0625rem;
}

[dir="rtl"] .auth-field .second-icon {
    right: auto;
    left: 1.0625rem;
}

[dir="rtl"] .auth-field .form-select {
    background-position: left 1rem center;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 991.98px) {
    .auth-split {
        grid-template-columns: minmax(0, 1fr);
        min-height: 0;
    }

    /* Matches the previous d-lg-block d-none behaviour. */
    .auth-visual {
        display: none;
    }

    .auth-panel {
        padding: 3rem 1.5rem;
    }
}

@media (max-width: 575.98px) {
    .auth-panel {
        padding: 2.5rem 1.25rem;
    }

    .auth-demo__grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ============================================================
   Motion
   ============================================================ */

.auth-panel__inner > * {
    animation: auth-rise 0.5s ease-out both;
}

.auth-panel__inner > *:nth-child(2) {
    animation-delay: 0.06s;
}

.auth-panel__inner > *:nth-child(3) {
    animation-delay: 0.12s;
}

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

@media (prefers-reduced-motion: reduce) {
    .auth-panel__inner > * {
        animation: none;
    }

    .auth-field .form-control,
    .auth-field .form-select,
    .auth-social__btn,
    .auth-demo__btn,
    .auth-link {
        transition: none;
    }
}
