﻿/**
 * Portal Login CSS additions
 * Append to the end of the portal's existing login CSS file.
 * Uses .pw-wrapper (not .input-with-toggle) to avoid conflicts
 * with existing .form-input rules.
 */

/* ── CSS var bridge (portal.css --color-* / themes.css --primary-blue) ── */
:root {
	/* NEW — in the artifact */
	--login-color-primary:   var(--palette-secondary-dark, var(--primary-blue,    #0c488e));
	--login-color-secondary: var(--palette-primary,        var(--secondary-green, #148A2F));
	--login-color-border:    var(--color-border,           var(--border-color,    #dddddd));
	--login-color-bg:        var(--color-surface,          var(--white,           #ffffff));
	--login-color-text:      var(--color-on-surface,       var(--text-dark,       #333333));
	--login-focus-ring:      var(--focus-outline,   3px solid #4a90e2);
	--login-radius:          var(--border-radius,   12px);
	--login-transition:      var(--transition-speed, 0.3s);
}

/* ── form-input: apply bridge vars ──────────────────────────────────── */
.form-input {
    border-color:     var(--login-color-border);
    color:            var(--login-color-text);
    background-color: var(--login-color-bg);
    border-radius:    var(--login-radius);
    box-sizing:       border-box;
}
.form-input:focus {
    outline:      var(--login-focus-ring);
    border-color: var(--login-color-primary);
}
.form-input:hover  { border-color: var(--login-color-secondary); }
.form-input[aria-invalid=true] {
    border-color:     #dc3545;
    background-color: #fff5f5;
}

/* ── Field error ─────────────────────────────────────────────────────── */
.field-error         { display: block; margin-top: 0.25rem; font-size: 0.875em; color: #dc3545; }
.field-error[hidden] { display: none; }

/* ── Password wrapper — owns positioning only, no visual styles ──────── */
.pw-wrapper { position: relative; display: block; }

/* Right-pad the password input to make room for the toggle button */
.pw-wrapper .pw-input {
    padding-right: 2.75rem !important;
    width: 100%;
    box-sizing: border-box;
}

/* ── Toggle button ───────────────────────────────────────────────────── */
/*
 * Uses mask-image + background-color for the icon (technique from pwshowhide).
 * background-color IS the icon colour — no background-image URI conflicts.
 * The button is inset by the border width on three sides so it sits flush
 * inside the field chrome with matching inner border-radius.
 * Icon swap driven by [aria-pressed]; JS only sets aria-pressed + input type.
 */
.pw-toggle {
    appearance: none;
    -webkit-appearance: none;

    /* Icon colour — change this one value to re-theme */
    background-color: var(--login-color-secondary) !important;

    /* Eye icon via mask so background-color paints it */
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M15 12a3 3 0 11-6 0 3 3 0 016 0z M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z'/></svg>");
            mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M15 12a3 3 0 11-6 0 3 3 0 016 0z M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z'/></svg>");
    -webkit-mask-repeat:   no-repeat;
            mask-repeat:   no-repeat;
    -webkit-mask-position: center;
            mask-position: center;
    -webkit-mask-size:     1.25rem;
            mask-size:     1.25rem;

    border:  0;
    margin:  0;
    padding: 0;
    cursor:  pointer;

    /* Inset by border width on the three inner sides so the button sits
       flush within the field chrome; left edge stays square */
    position:      absolute;
    top:           2px;
    right:         2px;
    bottom:        2px;
    width:         2.5rem;
    border-radius: 0 10px 10px 0;   /* 10px = input's 12px radius − 2px border */

    opacity:    0.7;
    transition: opacity var(--login-transition), background-color var(--login-transition);
    z-index: 1;
}

/* Eye-slash icon when password is revealed */
.pw-toggle[aria-pressed=true] {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M15 12a3 3 0 11-6 0 3 3 0 016 0z M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z M3 3l18 18'/></svg>");
            mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M15 12a3 3 0 11-6 0 3 3 0 016 0z M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z M3 3l18 18'/></svg>");
}

.pw-toggle:hover,
.pw-wrapper:hover .pw-toggle {
    opacity: 1;
    background-color: var(--login-color-primary) !important;
}
.pw-toggle:focus-visible {
    outline:        var(--login-focus-ring);
    outline-offset: 2px;
    opacity: 1;
}

/* ── login-button: use bridge vars ───────────────────────────────────── */
.login-button                { background-color: var(--login-color-primary); border-radius: var(--login-radius); }
.login-button:hover          { background-color: var(--button-hover, #0056b3); }
.login-button:focus-visible  { outline: var(--login-focus-ring); }

/* ── password-link ───────────────────────────────────────────────────── */
.password-link               { color: var(--login-color-primary); }
.password-link:hover         { color: var(--login-color-secondary); }
.password-link:focus-visible { outline: var(--login-focus-ring); outline-offset: 2px; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .form-actions  { flex-direction: column-reverse; align-items: stretch; }
    .login-button  { width: 100%; }
    .password-link { text-align: center; }
}

/* ── Screen-reader only ──────────────────────────────────────────────── */
.sr-only {
    position:   absolute;
    width:      1px;
    height:     1px;
    padding:    0;
    margin:     -1px;
    overflow:   hidden;
    clip:       rect(0 0 0 0);
    white-space: nowrap;
    border:     0;
}