/* Netstreet Branded Login - Roundcube Override
 * Same design as the Netstreet CRM sign-in: a Netstreet-blue brand panel with the
 * interlocking-N pattern beside a white sign-in card.
 *
 * Netstreet brand guide: Blue #0065E1 + tints, Onyx #131520 + shades.
 * Fonts: DM Sans (text), Ubuntu (display) - loaded by netstreet_login.php.
 */

body.ns-login {
    --ns-bg: #eef0f4;
    --ns-surface: #ffffff;
    --ns-surface-2: #f5f6f9;
    --ns-border: #e3e5ec;
    --ns-ink: #131520;
    --ns-ink-2: #41435a;
    --ns-muted: #585a77;
    --ns-accent: #0065e1;
    --ns-accent-hover: #0052b8;
    --ns-accent-soft: #e6f0fd;
    --ns-accent-ink: #ffffff;
    --ns-brand: #0065e1;
    --ns-danger: #c0352f;
    --ns-danger-soft: #fbe9e8;
    --ns-font: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --ns-font-display: "Ubuntu", "DM Sans", ui-sans-serif, system-ui, sans-serif;
}

/* Elastic's dark mode */
html.dark-mode body.ns-login {
    --ns-bg: #0d0e16;
    --ns-surface: #1c1e2c;
    --ns-surface-2: #2a2c3d;
    --ns-border: #34364a;
    --ns-ink: #ffffff;
    --ns-ink-2: #c9cadd;
    --ns-muted: #9a9cc0;
    --ns-accent: #66aef0;
    --ns-accent-hover: #99c3f5;
    --ns-accent-soft: #17304f;
    --ns-accent-ink: #131520;
    --ns-danger: #ef7b7b;
    --ns-danger-soft: #3a1c26;
}

html:has(body.ns-login) {
    height: auto;
    background: var(--ns-bg);
    color-scheme: light;
}

html.dark-mode:has(body.ns-login) {
    color-scheme: dark;
}

body.ns-login {
    margin: 0;
    height: auto;
    min-height: 100vh;
    overflow: auto;
    background: var(--ns-bg);
    color: var(--ns-ink);
    font-family: var(--ns-font);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* The skin's own layout stays in the page for Roundcube's scripts, just out of sight */
body.ns-login > *:not(.ns-shell):not(#messagestack):not(script):not(iframe) {
    display: none !important;
}

.ns-shell,
.ns-shell * {
    box-sizing: border-box;
}

.ns-shell {
    padding: 12px;
}

.ns-grid {
    display: grid;
    gap: 12px;
    max-width: 1152px;
    min-height: calc(100vh - 24px);
    margin: 0 auto;
}

@media (min-width: 640px) {
    .ns-shell { padding: 16px; }
    .ns-grid { min-height: calc(100vh - 32px); }
}

@media (min-width: 1024px) {
    .ns-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Brand panel ─────────────────────────────────── */
.ns-brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 240px;
    overflow: hidden;
    border-radius: 32px;
    background: var(--ns-brand);
    color: #ffffff;
    padding: 28px;
}

@media (min-width: 640px) {
    .ns-brand { padding: 40px; }
}

.ns-pattern {
    position: absolute;
    inset: 0;
    opacity: 0.2;
}

.ns-brand-fade {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, #0065e1 0%, rgba(0, 101, 225, 0.6) 50%, rgba(0, 101, 225, 0) 100%);
}

.ns-brand-top,
.ns-brand-copy {
    position: relative;
}

.ns-brand-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ns-app-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    color: #ffffff;
}

.ns-app-name {
    line-height: 1.25;
    font-family: var(--ns-font-display);
    font-size: 20px;
    font-weight: 500;
}

.ns-app-by {
    font-family: var(--ns-font);
    font-size: 15px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.85);
}

.ns-wordmark-inline {
    display: inline-block;
    height: 0.72em;
    width: auto;
    vertical-align: baseline;
}

.ns-back {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    font-size: 13px;
    text-decoration: none;
    transition: background 0.2s ease;
}

.ns-back:hover {
    background: rgba(255, 255, 255, 0.24);
}

.ns-back svg {
    width: 14px;
    height: 14px;
}

.ns-brand-copy {
    margin-top: 40px;
}

.ns-tagline {
    margin: 0;
    font-size: 36px;
    font-weight: 500;
    line-height: 1.1;
    letter-spacing: -0.025em;
}

@media (min-width: 640px) {
    .ns-tagline { font-size: 48px; }
}

.ns-tagline-sub {
    margin: 12px 0 0;
    max-width: 28rem;
    color: rgba(255, 255, 255, 0.9);
}

.ns-help {
    margin-top: 28px;
    max-width: 28rem;
    padding: 16px 18px;
    border-radius: 20px;
    background: rgba(19, 21, 32, 0.22);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.ns-help h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 600;
}

.ns-help h2 svg {
    width: 16px;
    height: 16px;
}

.ns-help dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 14px;
    margin: 0;
    font-size: 13px;
}

.ns-help dt {
    font-weight: 600;
}

.ns-help dd {
    margin: 0;
    color: rgba(255, 255, 255, 0.88);
    overflow-wrap: anywhere;
}

/* ── Sign-in panel ───────────────────────────────── */
/* Form centred in the card, footer row along its bottom edge */
.ns-signin {
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: 32px;
    background: var(--ns-surface);
    padding: 32px 20px 20px;
}

@media (min-width: 640px) {
    .ns-signin { padding: 40px 40px 24px; }
}

.ns-signin-inner {
    width: 100%;
    max-width: 24rem;
    margin: auto 0;
}

.ns-signin-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

