/**
 * CAVI Usher theme override for SimpleSAMLphp.
 *
 * Loaded after the base stylesheet.css via _header.twig preload block.
 * Applies the dark, modern, high-contrast CAVI design language to the
 * SimpleSAMLphp page shell, forms, buttons, language bar, and the
 * multiauth social-login picker.
 */

/* ---------- design tokens ---------- */

:root {
    --bg:           #0f1117;
    --surface:      #171a23;
    --surface-2:    #1e212c;
    --surface-3:    #262a38;
    --border:       #2c2f3d;
    --border-light: #393d4f;
    --text:         #c8cad3;
    --text-bright:  #f0f1f5;
    --text-muted:   #777a88;
    --accent:       #5b8def;
    --accent-glow:  rgba(91, 141, 239, .15);
    --accent-soft:  rgba(91, 141, 239, .08);
    --green:        #4ade80;
    --green-bg:     rgba(74, 222, 128, .08);
    --green-border: rgba(74, 222, 128, .25);
    --red:          #f87171;
    --red-bg:       rgba(248, 113, 113, .08);
    --red-border:   rgba(248, 113, 113, .25);
    --radius:       8px;
    --radius-sm:    5px;
    --shadow:       0 2px 8px rgba(0, 0, 0, .25);
    --transition:   150ms ease;
}

/* ---------- body / base ---------- */

body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); transition: color var(--transition); }
a:hover, a:focus {
    color: #7ba6f5;
    background: none;
    padding: 0;
}

/* ---------- layout shell ---------- */

#layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    right: 0;
}

#content {
    flex: 1;
    padding: 1.5em 0 2em;
    padding-top: 2em;
}

#push { height: auto; }

#foot {
    margin-top: auto;
}

/* ---------- header ---------- */

#header {
    background: linear-gradient(135deg, var(--surface-2), var(--surface));
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 1em 0;
    height: auto;
    min-height: 4rem;
}

#header .wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5em;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: auto;
    min-height: 4em;
}

.logo-header {
    min-width: auto;
    height: auto;
    max-width: none;
}

.logospace { float: none; }
.menuspace { float: none; }

#header .v-center {
    display: flex;
    align-items: center;
}

.header-lock {
    width: 28px;
    height: 28px;
    opacity: .55;
    flex-shrink: 0;
    margin-right: 0.6em;
}

#logo {
    font-size: 1.35em;
    font-weight: 700;
    color: var(--text-bright);
    letter-spacing: -0.02em;
    text-shadow: none;
    font-family: inherit;
}

/* ---------- language bar ---------- */

.language-bar {
    height: auto;
}

#header .language-bar .v-center {
    height: auto;
}

.language-menu {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0.35em 0.6em !important;
    font-family: inherit;
    font-weight: 400;
    min-width: 8rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.language-menu:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#language-selector {
    border: none;
    box-shadow: none;
    cursor: pointer;
}
.language-menu option {
    background: var(--surface-2);
    color: var(--text);
}

#header .pure-button {
    background: var(--surface-3);
    color: var(--text-bright);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0.4em 0.8em;
    font-size: 0.9em;
}

/* mobile language menu */
#menuLink.menu-link span {
    background-color: var(--text-muted);
}
#menu {
    background: var(--surface-2);
}
#menu a {
    color: var(--text);
}
#menu .pure-menu ul,
#menu .pure-menu .menu-item-divided {
    border-top-color: var(--border);
}
#menu .pure-menu-selected,
#menu .pure-menu-heading {
    background: var(--surface-3);
    color: var(--text-bright);
}

.hide-for-large,
.show-for-large {
    /* preserve base responsive behavior */
}

/* ---------- footer ---------- */

#footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    height: auto;
    padding: 1em 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85em;
}
#footer .wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5em;
    width: auto;
}
#footer a, #footer a:visited {
    color: var(--text-muted);
    transition: color var(--transition);
}
#footer a:hover, #footer a:focus {
    color: var(--text);
    background: none;
    padding: 0;
}
.copyrights {
    padding: 0;
    height: auto;
    font-size: inherit;
}

/* ---------- headings ---------- */

h1 {
    color: var(--text-bright);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 1em 0;
    font-size: 1.5em;
}
h2 {
    color: var(--text-bright);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 1em 0 0.6em;
    font-size: 1.15em;
    border-bottom: 1px solid var(--border);
}
h3 {
    color: var(--text-bright);
    font-weight: 600;
    padding: 0;
    margin-top: 0;
}

