/* Qupia login theme.
 *
 * Tokens are kept identical to qupia_frontend/src/assets/main.css so the hosted
 * Keycloak pages and the Vue application cannot drift apart visually. The base
 * Keycloak theme contributes no styling, so every rule needed is here. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --blue: #3b5bfd;
    --blue-hover: #2f4fe0;
    --blue-light: #eef2ff;
    --blue-border: #bcd0fb;
    --panel-bg: #eef4fd;
    --border: #e1e7f5;
    --surface: #ffffff;
    --text: #1c2333;
    --text-muted: #8a93a6;
    --text-soft: #6b7280;
    --danger: #b91c1c;
    --danger-bg: #fee2e2;
    --danger-border: #fca5a5;
    --warn-bg: #fff7e6;
    --warn-border: #ffe4a3;
    --warn-text: #8a6100;
    --success-bg: #ecfdf5;
    --success-border: #a7f3d0;
    --success-text: #065f46;
    --radius: 10px;
    --focus: 0 0 0 3px rgba(59, 91, 253, 0.28);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

.qupia-html {
    height: 100%;
}

.qupia-body {
    margin: 0;
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    background: var(--panel-bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
        Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* The base template nests: .qupia-page > #kc-header + .qupia-card > header +
   #kc-content. The width cap therefore belongs on the page wrapper, which is
   the only element that contains both the brand header and the card. */
.qupia-page {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.qupia-container,
.qupia-content {
    width: 100%;
}

/* Card ------------------------------------------------------------------- */

.qupia-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px;
    box-shadow: 0 1px 2px rgba(28, 35, 51, 0.04),
        0 12px 32px rgba(28, 35, 51, 0.06);
}

/* Holds the locale switcher above the title; it must not overlap the heading. */
.qupia-card-header {
    display: block;
}

#kc-page-title {
    margin: 0 0 24px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-align: center;
}

/* The base template prints the realm display name as a heading above the card. */
#kc-header-wrapper {
    margin-bottom: 20px;
    text-align: center;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
}

/* Fields ----------------------------------------------------------------- */

.qupia-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.qupia-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.qupia-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}


.qupia-input {
    width: 100%;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.qupia-input::placeholder {
    color: var(--text-muted);
}

.qupia-input:hover {
    border-color: var(--blue-border);
}

.qupia-input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: var(--focus);
}

.qupia-input[aria-invalid='true'] {
    border-color: var(--danger-border);
}

/* Password field with its show/hide button. */
.qupia-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.qupia-input-group .qupia-input {
    padding-right: 44px;
}

.qupia-password-toggle {
    position: absolute;
    right: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
}

.qupia-password-toggle:hover {
    color: var(--text);
    background: var(--track, #f1f4fb);
}

.qupia-password-toggle:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

/* The eye glyphs are drawn with CSS masks: dropping PatternFly also dropped
   FontAwesome, and these are the only two icons the base templates request. */
.qupia-icon-eye,
.qupia-icon-eye-off {
    display: block;
    width: 18px;
    height: 18px;
    background-color: currentColor;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
}

.qupia-icon-eye {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
}

.qupia-icon-eye-off {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17.9 17.9A10.1 10.1 0 0 1 12 19C5.6 19 2 12 2 12a18 18 0 0 1 5.1-5.9m3-1.4A10.1 10.1 0 0 1 12 5c6.4 0 10 7 10 7a18 18 0 0 1-2.2 3.2M1 1l22 22'/%3E%3Cpath d='M9.9 9.9a3 3 0 0 0 4.2 4.2'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17.9 17.9A10.1 10.1 0 0 1 12 19C5.6 19 2 12 2 12a18 18 0 0 1 5.1-5.9m3-1.4A10.1 10.1 0 0 1 12 5c6.4 0 10 7 10 7a18 18 0 0 1-2.2 3.2M1 1l22 22'/%3E%3Cpath d='M9.9 9.9a3 3 0 0 0 4.2 4.2'/%3E%3C/svg%3E");
}

.qupia-field-error {
    font-size: 12px;
    color: var(--danger);
}

.qupia-help {
    font-size: 12px;
    color: var(--text-soft);
}

/* Options row ------------------------------------------------------------ */

.qupia-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
}

