/* ============================================================
   mxa_redeem — Modern login page redesign + redeem panel.
   Overrides Elastic's #logo / #login-form absolute positioning
   so they no longer overlap.
   ============================================================ */

/* --- background & viewport centering ------------------------- */
body.task-login {
    background:
        radial-gradient(ellipse at top left,  rgba(99,102,241,.55), transparent 55%),
        radial-gradient(ellipse at bottom right, rgba(56,189,248,.50), transparent 55%),
        linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e3a8a 100%);
    background-attachment: fixed;
    overflow-x: hidden;
}

body.task-login::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(rgba(255,255,255,.06) 1px, transparent 1px);
    background-size: 24px 24px;
    pointer-events: none;
    z-index: 0;
}

body.task-login #layout {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    position: relative;
    z-index: 1;
}

/* Hide any leftover sidebar / frames on login. */
body.task-login #layout-menu,
body.task-login #layout-sidebar,
body.task-login #layout-frames { display: none !important; }

/* --- the card itself ---------------------------------------- */
body.task-login #layout-content {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    width: 100% !important;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    padding: 40px 36px 32px;
    border-radius: 20px;
    box-shadow:
        0 30px 80px rgba(0, 0, 0, .35),
        0 1px 0 rgba(255, 255, 255, .6) inset;
    border: 1px solid rgba(255, 255, 255, .4);
    text-align: center;
    animation: mxa-card-in .55s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes mxa-card-in {
    from { opacity: 0; transform: translateY(20px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- logo (kill its absolute-ish positioning) --------------- */
body.task-login #logo {
    position: static !important;
    top: auto !important;
    display: block;
    margin: 0 auto 6px;
    max-height: 52px;
    max-width: 200px;
    width: auto;
    filter: drop-shadow(0 4px 12px rgba(99, 102, 241, .25));
}

/* --- tagline below logo ------------------------------------- */
body.task-login #layout-content::after {
    content: "请登录或使用卡密领取邮箱";
    display: block;
    font-size: 13px;
    color: #6b7280;
    margin-top: -4px;
    margin-bottom: 22px;
    order: 2;
}
body.task-login #logo { order: 1; }
body.task-login .mxa-tabwrap { order: 3; }

/* --- tabs --------------------------------------------------- */
.mxa-tabwrap {
    width: 100% !important;
    max-width: none !important;
    display: block;
}

.mxa-tabs {
    display: flex;
    gap: 4px;
    background: #f3f4f6;
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 22px;
    border: 0 !important;
}

.mxa-tab {
    flex: 1;
    padding: 9px 0;
    background: transparent;
    border: 0;
    border-bottom: 0 !important;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    font-family: inherit;
    transition: all .2s ease;
}
.mxa-tab:hover { color: #111827; background: rgba(255,255,255,.5); }
.mxa-tab.active {
    background: #fff;
    color: #1d4ed8;
    box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

.mxa-panel { display: none; text-align: left; }
.mxa-panel.active { display: block; animation: mxa-panel-in .25s ease; }

@keyframes mxa-panel-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- override Roundcube's #login-form absolute positioning -- */
#login-form {
    position: static !important;
    top: auto !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Roundcube renders the login form as a <table>; relayout to flex rows */
#login-form table,
#login-form tbody,
#login-form tr,
#login-form td {
    display: block !important;
    width: 100% !important;
}
#login-form tr { margin-bottom: 14px; }
#login-form td.title {
    text-align: left !important;
    padding: 0 0 5px !important;
}
#login-form td.title label {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}
#login-form td.input { padding: 0 !important; }
#login-form input.form-control {
    width: 100% !important;
    padding: 10px 12px !important;
    border: 1.5px solid #e5e7eb !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    background: #fff !important;
    transition: border-color .15s ease, box-shadow .15s ease;
    box-sizing: border-box;
    height: auto !important;
}
#login-form input.form-control:focus {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .15) !important;
    outline: 0 !important;
}

#login-form .formbuttons { margin: 18px 0 0 !important; }
#rcmloginsubmit {
    width: 100%;
    padding: 11px !important;
    font-size: 14.5px !important;
    font-weight: 600 !important;
    background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
    color: #fff !important;
    border: 0 !important;
    border-radius: 8px !important;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .15s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, .35);
}
#rcmloginsubmit:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, .45);
}
#rcmloginsubmit:active { transform: translateY(0); }

#login-footer {
    margin-top: 24px;
    text-align: center;
    color: #9ca3af !important;
    font-size: 12px;
}
#login-footer > div { background: transparent !important; padding: 0 !important; margin: 0 !important; }

/* --- redeem form -------------------------------------------- */
.mxa-redeem-form .mxa-row { margin-bottom: 14px; }
.mxa-redeem-form label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 5px;
    color: #374151;
}
.mxa-redeem-form input[type=text],
.mxa-redeem-form input[type=password] {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    box-sizing: border-box;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.mxa-redeem-form input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
    outline: 0;
}
.mxa-redeem-form input[name=code] {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    text-align: center;
}

.mxa-submit, .mxa-fill {
    width: 100%;
    padding: 11px;
    margin-top: 8px;
    font-size: 14.5px;
    font-weight: 600;
    background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
    color: #fff !important;
    border: 0 !important;
    border-radius: 8px !important;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .15s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, .35);
    font-family: inherit;
}
.mxa-submit:hover:not([disabled]),
.mxa-fill:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, .45);
}
.mxa-submit[disabled] { opacity: .65; cursor: wait; }

.mxa-msg {
    margin-top: 14px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
}
.mxa-msg-err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.mxa-msg-ok  { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

.mxa-result .mxa-success {
    color: #166534;
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    padding: 11px 14px;
    border-radius: 8px;
    border: 1px solid #bbf7d0;
    margin-bottom: 14px;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
}
.mxa-cred {
    background: #f9fafb;
    border: 1px dashed #d1d5db;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 14px;
}
.mxa-cred > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0,0,0,.06);
    gap: 10px;
}
.mxa-cred > div:last-child { border-bottom: 0; }
.mxa-cred span { color: #6b7280; font-size: 13px; flex-shrink: 0; }
.mxa-cred code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    word-break: break-all;
    text-align: right;
    background: transparent;
    color: #111827;
    font-weight: 500;
}

.mxa-hint {
    font-size: 12px;
    color: #9ca3af;
    text-align: center;
    margin: 12px 0 0;
    line-height: 1.6;
}

/* --- responsive --------------------------------------------- */
@media (max-width: 480px) {
    body.task-login #layout { padding: 16px; }
    body.task-login #layout-content { padding: 32px 24px 28px; }
    body.task-login #logo { max-height: 44px; }
}

/* --- dark mode (Elastic adds .dark on body) ----------------- */
body.dark.task-login #layout-content {
    background: rgba(17, 24, 39, .95);
    border-color: rgba(255, 255, 255, .08);
}
body.dark.task-login #layout-content::after { color: #9ca3af; }
body.dark.task-login .mxa-tabs { background: #1f2937; }
body.dark.task-login .mxa-tab { color: #9ca3af; }
body.dark.task-login .mxa-tab.active { background: #374151; color: #818cf8; }
body.dark #login-form td.title label { color: #d1d5db; }
body.dark #login-form input.form-control,
body.dark .mxa-redeem-form input {
    background: #1f2937 !important;
    border-color: #374151 !important;
    color: #f3f4f6 !important;
}
body.dark .mxa-cred { background: #1f2937; border-color: #374151; }
body.dark .mxa-cred code { color: #f3f4f6; }