p { color: var(--text); padding: .5em 0; }

/* ---------- content container ---------- */

#content .wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5em;
    width: auto;
}

/* ---------- forms ---------- */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
select:not([multiple]) {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-light);
    padding: 0.45em 0.7em;
    border-radius: var(--radius-sm);
    font: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
select:not([multiple]):focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder { color: var(--text-muted); }

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

.pure-button,
button,
.btn,
input[type="submit"] {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.5em 1.1em;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font: inherit;
    font-weight: 500;
    transition: background var(--transition), box-shadow var(--transition);
}
.pure-button:hover,
button:hover,
.btn:hover,
input[type="submit"]:hover {
    box-shadow: 0 2px 8px var(--accent-glow);
    background-color: #55555535;
    color: #fff;
    padding: 0.5em 1.1em;
}
.pure-button:active,
button:active {
    transform: translateY(1px);
}
.pure-button-active {
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ---------- message boxes ---------- */

.message-box {
    background: var(--surface);
    border-left: 4px solid var(--border-light);
    box-shadow: var(--shadow);
    border-radius: var(--radius-sm);
    color: var(--text);
}
.message-box.error {
    background: var(--red-bg);
    border-left-color: var(--red);
    color: var(--red);
}
.message-box.warning {
    background: var(--surface-2);
    border-left-color: #facc15;
    color: #facc15;
}
.message-box.success {
    background: var(--green-bg);
    border-left-color: var(--green);
    color: var(--green);
}

/* ---------- code boxes ---------- */

.code-box {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    overflow: hidden;
}
.code-box-title {
    background: var(--surface-3);
    color: var(--text-bright);
    border-bottom: 1px solid var(--border);
    padding: 0.5em 0.8em;
}
.code-box-content {
    color: var(--text);
    padding: 0.5em 1em;
    font-family: monospace;
}

/* ---------- tables ---------- */

.pure-table,
table.attributes {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.pure-table thead {
    background: var(--surface-3);
}
.pure-table th {
    color: var(--text-bright);
    border-bottom: 1px solid var(--border);
}
.pure-table td {
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.pure-table tbody tr:hover {
    background: var(--surface-2);
}

table.attributes .attrname {
    color: var(--text-muted);
}
table.attributes .attrvalue {
    color: var(--text);
}

/* ---------- expandable sections ---------- */

.expandable {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}
.expandable .expander {
    color: var(--text);
    background: var(--surface-2);
    border-top: 1px solid var(--border);
}
.expandable .expander:focus,
.expandable .expander:hover {
    background: var(--surface-3);
    color: var(--text-bright);
}
.expandable.expanded .content {
    border-left: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
}
.expandable.expanded .expander {
    border-top: 1px solid var(--border);
}

/* ---------- Usher warning banner ---------- */

.usher-warning {
    display: block;
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid var(--red-border);
    border-radius: var(--radius-sm);
    padding: 1em;
    margin-top: 1em;
}

/* ---------- multiauth: select source (social login picker) ---------- */

[id="multiauth:selectsource"] ul {
    margin-left: 0;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6em;
}
[id="multiauth:selectsource"] ul li {
    list-style: none;
    display: flex;
    position: relative;
    justify-content: center;
    align-items: center;
}
.auth-sep {
  border-bottom: 1px solid #ffffff26;
  width: 16em;
  display: block;
  margin-top: 0.4em;
  margin-bottom: 0.4em;
}
.authsource-default {
  margin-top: 0.4em;
  font-size: 1.1em;
}
.authsource input {
    min-width: 16em;
    width: 16em;
    min-height: 4em;
    border: 1px solid var(--border-light);
    background: var(--surface);
    cursor: pointer;
    background-size: 60% 70%;
    background-position: center;
    background-repeat: no-repeat;
    color: transparent !important;
    padding: 0.9em 2.5em 0.9em 3.5em;
    margin: 0;
    border-radius: var(--radius);
    text-align: left;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.authsource input:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px var(--accent-glow);
}
.authsource input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.authsource-caret {
    position: absolute;
    right: 1em;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.4em;
    font-weight: 300;
    color: var(--text-muted);
    pointer-events: none;
    line-height: 1;
    transition: color var(--transition), transform var(--transition);
}
.authsource:hover .authsource-caret,
.authsource:focus-within .authsource-caret {
    color: var(--accent);
    transform: translateY(-50%) translateX(2px);
}
.authsource p {
    font-size: 0.82em;
    color: var(--text-muted);
    text-align: center;
    margin: 0.3em 0 0;
    padding: 0;
}

/* Social login brand buttons */
input#button-google {
    background-image: url(google.svg);
}
input#button-microsoft {
    background-image: url(microsoft.svg);
}
input#button-linkedin {
    background-image: url(linkedin.png);
}
input#button-facebook {
    background-image: url(facebook.png);
}
input#button-auid {
    background-image: url(aarhus.svg);
}
input#button-twitter-x {
    background-image: url(x.svg);
}