.qupia-check-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-soft);
    cursor: pointer;
}

.qupia-check-input {
    width: 16px;
    height: 16px;
    accent-color: var(--blue);
    cursor: pointer;
}

.qupia-link {
    color: var(--blue);
    font-weight: 500;
    text-decoration: none;
}

.qupia-link:hover {
    color: var(--blue-hover);
    text-decoration: underline;
}

/* Buttons ---------------------------------------------------------------- */

.qupia-buttons {
    margin-top: 4px;
}

.qupia-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.qupia-button-block {
    width: 100%;
}

.qupia-button-primary {
    background: var(--blue);
    color: #fff;
}

.qupia-button-primary:hover {
    background: var(--blue-hover);
}

.qupia-button-default {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.qupia-button-default:hover {
    border-color: var(--blue-border);
}

.qupia-button:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

.qupia-button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Identity providers ----------------------------------------------------- */

.qupia-social {
    margin-top: 24px;
}

.qupia-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    color: var(--text-muted);
    font-size: 12px;
}

.qupia-divider::before,
.qupia-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.qupia-social-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.qupia-social-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 11px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.qupia-social-button:hover {
    border-color: var(--blue-border);
    background: var(--blue-light);
}

.qupia-social-button:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

.qupia-social-button-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.qupia-social-logo {
    flex: none;
}

/* Footer ----------------------------------------------------------------- */

.qupia-foot {
    margin-top: 24px;
    text-align: center;
    font-size: 13px;
    color: var(--text-soft);
}

#kc-info {
    margin-top: 0;
}

/* Alerts ----------------------------------------------------------------- */

.qupia-alert {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding: 12px 14px;
    border: 1px solid;
    border-radius: var(--radius);
    font-size: 13px;
}

.qupia-alert .pf-c-alert__icon {
    display: none;
}

.alert-error {
    color: var(--danger);
    background: var(--danger-bg);
    border-color: var(--danger-border);
}

.alert-warning {
    color: var(--warn-text);
    background: var(--warn-bg);
    border-color: var(--warn-border);
}

.alert-success {
    color: var(--success-text);
    background: var(--success-bg);
    border-color: var(--success-border);
}

.alert-info {
    color: var(--text);
    background: var(--blue-light);
    border-color: var(--blue-border);
}

/* Locale switcher -------------------------------------------------------- */

.qupia-locale {
    position: relative;
    display: flex;
    justify-content: flex-end;
    /* Pulled toward the card's top padding so it reads as a corner control
       rather than a row competing with the page title. */
    margin: -12px -8px 8px 0;
}

.qupia-locale button {
    padding: 6px 10px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-soft);
    background: none;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
}

.qupia-locale button:hover {
    color: var(--text);
    border-color: var(--border);
}

.qupia-locale-list {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 10;
    min-width: 140px;
    margin: 4px 0 0;
    padding: 4px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(28, 35, 51, 0.1);
}

/* The base template toggles this attribute from its own dropdown script. */
#kc-current-locale-link[aria-expanded='false'] + .qupia-locale-list {
    display: none;
}

.qupia-locale-list a {
    display: block;
    padding: 8px 10px;
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
    border-radius: 6px;
}

.qupia-locale-list a:hover {
    background: var(--blue-light);
}

/* Utilities -------------------------------------------------------------- */

.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;
}

#kc-form-options,
.qupia-options-wrap,
.qupia-input-wrap {
    display: contents;
}

/* user-profile-commons.ftl emits the required marker as a bare "*" text node
   next to the label, not inside it. This wrapper must therefore stay a real box
   that lays both out on one line; display:contents would promote the asterisk
   into a column flex item and drop it onto its own row. */
.qupia-label-wrap {
    display: flex;
    align-items: baseline;
    gap: 4px;
    color: var(--danger);
    font-size: 13px;
    font-weight: 600;
}

@media (max-width: 480px) {
    .qupia-body {
        padding: 16px;
    }

    .qupia-card {
        padding: 24px 20px;
    }
}
