/* Magic Com - Master Panel login
   Self-contained (no framework, no icon font) so the first page loads fast. */

:root {
    --brand: #dc1420;
    --brand-dark: #9a0a12;
    --bg: #f3f4f7;
    --card: #ffffff;
    --text: #14171c;
    --muted: #667085;
    --line: #e3e6ec;
    --field: #f6f7f9;
    --field-hover: #f0f1f4;
    --ring: rgba(220, 20, 32, 0.22);
    --err-bg: #fdecee;
    --err-line: #f6c3c7;
    --err-text: #a4111b;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 14px 34px -10px rgba(16, 24, 40, 0.14), 0 36px 70px -28px rgba(16, 24, 40, 0.18);
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #0e1013;
    --card: #171a1f;
    --text: #f4f5f7;
    --muted: #9aa3b2;
    --line: #2a2e36;
    --field: #1e2228;
    --field-hover: #242930;
    --ring: rgba(255, 82, 92, 0.3);
    --err-bg: #2b1518;
    --err-line: #5b2329;
    --err-text: #ff9aa1;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 20px 44px -12px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overscroll-behavior: none;
}

body.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(56rem 34rem at 8% -8%, rgba(220, 20, 32, 0.09), transparent 62%),
        radial-gradient(46rem 30rem at 108% 108%, rgba(20, 23, 28, 0.07), transparent 58%),
        var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

[data-theme="dark"] body.auth-page {
    background:
        radial-gradient(56rem 34rem at 8% -8%, rgba(220, 20, 32, 0.16), transparent 62%),
        radial-gradient(46rem 30rem at 108% 108%, rgba(255, 255, 255, 0.04), transparent 58%),
        var(--bg);
}

/* margin:auto centres the card and stays safe when the keyboard shrinks the viewport */
.auth-card {
    position: relative;
    margin: auto;
    width: 100%;
    max-width: 432px;
    padding: 36px 32px 24px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.auth-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--brand), var(--brand-dark));
}

.auth-head {
    text-align: center;
    margin-bottom: 24px;
}

.auth-logo {
    display: block;
    width: 112px;
    height: 112px;
    margin: 0 auto 12px;
    object-fit: contain;
}

.auth-head h1 {
    font-size: 22px;
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.auth-head p {
    margin-top: 6px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--muted);
}

/* ---- Alert ---- */
.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--err-line);
    border-radius: 12px;
    background: var(--err-bg);
    color: var(--err-text);
    font-size: 13.5px;
    line-height: 1.4;
}

.auth-alert[hidden] {
    display: none;
}

.auth-alert svg {
    flex: none;
    margin-top: 1px;
}

/* ---- Form ---- */
.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.input-wrap {
    position: relative;
}

.input-wrap .ico {
    position: absolute;
    left: 14px;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
    transition: color 0.15s;
}

.input-wrap input {
    width: 100%;
    height: 50px;
    padding: 0 46px 0 44px;
    font: inherit;
    font-size: 16px; /* 16px stops iOS Safari zooming the page on focus */
    color: var(--text);
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
    -webkit-appearance: none;
    appearance: none;
}

.input-wrap input::placeholder {
    color: var(--muted);
    opacity: 0.75;
}

.input-wrap input:hover {
    background: var(--field-hover);
}

.input-wrap input:focus {
    background: var(--card);
    border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--ring);
}

.input-wrap:focus-within .ico {
    color: var(--brand);
}

.input-wrap input:-webkit-autofill {
    -webkit-text-fill-color: var(--text);
    box-shadow: 0 0 0 100px var(--field) inset;
}

.toggle-pass {
    position: absolute;
    right: 6px;
    top: 50%;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    transform: translateY(-50%);
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}

.toggle-pass:hover {
    color: var(--text);
    background: var(--field-hover);
}

.toggle-pass:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 1px;
}

.toggle-pass .eye-off {
    display: none;
}

.toggle-pass[aria-pressed="true"] .eye {
    display: none;
}

.toggle-pass[aria-pressed="true"] .eye-off {
    display: block;
}

.hint {
    display: none;
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--muted);
}

.hint.on {
    display: block;
}

/* ---- Remember me ---- */
.check {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 2px 0 20px;
    font-size: 14px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.check input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.check .box {
    flex: none;
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    border: 1.5px solid var(--line);
    border-radius: 6px;
    background: var(--field);
    transition: background-color 0.15s, border-color 0.15s;
}

.check .box svg {
    width: 12px;
    height: 12px;
    color: #fff;
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.12s, transform 0.12s;
}

.check input:checked + .box {
    background: var(--brand);
    border-color: var(--brand);
}

.check input:checked + .box svg {
    opacity: 1;
    transform: none;
}

.check input:focus-visible + .box {
    box-shadow: 0 0 0 4px var(--ring);
}

/* ---- Submit ---- */
.btn-primary {
    position: relative;
    width: 100%;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    border: 0;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 8px 20px -8px rgba(220, 20, 32, 0.55);
    transition: filter 0.15s, box-shadow 0.15s, opacity 0.15s;
    touch-action: manipulation;
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(1.07);
    box-shadow: 0 10px 24px -8px rgba(220, 20, 32, 0.65);
}

.btn-primary:active:not(:disabled) {
    filter: brightness(0.96);
}

.btn-primary:focus-visible {
    outline: 3px solid var(--ring);
    outline-offset: 2px;
}

.btn-primary:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-primary .spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn-primary[aria-busy="true"] .spinner {
    display: block;
}

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

/* ---- Footer ---- */
.auth-foot {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    font-size: 12.5px;
    color: var(--muted);
}

.auth-foot a {
    color: var(--muted);
    text-decoration: none;
}

.auth-foot a:hover {
    color: var(--brand);
    text-decoration: underline;
}

noscript .auth-alert {
    margin-top: 16px;
}

/* ---- Phones ---- */
@media (max-width: 480px) {
    body.auth-page {
        padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    }

    .auth-card {
        padding: 30px 20px 20px;
        border-radius: 20px;
        box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 18px 40px -20px rgba(16, 24, 40, 0.2);
    }

    .auth-logo {
        width: 100px;
        height: 100px;
    }

    .auth-head h1 {
        font-size: 21px;
    }
}

/* Short screens (landscape phones, open keyboard): tighten so less scrolling is needed */
@media (max-height: 640px) {
    .auth-card {
        padding-top: 26px;
    }

    .auth-head {
        margin-bottom: 16px;
    }

    .auth-logo {
        width: 64px;
        height: 64px;
        margin-bottom: 8px;
    }

    .field {
        margin-bottom: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation-duration: 0.01ms !important;
    }
}
