/* ===================================================================
   Modern Materialist Login UI for Roundcube
   Injected by telegram_otp plugin — scoped to task-login only.
   Overrides the default Elastic skin login layout.
   =================================================================== */

/* --- Reset the default Elastic login layout --- */
body.task-login {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 40%, #334155 100%) !important;
    background-size: 400% 400% !important;
    animation: gradientShift 4s ease-in-out infinite;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}
@keyframes gradientShift {
    0%   { background-position: 0% 50%; }
    25%  { background-position: 100% 50%; }
    50%  { background-position: 0% 50%; }
    75%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Override Elastic's flex layout so our card centers properly */
body.task-login #layout {
    display: none !important;
}

/* Animated background orbs */
body.task-login::before,
body.task-login::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.25;
    z-index: 0;
    pointer-events: none;
}
body.task-login::before {
    width: 480px; height: 480px;
    background: #6366f1;
    top: -120px; left: -120px;
    animation: floatOrb 18s ease-in-out infinite alternate;
}
body.task-login::after {
    width: 420px; height: 420px;
    background: #8b5cf6;
    bottom: -100px; right: -100px;
    animation: floatOrb 16s ease-in-out infinite alternate-reverse;
}
@keyframes floatOrb {
    0%   { transform: translate(0, 0) scale(1); }
    100% { transform: translate(60px, 40px) scale(1.15); }
}

/* Hide the default layout chrome (logo only — #layout stays for our card) */
body.task-login #layout-content > img#logo {
    display: none !important;
}

/* --- Login card --- */
body.task-login #tg-login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.97);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.08);
    padding: 44px 40px 36px;
    animation: cardIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes cardIn {
    from { opacity: 0; transform: translateY(24px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Header inside card --- */
#tg-login-card h1 {
    text-align: center;
    font-size: 63px;
    font-weight: 800;
    color: #1e293b;
    margin: 0 0 8px;
    letter-spacing: -1.5px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
#tg-login-card .tg-subtitle {
    text-align: center;
    font-size: 14px;
    color: #64748b;
    margin: 0 0 32px;
    font-weight: 400;
}

/* --- Form (override Elastic's #login-form top:20vh) --- */
#tg-login-card form#login-form {
    margin: 0;
    top: 0 !important;
    width: 100% !important;
    max-width: none !important;
    position: static !important;
}
#tg-login-card form {
    margin: 0;
}
#tg-login-card .tg-field {
    position: relative;
    margin-bottom: 22px;
}
#tg-login-card .tg-field-icon {
    position: absolute;
    left: 16px; top: 18px;
    width: 20px; height: 20px;
    fill: #94a3b8;
    transition: fill 0.2s;
    z-index: 2;
}
#tg-login-card .tg-field input {
    width: 100%;
    padding: 16px 16px 16px 48px;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    font-size: 15px;
    color: #1e293b;
    background: #f8fafc;
    outline: none;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}
#tg-login-card .tg-field input::placeholder {
    color: transparent;
}
#tg-login-card .tg-field input:focus {
    border-color: #6366f1;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(99,102,241,0.12);
}
#tg-login-card .tg-field input:focus ~ .tg-field-icon,
#tg-login-card .tg-field input:not(:placeholder-shown) ~ .tg-field-icon {
    fill: #6366f1;
}
#tg-login-card .tg-field label {
    position: absolute;
    left: 48px; top: 16px;
    font-size: 15px;
    color: #94a3b8;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.16,1,0.3,1);
    background: transparent;
    padding: 0 4px;
}
#tg-login-card .tg-field input:focus ~ label,
#tg-login-card .tg-field input:not(:placeholder-shown) ~ label {
    top: -10px;
    left: 14px;
    font-size: 12px;
    font-weight: 600;
    color: #6366f1;
    background: #fff;
    border-radius: 6px;
}

/* --- Buttons --- */
#tg-login-card .tg-actions {
    margin-top: 8px;
}
#tg-login-card .tg-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16,1,0.3,1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}
#tg-login-card .tg-btn-primary {
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: #fff;
    box-shadow: 0 6px 20px rgba(99,102,241,0.35);
}
#tg-login-card .tg-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(99,102,241,0.45);
}
#tg-login-card .tg-btn-primary:active {
    transform: translateY(0);
}
#tg-login-card .tg-btn-secondary {
    background: transparent;
    color: #6366f1;
    border: 2px solid #e2e8f0;
    margin-bottom: 12px;
}
#tg-login-card .tg-btn-secondary:hover {
    background: #f1f5f9;
    border-color: #c7d2fe;
}
#tg-login-card .tg-btn-secondary.sending {
    opacity: 0.6;
    pointer-events: none;
}
#tg-login-card .tg-btn-secondary.sent {
    color: #16a34a;
    border-color: #bbf7d0;
    background: #f0fdf4;
}
#tg-login-card .tg-btn svg {
    width: 20px; height: 20px;
    fill: currentColor;
}

/* Ripple effect */
#tg-login-card .tg-btn .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.45);
    transform: scale(0);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
}
@keyframes ripple {
    to { transform: scale(4); opacity: 0; }
}

/* --- Footer --- */
#tg-login-card .tg-footer {
    text-align: center;
    margin-top: 28px;
    font-size: 12px;
    color: #94a3b8;
}
#tg-login-card .tg-footer a {
    color: #6366f1;
    text-decoration: none;
    font-weight: 600;
}

/* --- OTP hint badge --- */
#tg-login-card .tg-otp-hint {
    display: none;
    margin-top: -8px;
    margin-bottom: 18px;
    padding: 10px 14px;
    background: #eff6ff;
    border-radius: 10px;
    font-size: 13px;
    color: #1d4ed8;
    text-align: center;
    animation: cardIn 0.3s ease;
}
#tg-login-card .tg-otp-hint.show {
    display: block;
}

/* --- Resend link button --- */
#tg-login-card .tg-btn-link {
    background: transparent;
    color: #6366f1;
    border: none;
    margin-top: 14px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    padding: 8px;
    box-shadow: none;
}
#tg-login-card .tg-btn-link:hover {
    text-decoration: underline;
    background: transparent;
    box-shadow: none;
}

/* --- Slide animation for OTP field --- */
#tg-login-card .tg-otp-field {
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.16,1,0.3,1);
}

/* --- Error message (Roundcube message stack) --- */
#messagestack {
    position: fixed !important;
    top: 24px !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translateX(-50%);
    z-index: 9999 !important;
    width: auto !important;
    max-width: 90% !important;
    max-height: none !important;
    pointer-events: none;
}
#messagestack > div {
    pointer-events: auto;
    margin: 0 0 8px !important;
    border-radius: 14px !important;
    min-height: 0 !important;
    padding: 14px 22px !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25) !important;
    font-family: 'Segoe UI', system-ui, sans-serif !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    backdrop-filter: blur(8px);
    animation: cardIn 0.3s cubic-bezier(0.16,1,0.3,1);
}

/* --- Responsive --- */
@media (max-width: 480px) {
    #tg-login-card {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
        max-width: 100%;
        padding: 60px 24px 24px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    body.task-login::before,
    body.task-login::after { display: none; }
}

/* --- Hide the old form + footer ONLY after JS builds the new card --- */
body.task-login.tg-card-built #layout-content > #login-form,
body.task-login.tg-card-built #layout-content > #login-footer,
body.task-login.tg-card-built #layout-content > .noscriptwarning,
body.task-login.tg-card-built #layout-content > img#logo {
    display: none !important;
}