/* Light / dark switch: shows the moon in light mode, the sun in dark mode */
.ns-theme-toggle {
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--ns-border);
    border-radius: 999px;
    background: var(--ns-surface);
    color: var(--ns-ink-2);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.ns-theme-toggle:hover {
    background: var(--ns-surface-2);
    color: var(--ns-ink);
}

.ns-theme-toggle:focus-visible {
    outline: 2px solid var(--ns-accent);
    outline-offset: 2px;
}

.ns-theme-toggle svg {
    width: 18px;
    height: 18px;
}

.ns-theme-toggle .ns-icon-sun,
html.dark-mode .ns-theme-toggle .ns-icon-moon {
    display: none;
}

html.dark-mode .ns-theme-toggle .ns-icon-sun {
    display: block;
}

.ns-signin-head h1 {
    margin: 0;
    font-family: var(--ns-font);
    font-size: 30px;
    font-weight: 500;
    letter-spacing: -0.025em;
    color: var(--ns-ink);
}

.ns-signin-head p {
    margin: 4px 0 0;
    font-size: 14px;
    color: var(--ns-muted);
}

.ns-form-slot {
    margin-top: 20px;
}

/* Roundcube's form: a table (title / input rows) and, in Elastic, input groups with icons */
/* !important: Elastic's script positions and sizes #login-form inline to centre it on its own page */
.ns-form-slot form {
    position: static !important;
    top: auto !important;
    left: auto !important;
    margin: 0 !important;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    width: 100% !important;
    max-width: none !important;
}

/* Elastic hides the labels inline in favour of icons; show them, as on the CRM sign-in */
.ns-form-slot td.title {
    display: block !important;
}

/* Elastic's footer line with the product name; the card has its own footer */
.ns-form-slot #login-footer {
    display: none;
}

.ns-form-slot table,
.ns-form-slot tbody,
.ns-form-slot tr,
.ns-form-slot td {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
}

.ns-form-slot tr {
    margin-bottom: 16px;
}

.ns-form-slot td.title,
.ns-form-slot label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ns-ink-2);
    text-align: left;
}

.ns-form-slot .input-group {
    display: flex;
    align-items: stretch;
    width: 100%;
}

/* Elastic's user / lock icons are replaced by the visible labels */
.ns-form-slot .input-group-prepend,
.ns-form-slot .input-group > .icon {
    display: none;
}

.ns-form-slot input[type="text"],
.ns-form-slot input[type="email"],
.ns-form-slot input[type="password"],
.ns-form-slot select {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--ns-border);
    border-radius: 8px;
    background: var(--ns-surface);
    color: var(--ns-ink);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    box-shadow: none;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ns-form-slot input::placeholder {
    color: var(--ns-muted);
    opacity: 0.7;
}

.ns-form-slot input:focus,
.ns-form-slot select:focus {
    border-color: var(--ns-accent);
    box-shadow: 0 0 0 3px var(--ns-accent-soft);
}

.ns-form-slot select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23585a77' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.ns-form-slot input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0 8px 0 0;
    accent-color: var(--ns-accent);
    vertical-align: -3px;
}

.ns-form-slot .formbuttons,
.ns-form-slot p {
    margin: 4px 0 0;
    padding: 0;
    text-align: left;
}

/* Submit button */
.ns-form-slot #rcmloginsubmit,
.ns-form-slot button[type="submit"],
.ns-form-slot input[type="submit"],
.ns-btn-login {
    display: block;
    width: 100%;
    margin: 8px 0 0;
    padding: 11px 16px;
    border: 0;
    border-radius: 8px;
    background: var(--ns-accent);
    color: var(--ns-accent-ink);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    text-transform: none !important; /* beats Elastic's .text-uppercase */
    letter-spacing: normal;
    cursor: pointer;
    position: relative;
    transition: background 0.15s ease;
}

.ns-form-slot #rcmloginsubmit:hover,
.ns-form-slot button[type="submit"]:hover,
.ns-form-slot input[type="submit"]:hover,
.ns-btn-login:hover {
    background: var(--ns-accent-hover);
}

.ns-form-slot #rcmloginsubmit:focus-visible,
.ns-btn-login:focus-visible {
    outline: 2px solid var(--ns-accent);
    outline-offset: 2px;
}

.ns-btn-login.loading {
    opacity: 0.8;
    pointer-events: none;
}

.ns-btn-login.loading::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: var(--ns-accent-ink);
    border-radius: 50%;
    animation: ns-spin 0.6s linear infinite;
}

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

/* Error messages */
.ns-form-slot .error,
.ns-form-slot .warning,
.ns-alert-error {
    margin-bottom: 16px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--ns-danger-soft);
    color: var(--ns-danger);
    font-size: 14px;
}

/* Help links and footer */
.ns-links {
    list-style: none;
    margin: 24px 0 0;
    padding: 16px 0 0;
    border-top: 1px solid var(--ns-border);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 20px;
    font-size: 13px;
}

.ns-links a {
    color: var(--ns-accent);
    text-decoration: none;
    font-weight: 500;
}

.ns-links a:hover {
    text-decoration: underline;
}

.ns-footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 16px;
    width: 100%;
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--ns-border);
}

.ns-logo {
    display: block;
    height: 16px;
    width: auto;
    color: var(--ns-ink);
}

.ns-copy {
    margin: 0;
    font-size: 12px;
    color: var(--ns-muted);
    white-space: nowrap;
}

@media (max-width: 480px) {
    .ns-back { display: none; }
    .ns-brand-copy { margin-top: 28px; }
    .ns-tagline { font-size: 30px; }
    .ns-signin-head h1 { font-size: 26px; }
}