/* Default (first) button: prominent with a lighter cyan-blue background */
.authsource-default input {
    background-color: rgba(55, 210, 255, 0.13) !important;
    border-color: rgba(55, 210, 255, 0.40) !important;
    box-shadow:
        0 0 0 1px rgba(55, 210, 255, 0.15),
        0 4px 14px rgba(0, 200, 255, 0.08);
}
.authsource-default input:hover {
    border-color: rgba(55, 210, 255, 0.65) !important;
    box-shadow: 0 4px 14px rgba(0, 200, 255, 0.15) !important;
}
.authsource-default .authsource-caret {
    color: rgba(55, 210, 255, 0.65);
}
.authsource-default:hover .authsource-caret,
.authsource-default:focus-within .authsource-caret {
    color: #37d2ff;
}

/* Non-default buttons: dimmed at 0.7 opacity, brighten on hover/focus */
.authsource:not(.authsource-default) {
    opacity: 0.7;
    transition: opacity var(--transition);
}
.authsource:not(.authsource-default):hover,
.authsource:not(.authsource-default):focus-within {
    opacity: 1;
}

/* ---------- Loading overlay ---------- */

.auth-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8em;
    background: rgba(15, 17, 23, 0.82);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    text-align: center;
    padding: 1.5em;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 250ms ease, visibility 250ms ease;
}
.auth-loading-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.auth-loading-text {
    color: var(--text-bright);
    font-size: 1.1em;
    font-weight: 600;
    margin: 0.6em 0 0;
}
.auth-loading-subtext {
    color: var(--text-muted);
    font-size: 0.88em;
    margin: 0;
}

/* Dual-ring spinner */
.auth-spinner {
    position: relative;
    width: 64px;
    height: 64px;
}
.auth-spinner-ring {
    position: absolute;
    border-radius: 50%;
}
.auth-spinner-ring--outer {
    inset: 0;
    border: 4px solid rgba(55, 210, 255, 0.15);
    border-top-color: rgba(55, 210, 255, 0.75);
    animation: auth-spinner-spin 0.9s linear infinite;
}
.auth-spinner-ring--inner {
    inset: 12px;
    border: 3px solid rgba(91, 141, 239, 0.12);
    border-bottom-color: rgba(91, 141, 239, 0.80);
    animation: auth-spinner-spin 0.6s linear infinite reverse;
}

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

/* Pulsing logo behind spinner */
.auth-loading-overlay.active .auth-spinner::after {
    content: "";
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(55, 210, 255, 0.06),
        transparent 70%
    );
    animation: auth-spinner-pulse 1.4s ease-in-out infinite;
}

@keyframes auth-spinner-pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50%      { transform: scale(1.25); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-spinner-ring--outer,
    .auth-spinner-ring--inner {
        animation-duration: 2.5s;
    }
    .auth-loading-overlay.active .auth-spinner::after {
        animation: none;
    }
}

/* ---------- OAuth2 authorize page ---------- */

#frm-authorize {
    margin-top: 1em;
}

/* ---------- pure-form overrides ---------- */

.pure-form input[type="text"],
.pure-form input[type="password"],
.pure-form input[type="email"],
.pure-form input[type="search"] {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}
.pure-form input[type="text"]:focus,
.pure-form input[type="password"]:focus,
.pure-form input[type="email"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    outline: none;
}

.pure-control-group label {
    color: var(--text-muted);
}

/* ---------- misc ---------- */

::selection {
    background: var(--accent-glow);
    color: var(--text-bright);
}
